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.8 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. compat_urllib_parse,
  8. )
  9. class ExtremeTubeIE(InfoExtractor):
  10. _VALID_URL = r'^(?:https?://)?(?:www\.)?(?P<url>extremetube\.com/video/.+?(?P<videoid>[0-9]+))(?:[/?&]|$)'
  11. _TEST = {
  12. u'url': u'http://www.extremetube.com/video/music-video-14-british-euro-brit-european-cumshots-swallow-652431',
  13. u'file': u'652431.mp4',
  14. u'md5': u'1fb9228f5e3332ec8c057d6ac36f33e0',
  15. u'info_dict': {
  16. u"title": u"Music Video 14 british euro brit european cumshots swallow",
  17. u"uploader": u"unknown",
  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'<h1 [^>]*?title="([^"]+)"[^>]*>\1<', webpage, u'title')
  29. uploader = self._html_search_regex(r'>Posted by:(?=<)(?:\s|<[^>]*>)*(.+?)\|', webpage, u'uploader', fatal=False)
  30. video_url = compat_urllib_parse.unquote(self._html_search_regex(r'video_url=(.+?)&amp;', webpage, u'video_url'))
  31. path = compat_urllib_parse_urlparse(video_url).path
  32. extension = os.path.splitext(path)[1][1:]
  33. format = path.split('/')[5].split('_')[:2]
  34. format = "-".join(format)
  35. return {
  36. 'id': video_id,
  37. 'title': video_title,
  38. 'uploader': uploader,
  39. 'url': video_url,
  40. 'ext': extension,
  41. 'format': format,
  42. 'format_id': format,
  43. 'age_limit': 18,
  44. }