You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_parse,
  6. )
  7. class XBefIE(InfoExtractor):
  8. _VALID_URL = r'http://(?:www\.)?xbef\.com/video/(?P<id>[0-9]+)'
  9. _TEST = {
  10. 'url': 'http://xbef.com/video/5119-glamourous-lesbians-smoking-drinking-and-fucking',
  11. 'md5': 'a478b565baff61634a98f5e5338be995',
  12. 'info_dict': {
  13. 'id': '5119',
  14. 'ext': 'mp4',
  15. 'title': 'md5:7358a9faef8b7b57acda7c04816f170e',
  16. 'age_limit': 18,
  17. 'thumbnail': 're:^http://.*\.jpg',
  18. }
  19. }
  20. def _real_extract(self, url):
  21. m = re.match(self._VALID_URL, url)
  22. video_id = m.group('id')
  23. webpage = self._download_webpage(url, video_id)
  24. title = self._html_search_regex(
  25. r'<h1[^>]*>(.*?)</h1>', webpage, 'title')
  26. config_url_enc = self._download_webpage(
  27. 'http://xbef.com/Main/GetVideoURLEncoded/%s' % video_id, video_id,
  28. note='Retrieving config URL')
  29. config_url = compat_urllib_parse.unquote(config_url_enc)
  30. config = self._download_xml(
  31. config_url, video_id, note='Retrieving config')
  32. video_url = config.find('./file').text
  33. thumbnail = config.find('./image').text
  34. return {
  35. 'id': video_id,
  36. 'url': video_url,
  37. 'title': title,
  38. 'thumbnail': thumbnail,
  39. 'age_limit': 18,
  40. }