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.

54 lines
2.0 KiB

  1. import os
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_parse_urlparse,
  6. compat_urllib_request,
  7. )
  8. class XTubeIE(InfoExtractor):
  9. _VALID_URL = r'^(?:https?://)?(?:www\.)?(?P<url>xtube\.com/watch\.php\?v=(?P<videoid>[^/?&]+))'
  10. _TEST = {
  11. u'url': u'http://www.xtube.com/watch.php?v=kVTUy_G222_',
  12. u'file': u'kVTUy_G222_.mp4',
  13. u'md5': u'092fbdd3cbe292c920ef6fc6a8a9cdab',
  14. u'info_dict': {
  15. u"title": u"strange erotica",
  16. u"description": u"surreal gay themed erotica...almost an ET kind of thing",
  17. u"uploader": u"greenshowers",
  18. u"age_limit": 18,
  19. }
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('videoid')
  24. url = 'http://www.' + mobj.group('url')
  25. req = compat_urllib_request.Request(url)
  26. req.add_header('Cookie', 'age_verified=1')
  27. webpage = self._download_webpage(req, video_id)
  28. video_title = self._html_search_regex(r'<div class="p_5px[^>]*>([^<]+)', webpage, u'title')
  29. video_uploader = self._html_search_regex(r'so_s\.addVariable\("owner_u", "([^"]+)', webpage, u'uploader', fatal=False)
  30. video_description = self._html_search_regex(r'<p class="video_description">([^<]+)', webpage, u'description', fatal=False)
  31. video_url= self._html_search_regex(r'var videoMp4 = "([^"]+)', webpage, u'video_url').replace('\\/', '/')
  32. path = compat_urllib_parse_urlparse(video_url).path
  33. extension = os.path.splitext(path)[1][1:]
  34. format = path.split('/')[5].split('_')[:2]
  35. format[0] += 'p'
  36. format[1] += 'k'
  37. format = "-".join(format)
  38. return {
  39. 'id': video_id,
  40. 'title': video_title,
  41. 'uploader': video_uploader,
  42. 'description': video_description,
  43. 'url': video_url,
  44. 'ext': extension,
  45. 'format': format,
  46. 'format_id': format,
  47. 'age_limit': 18,
  48. }