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.

132 lines
4.3 KiB

Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
  1. from __future__ import unicode_literals
  2. import itertools
  3. import re
  4. from .common import InfoExtractor
  5. from ..compat import compat_urllib_parse_unquote
  6. from ..utils import (
  7. int_or_none,
  8. orderedSet,
  9. sanitized_Request,
  10. str_to_int,
  11. )
  12. class XTubeIE(InfoExtractor):
  13. _VALID_URL = r'(?:xtube:|https?://(?:www\.)?xtube\.com/(?:watch\.php\?.*\bv=|video-watch/(?P<display_id>[^/]+)-))(?P<id>[^/?&#]+)'
  14. _TESTS = [{
  15. # old URL schema
  16. 'url': 'http://www.xtube.com/watch.php?v=kVTUy_G222_',
  17. 'md5': '092fbdd3cbe292c920ef6fc6a8a9cdab',
  18. 'info_dict': {
  19. 'id': 'kVTUy_G222_',
  20. 'ext': 'mp4',
  21. 'title': 'strange erotica',
  22. 'description': 'contains:an ET kind of thing',
  23. 'uploader': 'greenshowers',
  24. 'duration': 450,
  25. 'age_limit': 18,
  26. }
  27. }, {
  28. # new URL schema
  29. 'url': 'http://www.xtube.com/video-watch/strange-erotica-625837',
  30. 'only_matching': True,
  31. }, {
  32. 'url': 'xtube:625837',
  33. 'only_matching': True,
  34. }]
  35. def _real_extract(self, url):
  36. mobj = re.match(self._VALID_URL, url)
  37. video_id = mobj.group('id')
  38. display_id = mobj.group('display_id')
  39. if not display_id:
  40. display_id = video_id
  41. url = 'http://www.xtube.com/watch.php?v=%s' % video_id
  42. req = sanitized_Request(url)
  43. req.add_header('Cookie', 'age_verified=1; cookiesAccepted=1')
  44. webpage = self._download_webpage(req, display_id)
  45. flashvars = self._parse_json(
  46. self._search_regex(
  47. r'xt\.playerOps\s*=\s*({.+?});', webpage, 'player ops'),
  48. video_id)['flashvars']
  49. title = flashvars.get('title') or self._search_regex(
  50. r'<h1>([^<]+)</h1>', webpage, 'title')
  51. video_url = compat_urllib_parse_unquote(flashvars['video_url'])
  52. duration = int_or_none(flashvars.get('video_duration'))
  53. uploader = self._search_regex(
  54. r'<input[^>]+name="contentOwnerId"[^>]+value="([^"]+)"',
  55. webpage, 'uploader', fatal=False)
  56. description = self._search_regex(
  57. r'</h1>\s*<p>([^<]+)', webpage, 'description', fatal=False)
  58. view_count = str_to_int(self._search_regex(
  59. r'<dt>Views:</dt>\s*<dd>([\d,\.]+)</dd>',
  60. webpage, 'view count', fatal=False))
  61. comment_count = str_to_int(self._html_search_regex(
  62. r'>Comments? \(([\d,\.]+)\)<',
  63. webpage, 'comment count', fatal=False))
  64. return {
  65. 'id': video_id,
  66. 'display_id': display_id,
  67. 'url': video_url,
  68. 'title': title,
  69. 'description': description,
  70. 'uploader': uploader,
  71. 'duration': duration,
  72. 'view_count': view_count,
  73. 'comment_count': comment_count,
  74. 'age_limit': 18,
  75. }
  76. class XTubeUserIE(InfoExtractor):
  77. IE_DESC = 'XTube user profile'
  78. _VALID_URL = r'https?://(?:www\.)?xtube\.com/profile/(?P<id>[^/]+-\d+)'
  79. _TEST = {
  80. 'url': 'http://www.xtube.com/profile/greenshowers-4056496',
  81. 'info_dict': {
  82. 'id': 'greenshowers-4056496',
  83. 'age_limit': 18,
  84. },
  85. 'playlist_mincount': 155,
  86. }
  87. def _real_extract(self, url):
  88. user_id = self._match_id(url)
  89. entries = []
  90. for pagenum in itertools.count(1):
  91. request = sanitized_Request(
  92. 'http://www.xtube.com/profile/%s/videos/%d' % (user_id, pagenum),
  93. headers={
  94. 'Cookie': 'popunder=4',
  95. 'X-Requested-With': 'XMLHttpRequest',
  96. 'Referer': url,
  97. })
  98. page = self._download_json(
  99. request, user_id, 'Downloading videos JSON page %d' % pagenum)
  100. html = page.get('html')
  101. if not html:
  102. break
  103. for video_id in orderedSet([video_id for _, video_id in re.findall(
  104. r'data-plid=(["\'])(.+?)\1', html)]):
  105. entries.append(self.url_result('xtube:%s' % video_id, XTubeIE.ie_key()))
  106. page_count = int_or_none(page.get('pageCount'))
  107. if not page_count or pagenum == page_count:
  108. break
  109. playlist = self.playlist_result(entries, user_id)
  110. playlist['age_limit'] = 18
  111. return playlist