]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tv4.py
2 from __future__
import unicode_literals
4 from . common
import InfoExtractor
11 class TV4IE ( InfoExtractor
):
12 IE_DESC
= 'tv4.se and tv4play.se'
13 _VALID_URL
= r
'''(?x)https?://(?:www\.)?
15 tv4\.se/(?:[^/]+)/klipp/(?:.*)-|
18 (?:program|barn)/(?:[^\?]+)\?video_id=|
26 'url' : 'http://www.tv4.se/kalla-fakta/klipp/kalla-fakta-5-english-subtitles-2491650' ,
27 'md5' : '909d6454b87b10a25aa04c4bdd416a9b' ,
31 'title' : 'Kalla Fakta 5 (english subtitles)' ,
32 'thumbnail' : 're:^https?://.*\.jpg$' ,
34 'upload_date' : '20131125' ,
38 'url' : 'http://www.tv4play.se/iframe/video/3054113' ,
39 'md5' : '77f851c55139ffe0ebd41b6a5552489b' ,
43 'title' : 'Så här jobbar ficktjuvarna - se avslöjande bilder' ,
44 'thumbnail' : '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 ,
64 def _real_extract ( self
, url
):
65 video_id
= self
._ match
_ id
( url
)
67 info
= self
._ download
_ json
(
68 'http://www.tv4play.se/player/assets/ %s .json' % video_id
, video_id
, 'Downloading video info JSON' )
70 # If is_geo_restricted is true, it doesn't necessarily mean we can't download it
71 if info
[ 'is_geo_restricted' ]:
72 self
. report_warning ( 'This content might not be available in your country due to licensing restrictions.' )
73 if info
[ 'requires_subscription' ]:
74 raise ExtractorError ( 'This content requires subscription.' , expected
= True )
76 sources_data
= self
._ download
_ json
(
77 'https://prima.tv4play.se/api/web/asset/ %s /play.json?protocol=http&videoFormat=MP4' % video_id
, video_id
, 'Downloading sources JSON' )
78 sources
= sources_data
[ 'playback' ]
81 for item
in sources
. get ( 'items' , {}). get ( 'item' , []):
82 ext
, bitrate
= item
[ 'mediaFormat' ], item
[ 'bitrate' ]
84 'format_id' : ' %s _ %s ' % ( ext
, bitrate
),
89 self
._ sort
_ formats
( formats
)
93 'title' : info
[ 'title' ],
95 'description' : info
. get ( 'description' ),
96 'timestamp' : parse_iso8601 ( info
. get ( 'broadcast_date_time' )),
97 'duration' : info
. get ( 'duration' ),
98 'thumbnail' : info
. get ( 'image' ),
99 'is_live' : sources
. get ( 'live' ),