2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class VGTVIE(InfoExtractor):
14 IE_DESC = 'VGTV, BTTV, FTV, Aftenposten and Aftonbladet'
19 (?:bt|aftenbladet).no/tv|
33 'url': 'http://www.vgtv.no/#!/video/84196/hevnen-er-soet-episode-10-abu',
34 'md5': 'b8be7a234cebb840c0d512c78013e02f',
38 'title': 'Hevnen er søt: Episode 10 - Abu',
39 'description': 'md5:e25e4badb5f544b04341e14abdc72234',
40 'thumbnail': 're:^https?://.*\.jpg',
42 'timestamp': 1404626400,
43 'upload_date': '20140706',
49 'url': 'http://www.vgtv.no/#!/live/100764/opptak-vgtv-foelger-em-kvalifiseringen',
53 'title': 'OPPTAK: VGTV følger EM-kvalifiseringen',
54 'description': 'md5:3772d9c0dc2dff92a886b60039a7d4d3',
55 'thumbnail': 're:^https?://.*\.jpg',
57 'timestamp': 1410113864,
58 'upload_date': '20140907',
63 'skip_download': True,
65 'skip': 'Video is no longer available',
69 'url': 'http://www.vgtv.no/#!/live/113063/direkte-v75-fra-solvalla',
73 'title': 'V75 fra Solvalla 30.05.15',
74 'description': 'md5:b3743425765355855f88e096acc93231',
75 'thumbnail': 're:^https?://.*\.jpg',
77 'timestamp': 1432975582,
78 'upload_date': '20150530',
83 'skip_download': True,
87 'url': 'http://www.aftenposten.no/webtv/#!/video/21039/trailer-sweatshop-i-can-t-take-any-more',
88 'md5': '7fbc265a3ca4933a423c7a66aa879a67',
92 'title': 'TRAILER: «SWEATSHOP» - I can´t take any more',
93 'description': 'md5:21891f2b0dd7ec2f78d84a50e54f8238',
95 'timestamp': 1417002452,
96 'upload_date': '20141126',
101 'url': 'http://www.bt.no/tv/#!/video/100250/norling-dette-er-forskjellen-paa-1-divisjon-og-eliteserien',
102 'only_matching': True,
114 'aftenbladet.no/tv': {
122 'aftenposten.no/webtv': {
128 def _real_extract(self, url):
129 mobj = re.match(self._VALID_URL, url)
130 video_id = mobj.group('id')
131 host = mobj.group('host')
133 data = self._download_json(
134 'http://svp.vg.no/svp/api/v1/%s/assets/%s?appName=%s-website'
135 % (self._HOST_WEBSITES[host]['vendor'], video_id, self._HOST_WEBSITES[host]['appname']),
136 video_id, 'Downloading media JSON')
138 if data.get('status') == 'inactive':
139 raise ExtractorError(
140 'Video %s is no longer available' % video_id, expected=True)
142 streams = data['streamUrls']
143 stream_type = data.get('streamType')
147 hls_url = streams.get('hls')
149 m3u8_formats = self._extract_m3u8_formats(hls_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
151 formats.extend(m3u8_formats)
153 hds_url = streams.get('hds')
154 # wasLive hds are always 404
155 if hds_url and stream_type != 'wasLive':
156 f4m_formats = self._extract_f4m_formats(hds_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18', video_id, f4m_id='hds', fatal=False)
158 formats.extend(f4m_formats)
160 mp4_urls = streams.get('pseudostreaming') or []
161 mp4_url = streams.get('mp4')
163 mp4_urls.append(mp4_url)
164 for mp4_url in mp4_urls:
169 mobj = re.search('(\d+)_(\d+)_(\d+)', mp4_url)
171 vbr = int(mobj.group(3))
173 'width': int(mobj.group(1)),
174 'height': int(mobj.group(2)),
176 'format_id': 'mp4-%s' % vbr,
178 formats.append(format_info)
180 self._sort_formats(formats)
184 'title': self._live_title(data['title']) if stream_type == 'live' else data['title'],
185 'description': data['description'],
186 'thumbnail': data['images']['main'] + '?t[]=900x506q80',
187 'timestamp': data['published'],
188 'duration': float_or_none(data['duration'], 1000),
189 'view_count': data['displays'],
191 'is_live': True if stream_type == 'live' else False,
195 class BTArticleIE(InfoExtractor):
196 IE_NAME = 'bt:article'
197 IE_DESC = 'Bergens Tidende Articles'
198 _VALID_URL = 'http://(?:www\.)?bt\.no/(?:[^/]+/)+(?P<id>[^/]+)-\d+\.html'
200 'url': 'http://www.bt.no/nyheter/lokalt/Kjemper-for-internatet-1788214.html',
201 'md5': 'd055e8ee918ef2844745fcfd1a4175fb',
205 'title': 'Alrekstad internat',
206 'description': 'md5:dc81a9056c874fedb62fc48a300dac58',
207 'thumbnail': 're:^https?://.*\.jpg',
209 'timestamp': 1289991323,
210 'upload_date': '20101117',
215 def _real_extract(self, url):
216 webpage = self._download_webpage(url, self._match_id(url))
217 video_id = self._search_regex(
218 r'SVP\.Player\.load\(\s*(\d+)', webpage, 'video id')
219 return self.url_result('http://bt.no/tv/embed?id=%s' % video_id, 'VGTV')
222 class BTVestlendingenIE(InfoExtractor):
223 IE_NAME = 'bt:vestlendingen'
224 IE_DESC = 'Bergens Tidende - Vestlendingen'
225 _VALID_URL = 'http://(?:www\.)?bt\.no/spesial/vestlendingen/#!/(?P<id>\d+)'
227 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86588',
228 'md5': 'd7d17e3337dc80de6d3a540aefbe441b',
232 'title': 'Otto Wollertsen',
233 'description': 'Vestlendingen Otto Fredrik Wollertsen',
234 'timestamp': 1430473209,
235 'upload_date': '20150501',
239 def _real_extract(self, url):
240 return self.url_result('http://bt.no/tv/embed?id=%s' % self._match_id(url), 'VGTV')