]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/playwire.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
13 class PlaywireIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:config|cdn)\.playwire\.com(?:/v2)?/(?P<publisher_id>\d+)/(?:videos/v2|embed|config)/(?P<id>\d+)'
16 'url': 'http://config.playwire.com/14907/videos/v2/3353705/player.json',
17 'md5': 'e6398701e3595888125729eaa2329ed9',
21 'title': 'S04_RM_UCL_Rus',
22 'thumbnail': 're:^http://.*\.png$',
26 'url': 'http://cdn.playwire.com/11625/embed/85228.html',
27 'only_matching': True,
29 'url': 'http://config.playwire.com/12421/videos/v2/3389892/zeus.json',
30 'only_matching': True,
32 'url': 'http://cdn.playwire.com/v2/12342/config/1532636.json',
33 'only_matching': True,
36 def _real_extract(self
, url
):
37 mobj
= re
.match(self
._VALID
_URL
, url
)
38 publisher_id
, video_id
= mobj
.group('publisher_id'), mobj
.group('id')
40 player
= self
._download
_json
(
41 'http://config.playwire.com/%s/videos/v2/%s/zeus.json' % (publisher_id
, video_id
),
44 title
= player
['settings']['title']
45 duration
= float_or_none(player
.get('duration'), 1000)
47 content
= player
['content']
48 thumbnail
= content
.get('poster')
49 src
= content
['media']['f4m']
51 f4m
= self
._download
_xml
(src
, video_id
)
52 base_url
= xpath_text(f4m
, './{http://ns.adobe.com/f4m/1.0}baseURL', 'base url', fatal
=True)
54 for media
in f4m
.findall('./{http://ns.adobe.com/f4m/1.0}media'):
55 media_url
= media
.get('url')
58 tbr
= int_or_none(media
.get('bitrate'))
59 width
= int_or_none(media
.get('width'))
60 height
= int_or_none(media
.get('height'))
62 'url': '%s/%s' % (base_url
, media
.attrib
['url']),
67 if not (tbr
or width
or height
):
68 f
['quality'] = 1 if '-hd.' in media_url
else 0
70 self
._sort
_formats
(formats
)
75 'thumbnail': thumbnail
,