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.

169 lines
6.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. )
  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': '71ec5fcfddacf80f495efa8b6a8d9a89',
  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': '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. # Anonymous User 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': 're:^https?://.*\.jpg$',
  43. 'uploader': 'Anonymous User',
  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'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. # We will benefit from it by extracting some metadata
  92. mobj = re.search(r'/(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+/', video_url)
  93. if mobj:
  94. height = int(mobj.group('height'))
  95. bitrate = int(mobj.group('bitrate'))
  96. f.update({
  97. 'format_id': '%dp-%dk' % (height, bitrate),
  98. 'height': height,
  99. 'tbr': bitrate,
  100. })
  101. formats.append(f)
  102. self._sort_formats(formats)
  103. description = self._og_search_description(webpage, default=None)
  104. thumbnail = self._search_regex(
  105. r'(?:imageurl\s*=|poster\s*:)\s*(["\'])(?P<thumbnail>.+?)\1',
  106. webpage, 'thumbnail', fatal=False, group='thumbnail')
  107. uploader = self._html_search_regex(
  108. r'(?s)<div[^>]+class=["\']videoInfoBy(?:\s+[^"\']+)?["\'][^>]*>\s*By:\s*</div>(.+?)</(?:a|div)>',
  109. webpage, 'uploader', fatal=False)
  110. upload_date = unified_strdate(self._html_search_regex(
  111. r'(?s)<div[^>]+class=["\']videoInfoTime["\'][^>]*>(.+?)</div>',
  112. webpage, 'upload date', fatal=False))
  113. age_limit = self._rta_search(webpage)
  114. average_rating = int_or_none(self._search_regex(
  115. r'<div[^>]+class=["\']videoInfoRating["\'][^>]*>\s*<div[^>]+class=["\']videoRatingPercentage["\'][^>]*>(\d+)%</div>',
  116. webpage, 'average rating', fatal=False))
  117. view_count = str_to_int(self._search_regex(
  118. r'(?s)<div[^>]+class=["\']videoInfoViews["\'][^>]*>.*?([\d,.]+)\s*</div>',
  119. webpage, 'view count', fatal=False))
  120. comment_count = str_to_int(self._search_regex(
  121. r'>All [Cc]omments? \(([\d,.]+)\)',
  122. webpage, 'comment count', fatal=False))
  123. def extract_tag_box(title):
  124. tag_box = self._search_regex(
  125. (r'<div[^>]+class=["\']tagBoxTitle["\'][^>]*>\s*%s\b.*?</div>\s*'
  126. '<div[^>]+class=["\']tagBoxContent["\']>(.+?)</div>') % re.escape(title),
  127. webpage, '%s tag box' % title, default=None)
  128. if not tag_box:
  129. return []
  130. return re.findall(r'<a[^>]+href=[^>]+>([^<]+)', tag_box)
  131. categories = extract_tag_box('Category')
  132. tags = extract_tag_box('Tags')
  133. return {
  134. 'id': video_id,
  135. 'display_id': display_id,
  136. 'title': title,
  137. 'description': description,
  138. 'thumbnail': thumbnail,
  139. 'uploader': uploader,
  140. 'upload_date': upload_date,
  141. 'average_rating': average_rating,
  142. 'view_count': view_count,
  143. 'comment_count': comment_count,
  144. 'categories': categories,
  145. 'tags': tags,
  146. 'age_limit': age_limit,
  147. 'formats': formats,
  148. }