]>
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
15 class TV4IE ( InfoExtractor
):
16 IE_DESC
= 'tv4.se and tv4play.se'
17 _VALID_URL
= r
'''(?x)https?://(?:www\.)?
19 tv4\.se/(?:[^/]+)/klipp/(?:.*)-|
22 (?:program|barn)/(?:[^\?]+)\?video_id=|
30 'url' : 'http://www.tv4.se/kalla-fakta/klipp/kalla-fakta-5-english-subtitles-2491650' ,
31 'md5' : '909d6454b87b10a25aa04c4bdd416a9b' ,
35 'title' : 'Kalla Fakta 5 (english subtitles)' ,
36 'thumbnail' : 're:^https?://.*\.jpg$' ,
38 'upload_date' : '20131125' ,
42 'url' : 'http://www.tv4play.se/iframe/video/3054113' ,
43 'md5' : '77f851c55139ffe0ebd41b6a5552489b' ,
47 'title' : 'Så här jobbar ficktjuvarna - se avslöjande bilder' ,
48 'thumbnail' : '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 ,
68 def _real_extract ( self
, url
):
69 video_id
= self
._ match
_ id
( url
)
71 info
= self
._ download
_ json
(
72 'http://www.tv4play.se/player/assets/ %s .json' % video_id
,
73 video_id
, 'Downloading video info JSON' )
75 # If is_geo_restricted is true, it doesn't necessarily mean we can't download it
76 if info
. get ( 'is_geo_restricted' ):
77 self
. report_warning ( 'This content might not be available in your country due to licensing restrictions.' )
78 if info
. get ( 'requires_subscription' ):
79 raise ExtractorError ( 'This content requires subscription.' , expected
= True )
84 # http formats are linked with unresolvable host
85 for kind
in ( 'hls' , '' ):
86 data
= self
._ download
_ json
(
87 'https://prima.tv4play.se/api/web/asset/ %s /play.json' % video_id
,
88 video_id
, 'Downloading sources JSON' , query
={
90 'videoFormat' : 'MP4+WEBVTTS+WEBVTT' ,
92 item
= try_get ( data
, lambda x
: x
[ 'playback' ][ 'items' ][ 'item' ], dict )
93 manifest_url
= item
. get ( 'url' )
94 if not isinstance ( manifest_url
, compat_str
):
97 formats
. extend ( self
._ extract
_ m
3u8_ formats
(
98 manifest_url
, video_id
, 'mp4' , entry_protocol
= 'm3u8_native' ,
99 m3u8_id
= kind
, fatal
= False ))
101 formats
. extend ( self
._ extract
_ f
4 m
_ formats
(
102 update_url_query ( manifest_url
, { 'hdcore' : '3.8.0' }),
103 video_id
, f4m_id
= 'hds' , fatal
= False ))
104 self
._ sort
_ formats
( formats
)
110 'description' : info
. get ( 'description' ),
111 'timestamp' : parse_iso8601 ( info
. get ( 'broadcast_date_time' )),
112 'duration' : int_or_none ( info
. get ( 'duration' )),
113 'thumbnail' : info
. get ( 'image' ),
114 'is_live' : info
. get ( 'is_live' ) is True ,