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.

117 lines
4.4 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
10 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. parse_iso8601,
  7. sanitized_Request,
  8. str_to_int,
  9. )
  10. class FourTubeIE(InfoExtractor):
  11. IE_NAME = '4tube'
  12. _VALID_URL = r'https?://(?:www\.)?4tube\.com/videos/(?P<id>\d+)'
  13. _TEST = {
  14. 'url': 'http://www.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
  15. 'md5': '6516c8ac63b03de06bc8eac14362db4f',
  16. 'info_dict': {
  17. 'id': '209733',
  18. 'ext': 'mp4',
  19. 'title': 'Hot Babe Holly Michaels gets her ass stuffed by black',
  20. 'uploader': 'WCP Club',
  21. 'uploader_id': 'wcp-club',
  22. 'upload_date': '20131031',
  23. 'timestamp': 1383263892,
  24. 'duration': 583,
  25. 'view_count': int,
  26. 'like_count': int,
  27. 'categories': list,
  28. 'age_limit': 18,
  29. }
  30. }
  31. def _real_extract(self, url):
  32. video_id = self._match_id(url)
  33. webpage = self._download_webpage(url, video_id)
  34. title = self._html_search_meta('name', webpage)
  35. timestamp = parse_iso8601(self._html_search_meta(
  36. 'uploadDate', webpage))
  37. thumbnail = self._html_search_meta('thumbnailUrl', webpage)
  38. uploader_id = self._html_search_regex(
  39. r'<a class="img-avatar" href="[^"]+/channels/([^/"]+)" title="Go to [^"]+ page">',
  40. webpage, 'uploader id', fatal=False)
  41. uploader = self._html_search_regex(
  42. r'<a class="img-avatar" href="[^"]+/channels/[^/"]+" title="Go to ([^"]+) page">',
  43. webpage, 'uploader', fatal=False)
  44. categories_html = self._search_regex(
  45. r'(?s)><i class="icon icon-tag"></i>\s*Categories / Tags\s*.*?<ul class="list">(.*?)</ul>',
  46. webpage, 'categories', fatal=False)
  47. categories = None
  48. if categories_html:
  49. categories = [
  50. c.strip() for c in re.findall(
  51. r'(?s)<li><a.*?>(.*?)</a>', categories_html)]
  52. view_count = str_to_int(self._search_regex(
  53. r'<meta itemprop="interactionCount" content="UserPlays:([0-9,]+)">',
  54. webpage, 'view count', fatal=False))
  55. like_count = str_to_int(self._search_regex(
  56. r'<meta itemprop="interactionCount" content="UserLikes:([0-9,]+)">',
  57. webpage, 'like count', fatal=False))
  58. duration = parse_duration(self._html_search_meta('duration', webpage))
  59. media_id = self._search_regex(
  60. r'<button[^>]+data-id=(["\'])(?P<id>\d+)\1[^>]+data-quality=', webpage,
  61. 'media id', default=None, group='id')
  62. sources = [
  63. quality
  64. for _, quality in re.findall(r'<button[^>]+data-quality=(["\'])(.+?)\1', webpage)]
  65. if not (media_id and sources):
  66. player_js = self._download_webpage(
  67. self._search_regex(
  68. r'<script[^>]id=(["\'])playerembed\1[^>]+src=(["\'])(?P<url>.+?)\2',
  69. webpage, 'player JS', group='url'),
  70. video_id, 'Downloading player JS')
  71. params_js = self._search_regex(
  72. r'\$\.ajax\(url,\ opts\);\s*\}\s*\}\)\(([0-9,\[\] ]+)\)',
  73. player_js, 'initialization parameters')
  74. params = self._parse_json('[%s]' % params_js, video_id)
  75. media_id = params[0]
  76. sources = ['%s' % p for p in params[2]]
  77. token_url = 'http://tkn.4tube.com/{0}/desktop/{1}'.format(
  78. media_id, '+'.join(sources))
  79. headers = {
  80. b'Content-Type': b'application/x-www-form-urlencoded',
  81. b'Origin': b'http://www.4tube.com',
  82. }
  83. token_req = sanitized_Request(token_url, b'{}', headers)
  84. tokens = self._download_json(token_req, video_id)
  85. formats = [{
  86. 'url': tokens[format]['token'],
  87. 'format_id': format + 'p',
  88. 'resolution': format + 'p',
  89. 'quality': int(format),
  90. } for format in sources]
  91. self._sort_formats(formats)
  92. return {
  93. 'id': video_id,
  94. 'title': title,
  95. 'formats': formats,
  96. 'categories': categories,
  97. 'thumbnail': thumbnail,
  98. 'uploader': uploader,
  99. 'uploader_id': uploader_id,
  100. 'timestamp': timestamp,
  101. 'like_count': like_count,
  102. 'view_count': view_count,
  103. 'duration': duration,
  104. 'age_limit': 18,
  105. }