]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vgtv.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from .xstream
import XstreamIE
15 class VGTVIE(XstreamIE
):
16 IE_DESC
= 'VGTV, BTTV, FTV, Aftenposten and Aftonbladet'
22 'aftenbladet.no/tv': 'satv',
23 'fvn.no/fvntv': 'fvntv',
24 'aftenposten.no/webtv': 'aptv',
25 'ap.vgtv.no/webtv': 'aptv',
26 'tv.aftonbladet.se/abtv': 'abtv',
27 'www.aftonbladet.se/tv': 'abtv',
30 _APP_NAME_TO_VENDOR
= {
40 (?:https?://(?:www\.)?
46 (?:\#!/)?(?:video|live)/|
54 ''' % ('|'.join(_HOST_TO_APPNAME
.keys()), '|'.join(_APP_NAME_TO_VENDOR
.keys()))
59 'url': 'http://www.vgtv.no/#!/video/84196/hevnen-er-soet-episode-10-abu',
60 'md5': 'b8be7a234cebb840c0d512c78013e02f',
64 'title': 'Hevnen er søt: Episode 10 - Abu',
65 'description': 'md5:e25e4badb5f544b04341e14abdc72234',
66 'thumbnail': r
're:^https?://.*\.jpg',
68 'timestamp': 1404626400,
69 'upload_date': '20140706',
75 'url': 'http://www.vgtv.no/#!/live/100764/opptak-vgtv-foelger-em-kvalifiseringen',
79 'title': 'OPPTAK: VGTV følger EM-kvalifiseringen',
80 'description': 'md5:3772d9c0dc2dff92a886b60039a7d4d3',
81 'thumbnail': r
're:^https?://.*\.jpg',
83 'timestamp': 1410113864,
84 'upload_date': '20140907',
89 'skip_download': True,
91 'skip': 'Video is no longer available',
95 'url': 'http://www.vgtv.no/#!/live/113063/direkte-v75-fra-solvalla',
99 'title': 'V75 fra Solvalla 30.05.15',
100 'description': 'md5:b3743425765355855f88e096acc93231',
101 'thumbnail': r
're:^https?://.*\.jpg',
103 'timestamp': 1432975582,
104 'upload_date': '20150530',
109 'skip_download': True,
113 'url': 'http://www.aftenposten.no/webtv/#!/video/21039/trailer-sweatshop-i-can-t-take-any-more',
114 'md5': 'fd828cd29774a729bf4d4425fe192972',
118 'title': 'TRAILER: «SWEATSHOP» - I can´t take any more',
119 'description': 'md5:21891f2b0dd7ec2f78d84a50e54f8238',
121 'timestamp': 1417002452,
122 'upload_date': '20141126',
127 'skip_download': True,
131 'url': 'http://www.bt.no/tv/#!/video/100250/norling-dette-er-forskjellen-paa-1-divisjon-og-eliteserien',
132 'only_matching': True,
135 'url': 'http://ap.vgtv.no/webtv#!/video/111084/de-nye-bysyklene-lettere-bedre-gir-stoerre-hjul-og-feste-til-mobil',
136 'only_matching': True,
140 'url': 'http://www.vgtv.no/#!/video/127205/inside-the-mind-of-favela-funk',
141 'only_matching': True,
144 'url': 'http://tv.aftonbladet.se/abtv/articles/36015',
145 'only_matching': True,
148 'url': 'https://www.aftonbladet.se/tv/a/36015',
149 'only_matching': True,
152 'url': 'abtv:140026',
153 'only_matching': True,
156 'url': 'http://www.vgtv.no/video/84196/hevnen-er-soet-episode-10-abu',
157 'only_matching': True,
161 def _real_extract(self
, url
):
162 mobj
= re
.match(self
._VALID
_URL
, url
)
163 video_id
= mobj
.group('id')
164 host
= mobj
.group('host')
165 appname
= self
._HOST
_TO
_APPNAME
[host
] if host
else mobj
.group('appname')
166 vendor
= self
._APP
_NAME
_TO
_VENDOR
[appname
]
168 data
= self
._download
_json
(
169 'http://svp.vg.no/svp/api/v1/%s/assets/%s?appName=%s-website'
170 % (vendor
, video_id
, appname
),
171 video_id
, 'Downloading media JSON')
173 if data
.get('status') == 'inactive':
174 raise ExtractorError(
175 'Video %s is no longer available' % video_id
, expected
=True)
180 if len(video_id
) == 5:
181 if appname
== 'bttv':
182 info
= self
._extract
_video
_info
('btno', video_id
)
184 streams
= data
['streamUrls']
185 stream_type
= data
.get('streamType')
186 is_live
= stream_type
== 'live'
189 hls_url
= streams
.get('hls')
191 formats
.extend(self
._extract
_m
3u8_formats
(
192 hls_url
, video_id
, 'mp4',
193 entry_protocol
='m3u8' if is_live
else 'm3u8_native',
194 m3u8_id
='hls', fatal
=False))
196 hds_url
= streams
.get('hds')
198 hdcore_sign
= 'hdcore=3.7.0'
199 f4m_formats
= self
._extract
_f
4m
_formats
(
200 hds_url
+ '?%s' % hdcore_sign
, video_id
, f4m_id
='hds', fatal
=False)
202 for entry
in f4m_formats
:
203 # URLs without the extra param induce an 404 error
204 entry
.update({'extra_param_to_segment_url': hdcore_sign
})
205 formats
.append(entry
)
207 mp4_urls
= streams
.get('pseudostreaming') or []
208 mp4_url
= streams
.get('mp4')
210 mp4_urls
.append(mp4_url
)
211 for mp4_url
in mp4_urls
:
215 mobj
= re
.search(r
'(\d+)_(\d+)_(\d+)', mp4_url
)
217 tbr
= int(mobj
.group(3))
219 'width': int(mobj
.group(1)),
220 'height': int(mobj
.group(2)),
222 'format_id': 'mp4-%s' % tbr
,
224 formats
.append(format_info
)
226 info
['formats'].extend(formats
)
228 if not info
['formats']:
229 properties
= try_get(
230 data
, lambda x
: x
['streamConfiguration']['properties'], list)
231 if properties
and 'geoblocked' in properties
:
232 raise self
.raise_geo_restricted(
233 countries
=[host
.rpartition('.')[-1].partition('/')[0].upper()])
235 self
._sort
_formats
(info
['formats'])
239 'title': self
._live
_title
(data
['title']) if is_live
else data
['title'],
240 'description': data
['description'],
241 'thumbnail': data
['images']['main'] + '?t[]=900x506q80',
242 'timestamp': data
['published'],
243 'duration': float_or_none(data
['duration'], 1000),
244 'view_count': data
['displays'],
250 class BTArticleIE(InfoExtractor
):
251 IE_NAME
= 'bt:article'
252 IE_DESC
= 'Bergens Tidende Articles'
253 _VALID_URL
= r
'https?://(?:www\.)?bt\.no/(?:[^/]+/)+(?P<id>[^/]+)-\d+\.html'
255 'url': 'http://www.bt.no/nyheter/lokalt/Kjemper-for-internatet-1788214.html',
256 'md5': '2acbe8ad129b3469d5ae51b1158878df',
260 'title': 'Alrekstad internat',
261 'description': 'md5:dc81a9056c874fedb62fc48a300dac58',
262 'thumbnail': r
're:^https?://.*\.jpg',
264 'timestamp': 1289991323,
265 'upload_date': '20101117',
270 def _real_extract(self
, url
):
271 webpage
= self
._download
_webpage
(url
, self
._match
_id
(url
))
272 video_id
= self
._search
_regex
(
273 r
'<video[^>]+data-id="(\d+)"', webpage
, 'video id')
274 return self
.url_result('bttv:%s' % video_id
, 'VGTV')
277 class BTVestlendingenIE(InfoExtractor
):
278 IE_NAME
= 'bt:vestlendingen'
279 IE_DESC
= 'Bergens Tidende - Vestlendingen'
280 _VALID_URL
= r
'https?://(?:www\.)?bt\.no/spesial/vestlendingen/#!/(?P<id>\d+)'
282 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86588',
283 'md5': 'd7d17e3337dc80de6d3a540aefbe441b',
287 'title': 'Otto Wollertsen',
288 'description': 'Vestlendingen Otto Fredrik Wollertsen',
289 'timestamp': 1430473209,
290 'upload_date': '20150501',
294 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86255',
295 'md5': 'a2893f8632e96389f4bdf36aa9463ceb',
299 'title': 'Du må tåle å fryse og være sulten',
300 'description': 'md5:b8046f4d022d5830ddab04865791d063',
301 'upload_date': '20150321',
302 'timestamp': 1426942023,
306 def _real_extract(self
, url
):
307 return self
.url_result('bttv:%s' % self
._match
_id
(url
), 'VGTV')