]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tv4.py
2 from __future__
import unicode_literals
4 from . common
import InfoExtractor
5 from .. compat
import compat_str
14 class TV4IE ( InfoExtractor
):
15 IE_DESC
= 'tv4.se and tv4play.se'
16 _VALID_URL
= r
'''(?x)https?://(?:www\.)?
18 tv4\.se/(?:[^/]+)/klipp/(?:.*)-|
21 (?:program|barn)/(?:[^/]+/|(?:[^\?]+)\?video_id=)|
27 _GEO_COUNTRIES
= [ 'SE' ]
30 'url' : 'http://www.tv4.se/kalla-fakta/klipp/kalla-fakta-5-english-subtitles-2491650' ,
31 'md5' : 'cb837212f342d77cec06e6dad190e96d' ,
35 'title' : 'Kalla Fakta 5 (english subtitles)' ,
36 'thumbnail' : r
're:^https?://.*\.jpg$' ,
38 'upload_date' : '20131125' ,
42 'url' : 'http://www.tv4play.se/iframe/video/3054113' ,
43 'md5' : 'cb837212f342d77cec06e6dad190e96d' ,
47 'title' : 'Så här jobbar ficktjuvarna - se avslöjande bilder' ,
48 'thumbnail' : r
're:^https?://.*\.jpg$' ,
49 'description' : 'Unika bilder avslöjar hur turisternas fickor vittjas mitt på Stockholms central. Två experter på ficktjuvarna avslöjar knepen du ska se upp för.' ,
51 'upload_date' : '20150130' ,
55 'url' : 'http://www.tv4play.se/sport/3060959' ,
56 'only_matching' : True ,
59 'url' : 'http://www.tv4play.se/film/2378136' ,
60 'only_matching' : True ,
63 'url' : 'http://www.tv4play.se/barn/looney-tunes?video_id=3062412' ,
64 'only_matching' : True ,
67 'url' : 'http://www.tv4play.se/program/farang/3922081' ,
68 'only_matching' : True ,
72 def _real_extract ( self
, url
):
73 video_id
= self
._ match
_ id
( url
)
75 info
= self
._ download
_ json
(
76 'http://www.tv4play.se/player/assets/ %s .json' % video_id
,
77 video_id
, 'Downloading video info JSON' )
83 # http formats are linked with unresolvable host
84 for kind
in ( 'hls3' , '' ):
85 data
= self
._ download
_ json
(
86 'https://prima.tv4play.se/api/web/asset/ %s /play.json' % video_id
,
87 video_id
, 'Downloading sources JSON' , query
={
89 'videoFormat' : 'MP4+WEBVTT' ,
91 items
= try_get ( data
, lambda x
: x
[ 'playback' ][ 'items' ][ 'item' ])
94 if isinstance ( items
, dict ):
97 manifest_url
= item
. get ( 'url' )
98 if not isinstance ( manifest_url
, compat_str
):
100 ext
= determine_ext ( manifest_url
)
102 formats
. extend ( self
._ extract
_ m
3u8_ formats
(
103 manifest_url
, video_id
, 'mp4' , entry_protocol
= 'm3u8_native' ,
104 m3u8_id
= kind
, fatal
= False ))
106 formats
. extend ( self
._ extract
_ akamai
_ formats
(
107 manifest_url
, video_id
, {
108 'hls' : 'tv4play-i.akamaihd.net' ,
110 elif ext
== 'webvtt' :
111 subtitles
= self
._ merge
_ subtitles
(
118 if not formats
and info
. get ( 'is_geo_restricted' ):
119 self
. raise_geo_restricted ( countries
= self
._ GEO
_ COUNTRIES
)
121 self
._ sort
_ formats
( formats
)
127 'subtitles' : subtitles
,
128 'description' : info
. get ( 'description' ),
129 'timestamp' : parse_iso8601 ( info
. get ( 'broadcast_date_time' )),
130 'duration' : int_or_none ( info
. get ( 'duration' )),
131 'thumbnail' : info
. get ( 'image' ),
132 'is_live' : info
. get ( 'is_live' ) is True ,