]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/viddler.py
   4 from .common 
import InfoExtractor
 
   7 class ViddlerIE(InfoExtractor
): 
   8     _VALID_URL 
= r
'(?P<domain>https?://(?:www\.)?viddler\.com)/(?:v|embed|player)/(?P<id>[a-z0-9]+)' 
  10         u
"url": u
"http://www.viddler.com/v/43903784", 
  11         u
'file': u
'43903784.mp4', 
  12         u
'md5': u
'fbbaedf7813e514eb7ca30410f439ac9', 
  14             u
"title": u
"Video Made Easy", 
  15             u
"uploader": u
"viddler", 
  20     def _real_extract(self
, url
): 
  21         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  22         video_id 
= mobj
.group('id') 
  24         embed_url 
= mobj
.group('domain') + u
'/embed/' + video_id
 
  25         webpage 
= self
._download
_webpage
(embed_url
, video_id
) 
  27         video_sources_code 
= self
._search
_regex
( 
  28             r
"(?ms)sources\s*:\s*(\{.*?\})", webpage
, u
'video URLs') 
  29         video_sources 
= json
.loads(video_sources_code
.replace("'", '"')) 
  34         } for video_url
, format_id 
in video_sources
.items()] 
  36         title 
= self
._html
_search
_regex
( 
  37             r
"title\s*:\s*'([^']*)'", webpage
, u
'title') 
  38         uploader 
= self
._html
_search
_regex
( 
  39             r
"authorName\s*:\s*'([^']*)'", webpage
, u
'uploader', fatal
=False) 
  40         duration_s 
= self
._html
_search
_regex
( 
  41             r
"duration\s*:\s*([0-9.]*)", webpage
, u
'duration', fatal
=False) 
  42         duration 
= float(duration_s
) if duration_s 
else None 
  43         thumbnail 
= self
._html
_search
_regex
( 
  44             r
"thumbnail\s*:\s*'([^']*)'", 
  45             webpage
, u
'thumbnail', fatal
=False) 
  51             'thumbnail': thumbnail
,