]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tv4.py
2 from __future__
import unicode_literals
6 from . common
import InfoExtractor
13 class TV4IE ( InfoExtractor
):
14 IE_DESC
= 'tv4.se and tv4play.se'
15 _VALID_URL
= r
'''(?x)https?://(?:www\.)?
17 tv4\.se/(?:[^/]+)/klipp/(?:.*)-|
20 (?:program|barn)/(?:[^/]+/|(?:[^\?]+)\?video_id=)|
26 _GEO_COUNTRIES
= [ 'SE' ]
29 'url' : 'http://www.tv4.se/kalla-fakta/klipp/kalla-fakta-5-english-subtitles-2491650' ,
30 'md5' : 'cb837212f342d77cec06e6dad190e96d' ,
34 'title' : 'Kalla Fakta 5 (english subtitles)' ,
35 'thumbnail' : r
're:^https?://.*\.jpg$' ,
37 'upload_date' : '20131125' ,
41 'url' : 'http://www.tv4play.se/iframe/video/3054113' ,
42 'md5' : 'cb837212f342d77cec06e6dad190e96d' ,
46 'title' : 'Så här jobbar ficktjuvarna - se avslöjande bilder' ,
47 'thumbnail' : r
're:^https?://.*\.jpg$' ,
48 '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.' ,
50 'upload_date' : '20150130' ,
54 'url' : 'http://www.tv4play.se/sport/3060959' ,
55 'only_matching' : True ,
58 'url' : 'http://www.tv4play.se/film/2378136' ,
59 'only_matching' : True ,
62 'url' : 'http://www.tv4play.se/barn/looney-tunes?video_id=3062412' ,
63 'only_matching' : True ,
66 'url' : 'http://www.tv4play.se/program/farang/3922081' ,
67 'only_matching' : True ,
71 def _real_extract ( self
, url
):
72 video_id
= self
._ match
_ id
( url
)
74 info
= self
._ download
_ json
(
75 'https://playback-api.b17g.net/asset/ %s ' % video_id
,
76 video_id
, 'Downloading video info JSON' , query
={
79 'protocol' : 'hls,dash' ,
85 manifest_url
= self
._ download
_ json
(
86 'https://playback-api.b17g.net/media/' + video_id
,
91 })[ 'playbackItem' ][ 'manifestUrl' ]
92 formats
= self
._ extract
_ m
3u8_ formats
(
93 manifest_url
, video_id
, 'mp4' ,
94 'm3u8_native' , m3u8_id
= 'hls' , fatal
= False )
95 formats
. extend ( self
._ extract
_ mpd
_ formats
(
96 manifest_url
. replace ( '.m3u8' , '.mpd' ),
97 video_id
, mpd_id
= 'dash' , fatal
= False ))
98 formats
. extend ( self
._ extract
_ f
4 m
_ formats
(
99 manifest_url
. replace ( '.m3u8' , '.f4m' ),
100 video_id
, f4m_id
= 'hds' , fatal
= False ))
101 formats
. extend ( self
._ extract
_ ism
_ formats
(
102 re
. sub ( r
'\.ism/.+?\.m3u8' , r
'.ism/Manifest' , manifest_url
),
103 video_id
, ism_id
= 'mss' , fatal
= False ))
105 if not formats
and info
. get ( 'is_geo_restricted' ):
106 self
. raise_geo_restricted ( countries
= self
._ GEO
_ COUNTRIES
)
108 self
._ sort
_ formats
( formats
)
114 # 'subtitles': subtitles,
115 'description' : info
. get ( 'description' ),
116 'timestamp' : parse_iso8601 ( info
. get ( 'broadcast_date_time' )),
117 'duration' : int_or_none ( info
. get ( 'duration' )),
118 'thumbnail' : info
. get ( 'image' ),
119 'is_live' : info
. get ( 'isLive' ) is True ,
120 'series' : info
. get ( 'seriesTitle' ),
121 'season_number' : int_or_none ( info
. get ( 'seasonNumber' )),
122 'episode' : info
. get ( 'episodeTitle' ),
123 'episode_number' : int_or_none ( info
. get ( 'episodeNumber' )),