]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/trilulilu.py
0bf028f6195ba56be22e059bdc83d23cbabff59b
   3 import xml
.etree
.ElementTree
 
   5 from .common 
import InfoExtractor
 
   8 class TriluliluIE(InfoExtractor
): 
   9     _VALID_URL 
= r
'(?x)(?:https?://)?(?:www\.)?trilulilu\.ro/video-(?P<category>[^/]+)/(?P<video_id>[^/]+)' 
  11         u
"url": u
"http://www.trilulilu.ro/video-animatie/big-buck-bunny-1", 
  12         u
'file': u
"big-buck-bunny-1.mp4", 
  14             u
"title": u
"Big Buck Bunny", 
  15             u
"description": u
":) pentru copilul din noi", 
  17         # Server ignores Range headers (--test) 
  19             u
"skip_download": True 
  23     def _real_extract(self
, url
): 
  24         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  25         video_id 
= mobj
.group('video_id') 
  27         webpage 
= self
._download
_webpage
(url
, video_id
) 
  29         title 
= self
._og
_search
_title
(webpage
) 
  30         thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
  31         description 
= self
._og
_search
_description
(webpage
) 
  33         log_str 
= self
._search
_regex
( 
  34             r
'block_flash_vars[ ]=[ ]({[^}]+})', webpage
, u
'log info') 
  35         log 
= json
.loads(log_str
) 
  37         format_url 
= (u
'http://fs%(server)s.trilulilu.ro/%(hash)s/' 
  38                       u
'video-formats2' % log
) 
  39         format_str 
= self
._download
_webpage
( 
  41             note
=u
'Downloading formats', 
  42             errnote
=u
'Error while downloading formats') 
  44         format_doc 
= xml
.etree
.ElementTree
.fromstring(format_str
) 
  46         video_url_template 
= ( 
  47             u
'http://fs%(server)s.trilulilu.ro/stream.php?type=video' 
  48             u
'&source=site&hash=%(hash)s&username=%(userid)s&' 
  49             u
'key=ministhebest&format=%%s&sig=&exp=' % 
  54                 'url': video_url_template 
% fnode
.text
, 
  55                 'ext': fnode
.text
.partition('-')[0] 
  58             for fnode 
in format_doc
.findall('./formats/format') 
  66             'description': description
, 
  67             'thumbnail': thumbnail
, 
  70         # TODO: Remove when #980 has been merged 
  71         info
.update(formats
[-1])