]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/fourtube.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
16 class FourTubeIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:www\.)?4tube\.com/videos/(?P<id>\d+)'
21 'url': 'http://www.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
22 'md5': '6516c8ac63b03de06bc8eac14362db4f',
26 'title': 'Hot Babe Holly Michaels gets her ass stuffed by black',
27 'uploader': 'WCP Club',
28 'uploader_id': 'wcp-club',
29 'upload_date': '20131031',
30 'timestamp': 1383263892,
38 def _real_extract(self
, url
):
39 video_id
= self
._match
_id
(url
)
40 webpage
= self
._download
_webpage
(url
, video_id
)
42 title
= self
._html
_search
_meta
('name', webpage
)
43 timestamp
= parse_iso8601(self
._html
_search
_meta
(
44 'uploadDate', webpage
))
45 thumbnail
= self
._html
_search
_meta
('thumbnailUrl', webpage
)
46 uploader_id
= self
._html
_search
_regex
(
47 r
'<a class="img-avatar" href="[^"]+/channels/([^/"]+)" title="Go to [^"]+ page">',
48 webpage
, 'uploader id')
49 uploader
= self
._html
_search
_regex
(
50 r
'<a class="img-avatar" href="[^"]+/channels/[^/"]+" title="Go to ([^"]+) page">',
53 categories_html
= self
._search
_regex
(
54 r
'(?s)><i class="icon icon-tag"></i>\s*Categories / Tags\s*.*?<ul class="list">(.*?)</ul>',
55 webpage
, 'categories', fatal
=False)
59 c
.strip() for c
in re
.findall(
60 r
'(?s)<li><a.*?>(.*?)</a>', categories_html
)]
62 view_count
= str_to_int(self
._search
_regex
(
63 r
'<meta itemprop="interactionCount" content="UserPlays:([0-9,]+)">',
64 webpage
, 'view count', fatal
=False))
65 like_count
= str_to_int(self
._search
_regex
(
66 r
'<meta itemprop="interactionCount" content="UserLikes:([0-9,]+)">',
67 webpage
, 'like count', fatal
=False))
68 duration
= parse_duration(self
._html
_search
_meta
('duration', webpage
))
70 params_js
= self
._search
_regex
(
71 r
'\$\.ajax\(url,\ opts\);\s*\}\s*\}\)\(([0-9,\[\] ]+)\)',
72 webpage
, 'initialization parameters'
74 params
= self
._parse
_json
('[%s]' % params_js
, video_id
)
76 sources
= ['%s' % p
for p
in params
[2]]
78 token_url
= 'http://tkn.4tube.com/{0}/desktop/{1}'.format(
79 media_id
, '+'.join(sources
))
81 b
'Content-Type': b
'application/x-www-form-urlencoded',
82 b
'Origin': b
'http://www.4tube.com',
84 token_req
= compat_urllib_request
.Request(token_url
, b
'{}', headers
)
85 tokens
= self
._download
_json
(token_req
, video_id
)
87 'url': tokens
[format
]['token'],
88 'format_id': format
+ 'p',
89 'resolution': format
+ 'p',
90 'quality': int(format
),
91 } for format
in sources
]
92 self
._sort
_formats
(formats
)
98 'categories': categories
,
99 'thumbnail': thumbnail
,
100 'uploader': uploader
,
101 'uploader_id': uploader_id
,
102 'timestamp': timestamp
,
103 'like_count': like_count
,
104 'view_count': view_count
,
105 'duration': duration
,