]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/svt.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
12 class SVTBaseIE(InfoExtractor
):
13 def _extract_video(self
, url
, video_id
):
14 info
= self
._download
_json
(url
, video_id
)
16 title
= info
['context']['title']
17 thumbnail
= info
['context'].get('thumbnailImage')
19 video_info
= info
['video']
21 for vr
in video_info
['videoReferences']:
23 ext
= determine_ext(vurl
)
25 formats
.extend(self
._extract
_m
3u8_formats
(
27 ext
='mp4', entry_protocol
='m3u8_native',
28 m3u8_id
=vr
.get('playerType')))
30 formats
.extend(self
._extract
_f
4m
_formats
(
31 vurl
+ '?hdcore=3.3.0', video_id
,
32 f4m_id
=vr
.get('playerType')))
35 'format_id': vr
.get('playerType'),
38 self
._sort
_formats
(formats
)
40 duration
= video_info
.get('materialLength')
41 age_limit
= 18 if video_info
.get('inappropriateForChildren') else 0
47 'thumbnail': thumbnail
,
49 'age_limit': age_limit
,
53 class SVTIE(SVTBaseIE
):
54 _VALID_URL
= r
'https?://(?:www\.)?svt\.se/wd\?(?:.*?&)?widgetId=(?P<widget_id>\d+)&.*?\barticleId=(?P<id>\d+)'
56 'url': 'http://www.svt.se/wd?widgetId=23991§ionId=541&articleId=2900353&type=embed&contextSectionId=123&autostart=false',
57 'md5': '9648197555fc1b49e3dc22db4af51d46',
61 'title': 'Här trycker Jagr till Giroux (under SVT-intervjun)',
68 def _extract_url(webpage
):
70 r
'(?:<iframe src|href)="(?P<url>%s[^"]*)"' % SVTIE
._VALID
_URL
, webpage
)
72 return mobj
.group('url')
74 def _real_extract(self
, url
):
75 mobj
= re
.match(self
._VALID
_URL
, url
)
76 widget_id
= mobj
.group('widget_id')
77 article_id
= mobj
.group('id')
78 return self
._extract
_video
(
79 'http://www.svt.se/wd?widgetId=%s&articleId=%s&format=json&type=embed&output=json' % (widget_id
, article_id
),
83 class SVTPlayIE(SVTBaseIE
):
84 IE_DESC
= 'SVT Play and Öppet arkiv'
85 _VALID_URL
= r
'https?://(?:www\.)?(?P<host>svtplay|oppetarkiv)\.se/video/(?P<id>[0-9]+)'
87 'url': 'http://www.svtplay.se/video/2609989/sm-veckan/sm-veckan-rally-final-sasong-1-sm-veckan-rally-final',
88 'md5': 'ade3def0643fa1c40587a422f98edfd9',
92 'title': 'SM veckan vinter, Örebro - Rally, final',
94 'thumbnail': 're:^https?://.*[\.-]jpg$',
98 'url': 'http://www.oppetarkiv.se/video/1058509/rederiet-sasong-1-avsnitt-1-av-318',
99 'md5': 'c3101a17ce9634f4c1f9800f0746c187',
103 'title': 'Farlig kryssning',
105 'thumbnail': 're:^https?://.*[\.-]jpg$',
108 'skip': 'Only works from Sweden',
111 def _real_extract(self
, url
):
112 mobj
= re
.match(self
._VALID
_URL
, url
)
113 video_id
= mobj
.group('id')
114 host
= mobj
.group('host')
115 return self
._extract
_video
(
116 'http://www.%s.se/video/%s?output=json' % (host
, video_id
),