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.

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