]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tv4.py
3 from . common
import InfoExtractor
10 class TV4IE ( InfoExtractor
):
11 IE_DESC
= 'tv4.se and tv4play.se'
12 _VALID_URL
= r
'''(?x)https?://(?:www\.)?
14 tv4\.se/(?:[^/]+)/klipp/(?:.*)-|
17 (?:program|barn)/(?:(?:[^/]+/) {1,2} |(?:[^\?]+)\?video_id=)|
23 _GEO_COUNTRIES
= [ 'SE' ]
26 'url' : 'http://www.tv4.se/kalla-fakta/klipp/kalla-fakta-5-english-subtitles-2491650' ,
27 'md5' : 'cb837212f342d77cec06e6dad190e96d' ,
31 'title' : 'Kalla Fakta 5 (english subtitles)' ,
32 'thumbnail' : r
're:^https?://.*\.jpg$' ,
34 'upload_date' : '20131125' ,
38 'url' : 'http://www.tv4play.se/iframe/video/3054113' ,
39 'md5' : 'cb837212f342d77cec06e6dad190e96d' ,
43 'title' : 'Så här jobbar ficktjuvarna - se avslöjande bilder' ,
44 'thumbnail' : r
're:^https?://.*\.jpg$' ,
45 '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.' ,
47 'upload_date' : '20150130' ,
51 'url' : 'http://www.tv4play.se/sport/3060959' ,
52 'only_matching' : True ,
55 'url' : 'http://www.tv4play.se/film/2378136' ,
56 'only_matching' : True ,
59 'url' : 'http://www.tv4play.se/barn/looney-tunes?video_id=3062412' ,
60 'only_matching' : True ,
63 'url' : 'http://www.tv4play.se/program/farang/3922081' ,
64 'only_matching' : True ,
67 'url' : 'https://www.tv4play.se/program/nyheterna/avsnitt/13315940' ,
68 'only_matching' : True ,
72 def _real_extract ( self
, url
):
73 video_id
= self
._ match
_ id
( url
)
75 info
= self
._ download
_ json
(
76 'https://playback-api.b17g.net/asset/ %s ' % video_id
,
77 video_id
, 'Downloading video info JSON' , query
={
80 'protocol' : 'hls,dash' ,
86 manifest_url
= self
._ download
_ json
(
87 'https://playback-api.b17g.net/media/' + video_id
,
92 })[ 'playbackItem' ][ 'manifestUrl' ]
96 fmts
, subs
= self
._ extract
_ m
3u8_ formats
_ and
_ subtitles
(
97 manifest_url
, video_id
, 'mp4' ,
98 'm3u8_native' , m3u8_id
= 'hls' , fatal
= False )
100 subtitles
= self
._ merge
_ subtitles
( subtitles
, subs
)
102 fmts
, subs
= self
._ extract
_ mpd
_ formats
_ and
_ subtitles
(
103 manifest_url
. replace ( '.m3u8' , '.mpd' ),
104 video_id
, mpd_id
= 'dash' , fatal
= False )
106 subtitles
= self
._ merge
_ subtitles
( subtitles
, subs
)
108 fmts
= self
._ extract
_ f
4 m
_ formats
(
109 manifest_url
. replace ( '.m3u8' , '.f4m' ),
110 video_id
, f4m_id
= 'hds' , fatal
= False )
113 fmts
, subs
= self
._ extract
_ ism
_ formats
_ and
_ subtitles
(
114 re
. sub ( r
'\.ism/.*?\.m3u8' , r
'.ism/Manifest' , manifest_url
),
115 video_id
, ism_id
= 'mss' , fatal
= False )
117 subtitles
= self
._ merge
_ subtitles
( subtitles
, subs
)
119 if not formats
and info
. get ( 'is_geo_restricted' ):
120 self
. raise_geo_restricted ( countries
= self
._ GEO
_ COUNTRIES
, metadata_available
= True )
126 'subtitles' : subtitles
,
127 'description' : info
. get ( 'description' ),
128 'timestamp' : parse_iso8601 ( info
. get ( 'broadcast_date_time' )),
129 'duration' : int_or_none ( info
. get ( 'duration' )),
130 'thumbnail' : info
. get ( 'image' ),
131 'is_live' : info
. get ( 'isLive' ) is True ,
132 'series' : info
. get ( 'seriesTitle' ),
133 'season_number' : int_or_none ( info
. get ( 'seasonNumber' )),
134 'episode' : info
. get ( 'episodeTitle' ),
135 'episode_number' : int_or_none ( info
. get ( 'episodeNumber' )),