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.

192 lines
7.6 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
10 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. sanitized_Request,
  7. str_to_int,
  8. unescapeHTML,
  9. unified_strdate,
  10. url_or_none,
  11. )
  12. from ..aes import aes_decrypt_text
  13. class YouPornIE(InfoExtractor):
  14. _VALID_URL = r'https?://(?:www\.)?youporn\.com/watch/(?P<id>\d+)/(?P<display_id>[^/?#&]+)'
  15. _TESTS = [{
  16. 'url': 'http://www.youporn.com/watch/505835/sex-ed-is-it-safe-to-masturbate-daily/',
  17. 'md5': '3744d24c50438cf5b6f6d59feb5055c2',
  18. 'info_dict': {
  19. 'id': '505835',
  20. 'display_id': 'sex-ed-is-it-safe-to-masturbate-daily',
  21. 'ext': 'mp4',
  22. 'title': 'Sex Ed: Is It Safe To Masturbate Daily?',
  23. 'description': 'Love & Sex Answers: http://bit.ly/DanAndJenn -- Is It Unhealthy To Masturbate Daily?',
  24. 'thumbnail': r're:^https?://.*\.jpg$',
  25. 'uploader': 'Ask Dan And Jennifer',
  26. 'upload_date': '20101217',
  27. 'average_rating': int,
  28. 'view_count': int,
  29. 'comment_count': int,
  30. 'categories': list,
  31. 'tags': list,
  32. 'age_limit': 18,
  33. },
  34. }, {
  35. # Unknown uploader
  36. 'url': 'http://www.youporn.com/watch/561726/big-tits-awesome-brunette-on-amazing-webcam-show/?from=related3&al=2&from_id=561726&pos=4',
  37. 'info_dict': {
  38. 'id': '561726',
  39. 'display_id': 'big-tits-awesome-brunette-on-amazing-webcam-show',
  40. 'ext': 'mp4',
  41. 'title': 'Big Tits Awesome Brunette On amazing webcam show',
  42. 'description': 'http://sweetlivegirls.com Big Tits Awesome Brunette On amazing webcam show.mp4',
  43. 'thumbnail': r're:^https?://.*\.jpg$',
  44. 'uploader': 'Unknown',
  45. 'upload_date': '20110418',
  46. 'average_rating': int,
  47. 'view_count': int,
  48. 'comment_count': int,
  49. 'categories': list,
  50. 'tags': list,
  51. 'age_limit': 18,
  52. },
  53. 'params': {
  54. 'skip_download': True,
  55. },
  56. }]
  57. def _real_extract(self, url):
  58. mobj = re.match(self._VALID_URL, url)
  59. video_id = mobj.group('id')
  60. display_id = mobj.group('display_id')
  61. request = sanitized_Request(url)
  62. request.add_header('Cookie', 'age_verified=1')
  63. webpage = self._download_webpage(request, display_id)
  64. title = self._html_search_regex(
  65. r'(?s)<div[^>]+class=["\']watchVideoTitle[^>]+>(.+?)</div>',
  66. webpage, 'title', default=None) or self._og_search_title(
  67. webpage, default=None) or self._html_search_meta(
  68. 'title', webpage, fatal=True)
  69. links = []
  70. # Main source
  71. definitions = self._parse_json(
  72. self._search_regex(
  73. r'mediaDefinition\s*=\s*(\[.+?\]);', webpage,
  74. 'media definitions', default='[]'),
  75. video_id, fatal=False)
  76. if definitions:
  77. for definition in definitions:
  78. if not isinstance(definition, dict):
  79. continue
  80. video_url = url_or_none(definition.get('videoUrl'))
  81. if video_url:
  82. links.append(video_url)
  83. # Fallback #1, this also contains extra low quality 180p format
  84. for _, link in re.findall(r'<a[^>]+href=(["\'])(http.+?)\1[^>]+title=["\']Download [Vv]ideo', webpage):
  85. links.append(link)
  86. # Fallback #2 (unavailable as at 22.06.2017)
  87. sources = self._search_regex(
  88. r'(?s)sources\s*:\s*({.+?})', webpage, 'sources', default=None)
  89. if sources:
  90. for _, link in re.findall(r'[^:]+\s*:\s*(["\'])(http.+?)\1', sources):
  91. links.append(link)
  92. # Fallback #3 (unavailable as at 22.06.2017)
  93. for _, link in re.findall(
  94. r'(?:videoSrc|videoIpadUrl|html5PlayerSrc)\s*[:=]\s*(["\'])(http.+?)\1', webpage):
  95. links.append(link)
  96. # Fallback #4, encrypted links (unavailable as at 22.06.2017)
  97. for _, encrypted_link in re.findall(
  98. r'encryptedQuality\d{3,4}URL\s*=\s*(["\'])([\da-zA-Z+/=]+)\1', webpage):
  99. links.append(aes_decrypt_text(encrypted_link, title, 32).decode('utf-8'))
  100. formats = []
  101. for video_url in set(unescapeHTML(link) for link in links):
  102. f = {
  103. 'url': video_url,
  104. }
  105. # Video URL's path looks like this:
  106. # /201012/17/505835/720p_1500k_505835/YouPorn%20-%20Sex%20Ed%20Is%20It%20Safe%20To%20Masturbate%20Daily.mp4
  107. # /201012/17/505835/vl_240p_240k_505835/YouPorn%20-%20Sex%20Ed%20Is%20It%20Safe%20To%20Masturbate%20Daily.mp4
  108. # We will benefit from it by extracting some metadata
  109. mobj = re.search(r'(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+/', video_url)
  110. if mobj:
  111. height = int(mobj.group('height'))
  112. bitrate = int(mobj.group('bitrate'))
  113. f.update({
  114. 'format_id': '%dp-%dk' % (height, bitrate),
  115. 'height': height,
  116. 'tbr': bitrate,
  117. })
  118. formats.append(f)
  119. self._sort_formats(formats)
  120. description = self._html_search_regex(
  121. r'(?s)<div[^>]+\bid=["\']description["\'][^>]*>(.+?)</div>',
  122. webpage, 'description',
  123. default=None) or self._og_search_description(
  124. webpage, default=None)
  125. thumbnail = self._search_regex(
  126. r'(?:imageurl\s*=|poster\s*:)\s*(["\'])(?P<thumbnail>.+?)\1',
  127. webpage, 'thumbnail', fatal=False, group='thumbnail')
  128. uploader = self._html_search_regex(
  129. r'(?s)<div[^>]+class=["\']submitByLink["\'][^>]*>(.+?)</div>',
  130. webpage, 'uploader', fatal=False)
  131. upload_date = unified_strdate(self._html_search_regex(
  132. [r'Date\s+[Aa]dded:\s*<span>([^<]+)',
  133. r'(?s)<div[^>]+class=["\']videoInfo(?:Date|Time)["\'][^>]*>(.+?)</div>'],
  134. webpage, 'upload date', fatal=False))
  135. age_limit = self._rta_search(webpage)
  136. average_rating = int_or_none(self._search_regex(
  137. r'<div[^>]+class=["\']videoRatingPercentage["\'][^>]*>(\d+)%</div>',
  138. webpage, 'average rating', fatal=False))
  139. view_count = str_to_int(self._search_regex(
  140. r'(?s)<div[^>]+class=(["\']).*?\bvideoInfoViews\b.*?\1[^>]*>.*?(?P<count>[\d,.]+)<',
  141. webpage, 'view count', fatal=False, group='count'))
  142. comment_count = str_to_int(self._search_regex(
  143. r'>All [Cc]omments? \(([\d,.]+)\)',
  144. webpage, 'comment count', fatal=False))
  145. def extract_tag_box(regex, title):
  146. tag_box = self._search_regex(regex, webpage, title, default=None)
  147. if not tag_box:
  148. return []
  149. return re.findall(r'<a[^>]+href=[^>]+>([^<]+)', tag_box)
  150. categories = extract_tag_box(
  151. r'(?s)Categories:.*?</[^>]+>(.+?)</div>', 'categories')
  152. tags = extract_tag_box(
  153. r'(?s)Tags:.*?</div>\s*<div[^>]+class=["\']tagBoxContent["\'][^>]*>(.+?)</div>',
  154. 'tags')
  155. return {
  156. 'id': video_id,
  157. 'display_id': display_id,
  158. 'title': title,
  159. 'description': description,
  160. 'thumbnail': thumbnail,
  161. 'uploader': uploader,
  162. 'upload_date': upload_date,
  163. 'average_rating': average_rating,
  164. 'view_count': view_count,
  165. 'comment_count': comment_count,
  166. 'categories': categories,
  167. 'tags': tags,
  168. 'age_limit': age_limit,
  169. 'formats': formats,
  170. }