]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/viddler.py
4 from .common
import InfoExtractor
10 class ViddlerIE(InfoExtractor
):
11 _VALID_URL
= r
'(?P<domain>https?://(?:www\.)?viddler.com)/(?:v|embed|player)/(?P<id>[0-9]+)'
13 u
"url": u
"http://www.viddler.com/v/43903784",
14 u
'file': u
'43903784.mp4',
15 u
'md5': u
'fbbaedf7813e514eb7ca30410f439ac9',
17 u
"title": u
"Video Made Easy",
18 u
"uploader": u
"viddler",
23 def _real_extract(self
, url
):
24 mobj
= re
.match(self
._VALID
_URL
, url
)
25 video_id
= mobj
.group('id')
27 embed_url
= mobj
.group('domain') + u
'/embed/' + video_id
28 webpage
= self
._download
_webpage
(embed_url
, video_id
)
30 video_sources_code
= self
._search
_regex
(
31 r
"(?ms)sources\s*:\s*(\{.*?\})", webpage
, u
'video URLs')
32 video_sources
= json
.loads(video_sources_code
.replace("'", '"'))
37 } for video_url
, format_id
in video_sources
.items()]
39 title
= self
._html
_search
_regex
(
40 r
"title\s*:\s*'([^']*)'", webpage
, u
'title')
41 uploader
= self
._html
_search
_regex
(
42 r
"authorName\s*:\s*'([^']*)'", webpage
, u
'uploader', fatal
=False)
43 duration_s
= self
._html
_search
_regex
(
44 r
"duration\s*:\s*([0-9.]*)", webpage
, u
'duration', fatal
=False)
45 duration
= float(duration_s
) if duration_s
else None
46 thumbnail
= self
._html
_search
_regex
(
47 r
"thumbnail\s*:\s*'([^']*)'",
48 webpage
, u
'thumbnail', fatal
=False)
54 'thumbnail': thumbnail
,
60 # TODO: Remove when #980 has been merged
61 info
['formats'][-1]['ext'] = determine_ext(info
['formats'][-1]['url'])
62 info
.update(info
['formats'][-1])