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.

58 lines
1.9 KiB

  1. from __future__ import unicode_literals
  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. _TESTS = [{
  12. 'url': 'http://www.extremetube.com/video/music-video-14-british-euro-brit-european-cumshots-swallow-652431',
  13. 'md5': '1fb9228f5e3332ec8c057d6ac36f33e0',
  14. 'info_dict': {
  15. 'id': '652431',
  16. 'ext': 'mp4',
  17. 'title': 'Music Video 14 british euro brit european cumshots swallow',
  18. 'uploader': 'unknown',
  19. 'age_limit': 18,
  20. }
  21. }, {
  22. 'url': 'http://www.extremetube.com/gay/video/abcde-1234',
  23. 'only_matching': True,
  24. }]
  25. def _real_extract(self, url):
  26. mobj = re.match(self._VALID_URL, url)
  27. video_id = mobj.group('videoid')
  28. url = 'http://www.' + mobj.group('url')
  29. req = compat_urllib_request.Request(url)
  30. req.add_header('Cookie', 'age_verified=1')
  31. webpage = self._download_webpage(req, video_id)
  32. video_title = self._html_search_regex(
  33. r'<h1 [^>]*?title="([^"]+)"[^>]*>\1<', webpage, 'title')
  34. uploader = self._html_search_regex(
  35. r'>Posted by:(?=<)(?:\s|<[^>]*>)*(.+?)\|', webpage, 'uploader',
  36. fatal=False)
  37. video_url = compat_urllib_parse.unquote(self._html_search_regex(
  38. r'video_url=(.+?)&amp;', webpage, 'video_url'))
  39. path = compat_urllib_parse_urlparse(video_url).path
  40. format = path.split('/')[5].split('_')[:2]
  41. format = "-".join(format)
  42. return {
  43. 'id': video_id,
  44. 'title': video_title,
  45. 'uploader': uploader,
  46. 'url': video_url,
  47. 'format': format,
  48. 'format_id': format,
  49. 'age_limit': 18,
  50. }