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.

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