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.

67 lines
2.2 KiB

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