]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/youporn.py
dd724085add2adbcacde458a23902cf07395382f
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
13 from ..aes
import aes_decrypt_text
16 class YouPornIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?youporn\.com/watch/(?P<id>\d+)/(?P<display_id>[^/?#&]+)'
19 'url': 'http://www.youporn.com/watch/505835/sex-ed-is-it-safe-to-masturbate-daily/',
20 'md5': '71ec5fcfddacf80f495efa8b6a8d9a89',
23 'display_id': 'sex-ed-is-it-safe-to-masturbate-daily',
25 'title': 'Sex Ed: Is It Safe To Masturbate Daily?',
26 'description': 'Love & Sex Answers: http://bit.ly/DanAndJenn -- Is It Unhealthy To Masturbate Daily?',
27 'thumbnail': 're:^https?://.*\.jpg$',
28 'uploader': 'Ask Dan And Jennifer',
29 'upload_date': '20101221',
30 'average_rating': int,
38 # Anonymous User uploader
39 'url': 'http://www.youporn.com/watch/561726/big-tits-awesome-brunette-on-amazing-webcam-show/?from=related3&al=2&from_id=561726&pos=4',
42 'display_id': 'big-tits-awesome-brunette-on-amazing-webcam-show',
44 'title': 'Big Tits Awesome Brunette On amazing webcam show',
45 'description': 'http://sweetlivegirls.com Big Tits Awesome Brunette On amazing webcam show.mp4',
46 'thumbnail': 're:^https?://.*\.jpg$',
47 'uploader': 'Anonymous User',
48 'upload_date': '20111125',
49 'average_rating': int,
57 'skip_download': True,
61 def _real_extract(self
, url
):
62 mobj
= re
.match(self
._VALID
_URL
, url
)
63 video_id
= mobj
.group('id')
64 display_id
= mobj
.group('display_id')
66 request
= sanitized_Request(url
)
67 request
.add_header('Cookie', 'age_verified=1')
68 webpage
= self
._download
_webpage
(request
, display_id
)
70 title
= self
._search
_regex
(
71 [r
'(?:video_titles|videoTitle)\s*[:=]\s*(["\'])(?P
<title
>.+?
)\
1',
72 r'<h1
[^
>]+class=["\']heading\d?["\'][^
>]*>([^
<])<'],
73 webpage, 'title
', group='title
')
77 sources = self._search_regex(
78 r'sources\s
*:\s
*({.+?
})', webpage, 'sources
', default=None)
80 for _, link in re.findall(r'[^
:]+\s
*:\s
*(["\'])(http.+?)\1', sources):
84 for _, link in re.findall(
85 r'(?:videoUrl|videoSrc|videoIpadUrl|html5PlayerSrc)\s*[:=]\s*(["\'])(http
.+?
)\
1', webpage):
88 # Fallback #2, this also contains extra low quality 180p format
89 for _, link in re.findall(r'<a
[^
>]+href
=(["\'])(http.+?)\1[^>]+title=["\']Download
[Vv
]ideo
', webpage):
92 # Fallback #3, encrypted links
93 for _, encrypted_link in re.findall(
94 r'encryptedQuality\d
{3,4}URL\s
*=\s
*(["\'])([\da-zA-Z+/=]+)\1', webpage):
95 links.append(aes_decrypt_text(encrypted_link, title, 32).decode('utf-8'))
98 for video_url in set(unescapeHTML(link) for link in links):
102 # Video URL's path looks like this:
103 # /201012/17/505835/720p_1500k_505835/YouPorn%20-%20Sex%20Ed%20Is%20It%20Safe%20To%20Masturbate%20Daily.mp4
104 # We will benefit from it by extracting some metadata
105 mobj = re.search(r'/(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+/', video_url)
107 height = int(mobj.group('height'))
108 bitrate = int(mobj.group('bitrate'))
110 'format_id': '%dp-%dk' % (height, bitrate),
115 self._sort_formats(formats)
117 description = self._html_search_regex(
118 r'(?s)<div[^>]+class=["\']video
-description
["\'][^>]*>(.+?)</div>',
119 webpage, 'description', default=None)
120 thumbnail = self._search_regex(
121 r'(?:imageurl\s*=|poster\s*:)\s*(["\'])(?P
<thumbnail
>.+?
)\
1',
122 webpage, 'thumbnail
', fatal=False, group='thumbnail
')
124 uploader = self._html_search_regex(
125 r'(?s
)<div
[^
>]+class=["\']videoInfoBy["\'][^
>]*>\s
*By
:\s
*</div
>(.+?
)</(?
:a|div
)>',
126 webpage, 'uploader
', fatal=False)
127 upload_date = unified_strdate(self._html_search_regex(
128 r'(?s
)<div
[^
>]+class=["\']videoInfoTime["\'][^
>]*>(.+?
)</div
>',
129 webpage, 'upload date
', fatal=False))
131 age_limit = self._rta_search(webpage)
133 average_rating = int_or_none(self._search_regex(
134 r'<div
[^
>]+class=["\']videoInfoRating["\'][^
>]*>\s
*<div
[^
>]+class=["\']videoRatingPercentage["\'][^
>]*>(\d
+)%</div
>',
135 webpage, 'average rating
', fatal=False))
137 view_count = str_to_int(self._search_regex(
138 r'(?s
)<div
[^
>]+class=["\']videoInfoViews["\'][^
>]*>.*?
([\d
,.]+)\s
*</div
>',
139 webpage, 'view count
', fatal=False))
140 comment_count = str_to_int(self._search_regex(
141 r'>All
[Cc
]omments? \
(([\d
,.]+)\
)',
142 webpage, 'comment count
', fatal=False))
144 def extract_tag_box(title):
145 tag_box = self._search_regex(
146 (r'<div
[^
>]+class=["\']tagBoxTitle["\'][^
>]*>\s
*%s\b.*?
</div
>\s
*'
147 '<div
[^
>]+class=["\']tagBoxContent["\']>(.+?
)</div
>') % re.escape(title),
148 webpage, '%s tag box
' % title, default=None)
151 return re.findall(r'<a
[^
>]+href
=[^
>]+>([^
<]+)', tag_box)
153 categories = extract_tag_box('Category
')
154 tags = extract_tag_box('Tags
')
158 'display_id
': display_id,
160 'description
': description,
161 'thumbnail
': thumbnail,
162 'uploader
': uploader,
163 'upload_date
': upload_date,
164 'average_rating
': average_rating,
165 'view_count
': view_count,
166 'comment_count
': comment_count,
167 'categories
': categories,
169 'age_limit
': age_limit,