]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/fourtube.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_urlparse
14 class FourTubeBaseIE(InfoExtractor
):
15 def _real_extract(self
, url
):
16 mobj
= re
.match(self
._VALID
_URL
, url
)
17 kind
, video_id
, display_id
= mobj
.group('kind', 'id', 'display_id')
19 if kind
== 'm' or not display_id
:
20 url
= self
._URL
_TEMPLATE
% video_id
22 webpage
= self
._download
_webpage
(url
, video_id
)
24 title
= self
._html
_search
_meta
('name', webpage
)
25 timestamp
= parse_iso8601(self
._html
_search
_meta
(
26 'uploadDate', webpage
))
27 thumbnail
= self
._html
_search
_meta
('thumbnailUrl', webpage
)
28 uploader_id
= self
._html
_search
_regex
(
29 r
'<a class="item-to-subscribe" href="[^"]+/(?:channel|user)s?/([^/"]+)" title="Go to [^"]+ page">',
30 webpage
, 'uploader id', fatal
=False)
31 uploader
= self
._html
_search
_regex
(
32 r
'<a class="item-to-subscribe" href="[^"]+/(?:channel|user)s?/[^/"]+" title="Go to ([^"]+) page">',
33 webpage
, 'uploader', fatal
=False)
35 categories_html
= self
._search
_regex
(
36 r
'(?s)><i class="icon icon-tag"></i>\s*Categories / Tags\s*.*?<ul class="[^"]*?list[^"]*?">(.*?)</ul>',
37 webpage
, 'categories', fatal
=False)
41 c
.strip() for c
in re
.findall(
42 r
'(?s)<li><a.*?>(.*?)</a>', categories_html
)]
44 view_count
= str_to_int(self
._search
_regex
(
45 r
'<meta[^>]+itemprop="interactionCount"[^>]+content="UserPlays:([0-9,]+)">',
46 webpage
, 'view count', default
=None))
47 like_count
= str_to_int(self
._search
_regex
(
48 r
'<meta[^>]+itemprop="interactionCount"[^>]+content="UserLikes:([0-9,]+)">',
49 webpage
, 'like count', default
=None))
50 duration
= parse_duration(self
._html
_search
_meta
('duration', webpage
))
52 media_id
= self
._search
_regex
(
53 r
'<button[^>]+data-id=(["\'])(?P
<id>\d
+)\
1[^
>]+data
-quality
=', webpage,
54 'media
id', default=None, group='id')
57 for _, quality in re.findall(r'<button
[^
>]+data
-quality
=(["\'])(.+?)\1', webpage)]
58 if not (media_id and sources):
59 player_js = self._download_webpage(
61 r'<script[^>]id=(["\'])playerembed\
1[^
>]+src
=(["\'])(?P<url>.+?)\2',
62 webpage, 'player JS', group='url'),
63 video_id, 'Downloading player JS')
64 params_js = self._search_regex(
65 r'\$\.ajax\(url,\ opts\);\s*\}\s*\}\)\(([0-9,\[\] ]+)\)',
66 player_js, 'initialization parameters')
67 params = self._parse_json('[%s]' % params_js, video_id)
69 sources = ['%s' % p for p in params[2]]
71 token_url = 'https://tkn.kodicdn.com/{0}/desktop/{1}'.format(
72 media_id, '+'.join(sources))
74 parsed_url = compat_urlparse.urlparse(url)
75 tokens = self._download_json(token_url, video_id, data=b'', headers={
76 'Origin': '%s://%s' % (parsed_url.scheme, parsed_url.hostname),
80 'url': tokens[format]['token'],
81 'format_id': format + 'p',
82 'resolution': format + 'p',
83 'quality': int(format),
84 } for format in sources]
85 self._sort_formats(formats)
91 'categories': categories,
92 'thumbnail': thumbnail,
94 'uploader_id': uploader_id,
95 'timestamp': timestamp,
96 'like_count': like_count,
97 'view_count': view_count,
103 class FourTubeIE(FourTubeBaseIE):
105 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?4tube\.com/(?:videos|embed)/(?P<id>\d+)(?:/(?P<display_id>[^/?#&]+))?'
106 _URL_TEMPLATE = 'https://www.4tube.com/videos/%s/video'
108 'url': 'http://www.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
109 'md5': '6516c8ac63b03de06bc8eac14362db4f',
113 'title': 'Hot Babe Holly Michaels gets her ass stuffed by black',
114 'uploader': 'WCP Club',
115 'uploader_id': 'wcp-club',
116 'upload_date': '20131031',
117 'timestamp': 1383263892,
125 'url': 'http://www.4tube.com/embed/209733',
126 'only_matching': True,
128 'url': 'http://m.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
129 'only_matching': True,
133 class FuxIE(FourTubeBaseIE):
134 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?fux\.com/(?:video|embed)/(?P<id>\d+)(?:/(?P<display_id>[^/?#&]+))?'
135 _URL_TEMPLATE = 'https://www.fux.com/video/%s/video'
137 'url': 'https://www.fux.com/video/195359/awesome-fucking-kitchen-ends-cum-swallow',
141 'title': 'Awesome fucking in the kitchen ends with cum swallow',
142 'uploader': 'alenci2342',
143 'uploader_id': 'alenci2342',
144 'upload_date': '20131230',
145 'timestamp': 1388361660,
153 'skip_download': True,
156 'url': 'https://www.fux.com/embed/195359',
157 'only_matching': True,
159 'url': 'https://www.fux.com/video/195359/awesome-fucking-kitchen-ends-cum-swallow',
160 'only_matching': True,
164 class PornTubeIE(FourTubeBaseIE):
165 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?porntube\.com/(?:videos/(?P<display_id>[^/]+)_|embed/)(?P<id>\d+)'
166 _URL_TEMPLATE = 'https://www.porntube.com/videos/video_%s'
168 'url': 'https://www.porntube.com/videos/teen-couple-doing-anal_7089759',
172 'title': 'Teen couple doing anal',
174 'uploader_id': 'Alexy',
175 'upload_date': '20150606',
176 'timestamp': 1433595647,
184 'skip_download': True,
187 'url': 'https://www.porntube.com/embed/7089759',
188 'only_matching': True,
190 'url': 'https://m.porntube.com/videos/teen-couple-doing-anal_7089759',
191 'only_matching': True,
195 class PornerBrosIE(FourTubeBaseIE):
196 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?pornerbros\.com/(?:videos/(?P<display_id>[^/]+)_|embed/)(?P<id>\d+)'
197 _URL_TEMPLATE = 'https://www.pornerbros.com/videos/video_%s'
199 'url': 'https://www.pornerbros.com/videos/skinny-brunette-takes-big-cock-down-her-anal-hole_181369',
200 'md5': '6516c8ac63b03de06bc8eac14362db4f',
204 'title': 'Skinny brunette takes big cock down her anal hole',
205 'uploader': 'PornerBros HD',
206 'uploader_id': 'pornerbros-hd',
207 'upload_date': '20130130',
208 'timestamp': 1359527401,
215 'skip_download': True,
218 'url': 'https://www.pornerbros.com/embed/181369',
219 'only_matching': True,
221 'url': 'https://m.pornerbros.com/videos/skinny-brunette-takes-big-cock-down-her-anal-hole_181369',
222 'only_matching': True,