]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vgtv.py
0f8c156a79ff7d67958b88e488ff50548bf3c998
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',
29 _APP_NAME_TO_VENDOR
= {
39 (?:https?://(?:www\.)?
53 ''' % ('|'.join(_HOST_TO_APPNAME
.keys()), '|'.join(_APP_NAME_TO_VENDOR
.keys()))
58 'url': 'http://www.vgtv.no/#!/video/84196/hevnen-er-soet-episode-10-abu',
59 'md5': 'b8be7a234cebb840c0d512c78013e02f',
63 'title': 'Hevnen er søt: Episode 10 - Abu',
64 'description': 'md5:e25e4badb5f544b04341e14abdc72234',
65 'thumbnail': r
're:^https?://.*\.jpg',
67 'timestamp': 1404626400,
68 'upload_date': '20140706',
74 'url': 'http://www.vgtv.no/#!/live/100764/opptak-vgtv-foelger-em-kvalifiseringen',
78 'title': 'OPPTAK: VGTV følger EM-kvalifiseringen',
79 'description': 'md5:3772d9c0dc2dff92a886b60039a7d4d3',
80 'thumbnail': r
're:^https?://.*\.jpg',
82 'timestamp': 1410113864,
83 'upload_date': '20140907',
88 'skip_download': True,
90 'skip': 'Video is no longer available',
94 'url': 'http://www.vgtv.no/#!/live/113063/direkte-v75-fra-solvalla',
98 'title': 'V75 fra Solvalla 30.05.15',
99 'description': 'md5:b3743425765355855f88e096acc93231',
100 'thumbnail': r
're:^https?://.*\.jpg',
102 'timestamp': 1432975582,
103 'upload_date': '20150530',
108 'skip_download': True,
112 'url': 'http://www.aftenposten.no/webtv/#!/video/21039/trailer-sweatshop-i-can-t-take-any-more',
113 'md5': 'fd828cd29774a729bf4d4425fe192972',
117 'title': 'TRAILER: «SWEATSHOP» - I can´t take any more',
118 'description': 'md5:21891f2b0dd7ec2f78d84a50e54f8238',
120 'timestamp': 1417002452,
121 'upload_date': '20141126',
126 'skip_download': True,
130 'url': 'http://www.bt.no/tv/#!/video/100250/norling-dette-er-forskjellen-paa-1-divisjon-og-eliteserien',
131 'only_matching': True,
134 'url': 'http://ap.vgtv.no/webtv#!/video/111084/de-nye-bysyklene-lettere-bedre-gir-stoerre-hjul-og-feste-til-mobil',
135 'only_matching': True,
139 'url': 'http://www.vgtv.no/#!/video/127205/inside-the-mind-of-favela-funk',
140 'only_matching': True,
143 'url': 'http://tv.aftonbladet.se/abtv/articles/36015',
144 'only_matching': True,
147 'url': 'abtv:140026',
148 'only_matching': True,
152 def _real_extract(self
, url
):
153 mobj
= re
.match(self
._VALID
_URL
, url
)
154 video_id
= mobj
.group('id')
155 host
= mobj
.group('host')
156 appname
= self
._HOST
_TO
_APPNAME
[host
] if host
else mobj
.group('appname')
157 vendor
= self
._APP
_NAME
_TO
_VENDOR
[appname
]
159 data
= self
._download
_json
(
160 'http://svp.vg.no/svp/api/v1/%s/assets/%s?appName=%s-website'
161 % (vendor
, video_id
, appname
),
162 video_id
, 'Downloading media JSON')
164 if data
.get('status') == 'inactive':
165 raise ExtractorError(
166 'Video %s is no longer available' % video_id
, expected
=True)
171 if len(video_id
) == 5:
172 if appname
== 'bttv':
173 info
= self
._extract
_video
_info
('btno', video_id
)
175 streams
= data
['streamUrls']
176 stream_type
= data
.get('streamType')
180 hls_url
= streams
.get('hls')
182 formats
.extend(self
._extract
_m
3u8_formats
(
183 hls_url
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
185 hds_url
= streams
.get('hds')
187 hdcore_sign
= 'hdcore=3.7.0'
188 f4m_formats
= self
._extract
_f
4m
_formats
(
189 hds_url
+ '?%s' % hdcore_sign
, video_id
, f4m_id
='hds', fatal
=False)
191 for entry
in f4m_formats
:
192 # URLs without the extra param induce an 404 error
193 entry
.update({'extra_param_to_segment_url': hdcore_sign
})
194 formats
.append(entry
)
196 mp4_urls
= streams
.get('pseudostreaming') or []
197 mp4_url
= streams
.get('mp4')
199 mp4_urls
.append(mp4_url
)
200 for mp4_url
in mp4_urls
:
204 mobj
= re
.search(r
'(\d+)_(\d+)_(\d+)', mp4_url
)
206 tbr
= int(mobj
.group(3))
208 'width': int(mobj
.group(1)),
209 'height': int(mobj
.group(2)),
211 'format_id': 'mp4-%s' % tbr
,
213 formats
.append(format_info
)
215 info
['formats'].extend(formats
)
217 if not info
['formats']:
218 properties
= try_get(
219 data
, lambda x
: x
['streamConfiguration']['properties'], list)
220 if properties
and 'geoblocked' in properties
:
221 raise self
.raise_geo_restricted(
222 countries
=[host
.rpartition('.')[-1].partition('/')[0].upper()])
224 self
._sort
_formats
(info
['formats'])
228 'title': self
._live
_title
(data
['title']) if stream_type
== 'live' else data
['title'],
229 'description': data
['description'],
230 'thumbnail': data
['images']['main'] + '?t[]=900x506q80',
231 'timestamp': data
['published'],
232 'duration': float_or_none(data
['duration'], 1000),
233 'view_count': data
['displays'],
234 'is_live': True if stream_type
== 'live' else False,
239 class BTArticleIE(InfoExtractor
):
240 IE_NAME
= 'bt:article'
241 IE_DESC
= 'Bergens Tidende Articles'
242 _VALID_URL
= r
'https?://(?:www\.)?bt\.no/(?:[^/]+/)+(?P<id>[^/]+)-\d+\.html'
244 'url': 'http://www.bt.no/nyheter/lokalt/Kjemper-for-internatet-1788214.html',
245 'md5': '2acbe8ad129b3469d5ae51b1158878df',
249 'title': 'Alrekstad internat',
250 'description': 'md5:dc81a9056c874fedb62fc48a300dac58',
251 'thumbnail': r
're:^https?://.*\.jpg',
253 'timestamp': 1289991323,
254 'upload_date': '20101117',
259 def _real_extract(self
, url
):
260 webpage
= self
._download
_webpage
(url
, self
._match
_id
(url
))
261 video_id
= self
._search
_regex
(
262 r
'<video[^>]+data-id="(\d+)"', webpage
, 'video id')
263 return self
.url_result('bttv:%s' % video_id
, 'VGTV')
266 class BTVestlendingenIE(InfoExtractor
):
267 IE_NAME
= 'bt:vestlendingen'
268 IE_DESC
= 'Bergens Tidende - Vestlendingen'
269 _VALID_URL
= r
'https?://(?:www\.)?bt\.no/spesial/vestlendingen/#!/(?P<id>\d+)'
271 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86588',
272 'md5': 'd7d17e3337dc80de6d3a540aefbe441b',
276 'title': 'Otto Wollertsen',
277 'description': 'Vestlendingen Otto Fredrik Wollertsen',
278 'timestamp': 1430473209,
279 'upload_date': '20150501',
283 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86255',
284 'md5': 'a2893f8632e96389f4bdf36aa9463ceb',
288 'title': 'Du må tåle å fryse og være sulten',
289 'description': 'md5:b8046f4d022d5830ddab04865791d063',
290 'upload_date': '20150321',
291 'timestamp': 1426942023,
295 def _real_extract(self
, url
):
296 return self
.url_result('bttv:%s' % self
._match
_id
(url
), 'VGTV')