2014-09-04 21:02:47 +02:00
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2015-12-10 22:18:42 +01:00
|
|
|
|
from .xstream import XstreamIE
|
2015-05-30 11:15:42 +02:00
|
|
|
|
from ..utils import (
|
|
|
|
|
ExtractorError,
|
|
|
|
|
float_or_none,
|
2016-08-14 11:25:14 +02:00
|
|
|
|
try_get,
|
2015-05-30 11:15:42 +02:00
|
|
|
|
)
|
2014-09-04 21:02:47 +02:00
|
|
|
|
|
|
|
|
|
|
2022-11-16 01:57:43 +01:00
|
|
|
|
class VGTVIE(XstreamIE): # XXX: Do not subclass from concrete IE
|
2015-10-30 10:20:38 +01:00
|
|
|
|
IE_DESC = 'VGTV, BTTV, FTV, Aftenposten and Aftonbladet'
|
2017-02-18 21:53:23 +01:00
|
|
|
|
_GEO_BYPASS = False
|
2015-12-09 10:50:11 +01:00
|
|
|
|
|
|
|
|
|
_HOST_TO_APPNAME = {
|
2022-07-21 14:23:41 +02:00
|
|
|
|
'tv.vg.no': 'vgtv',
|
2015-12-09 10:50:11 +01:00
|
|
|
|
'vgtv.no': 'vgtv',
|
|
|
|
|
'bt.no/tv': 'bttv',
|
|
|
|
|
'aftenbladet.no/tv': 'satv',
|
|
|
|
|
'fvn.no/fvntv': 'fvntv',
|
|
|
|
|
'aftenposten.no/webtv': 'aptv',
|
2016-03-05 17:51:46 +01:00
|
|
|
|
'ap.vgtv.no/webtv': 'aptv',
|
2021-03-24 23:32:37 +01:00
|
|
|
|
'tv.aftonbladet.se': 'abtv',
|
|
|
|
|
# obsolete URL schemas, kept in order to save one HTTP redirect
|
2016-09-29 19:15:09 +02:00
|
|
|
|
'tv.aftonbladet.se/abtv': 'abtv',
|
2018-06-18 18:08:35 +02:00
|
|
|
|
'www.aftonbladet.se/tv': 'abtv',
|
2015-12-09 10:50:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_APP_NAME_TO_VENDOR = {
|
|
|
|
|
'vgtv': 'vgtv',
|
|
|
|
|
'bttv': 'bt',
|
|
|
|
|
'satv': 'sa',
|
|
|
|
|
'fvntv': 'fvn',
|
|
|
|
|
'aptv': 'ap',
|
2016-09-29 19:15:09 +02:00
|
|
|
|
'abtv': 'ab',
|
2015-12-09 10:50:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 18:18:43 +02:00
|
|
|
|
_VALID_URL = r'''(?x)
|
2015-12-09 10:50:11 +01:00
|
|
|
|
(?:https?://(?:www\.)?
|
2015-10-30 10:20:38 +01:00
|
|
|
|
(?P<host>
|
2024-06-12 01:09:58 +02:00
|
|
|
|
{}
|
2015-05-08 18:18:43 +02:00
|
|
|
|
)
|
2016-03-05 17:51:46 +01:00
|
|
|
|
/?
|
2015-05-08 18:18:43 +02:00
|
|
|
|
(?:
|
2017-09-15 17:13:30 +02:00
|
|
|
|
(?:\#!/)?(?:video|live)/|
|
2016-09-29 19:15:09 +02:00
|
|
|
|
embed?.*id=|
|
2018-06-18 18:08:35 +02:00
|
|
|
|
a(?:rticles)?/
|
2015-12-09 10:50:11 +01:00
|
|
|
|
)|
|
|
|
|
|
(?P<appname>
|
2024-06-12 01:09:58 +02:00
|
|
|
|
{}
|
2015-12-09 10:50:11 +01:00
|
|
|
|
):)
|
2015-12-06 07:43:46 +01:00
|
|
|
|
(?P<id>\d+)
|
2024-06-12 01:09:58 +02:00
|
|
|
|
'''.format('|'.join(_HOST_TO_APPNAME.keys()), '|'.join(_APP_NAME_TO_VENDOR.keys()))
|
2015-12-09 10:50:11 +01:00
|
|
|
|
|
2014-09-08 16:26:42 +02:00
|
|
|
|
_TESTS = [
|
|
|
|
|
{
|
|
|
|
|
# streamType: vod
|
|
|
|
|
'url': 'http://www.vgtv.no/#!/video/84196/hevnen-er-soet-episode-10-abu',
|
|
|
|
|
'md5': 'b8be7a234cebb840c0d512c78013e02f',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '84196',
|
|
|
|
|
'ext': 'mp4',
|
2014-12-03 19:07:09 +01:00
|
|
|
|
'title': 'Hevnen er søt: Episode 10 - Abu',
|
2014-09-08 16:26:42 +02:00
|
|
|
|
'description': 'md5:e25e4badb5f544b04341e14abdc72234',
|
2017-01-02 13:08:07 +01:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg',
|
2014-09-08 16:26:42 +02:00
|
|
|
|
'duration': 648.000,
|
|
|
|
|
'timestamp': 1404626400,
|
2014-09-08 16:33:03 +02:00
|
|
|
|
'upload_date': '20140706',
|
|
|
|
|
'view_count': int,
|
2014-09-08 16:26:42 +02:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
# streamType: wasLive
|
|
|
|
|
'url': 'http://www.vgtv.no/#!/live/100764/opptak-vgtv-foelger-em-kvalifiseringen',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '100764',
|
2014-09-30 14:50:14 +02:00
|
|
|
|
'ext': 'flv',
|
2014-09-08 16:26:42 +02:00
|
|
|
|
'title': 'OPPTAK: VGTV følger EM-kvalifiseringen',
|
|
|
|
|
'description': 'md5:3772d9c0dc2dff92a886b60039a7d4d3',
|
2017-01-02 13:08:07 +01:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg',
|
2014-12-03 19:07:09 +01:00
|
|
|
|
'duration': 9103.0,
|
2014-09-08 16:26:42 +02:00
|
|
|
|
'timestamp': 1410113864,
|
2014-09-08 16:33:03 +02:00
|
|
|
|
'upload_date': '20140907',
|
|
|
|
|
'view_count': int,
|
2014-09-08 16:26:42 +02:00
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
# m3u8 download
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
},
|
2015-10-30 09:48:56 +01:00
|
|
|
|
'skip': 'Video is no longer available',
|
2014-09-08 16:26:42 +02:00
|
|
|
|
},
|
|
|
|
|
{
|
2015-10-30 09:48:56 +01:00
|
|
|
|
# streamType: wasLive
|
2015-05-30 12:12:07 +02:00
|
|
|
|
'url': 'http://www.vgtv.no/#!/live/113063/direkte-v75-fra-solvalla',
|
2014-09-08 16:26:42 +02:00
|
|
|
|
'info_dict': {
|
2015-05-30 12:12:07 +02:00
|
|
|
|
'id': '113063',
|
2016-01-30 20:31:03 +01:00
|
|
|
|
'ext': 'mp4',
|
2015-10-30 09:48:56 +01:00
|
|
|
|
'title': 'V75 fra Solvalla 30.05.15',
|
2015-05-30 12:12:07 +02:00
|
|
|
|
'description': 'md5:b3743425765355855f88e096acc93231',
|
2017-01-02 13:08:07 +01:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg',
|
2015-10-30 09:48:56 +01:00
|
|
|
|
'duration': 25966,
|
2015-05-30 12:12:07 +02:00
|
|
|
|
'timestamp': 1432975582,
|
|
|
|
|
'upload_date': '20150530',
|
2014-09-08 16:33:03 +02:00
|
|
|
|
'view_count': int,
|
2014-09-08 16:26:42 +02:00
|
|
|
|
},
|
2016-01-30 20:31:03 +01:00
|
|
|
|
'params': {
|
|
|
|
|
# m3u8 download
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
},
|
2015-12-06 07:43:46 +01:00
|
|
|
|
},
|
|
|
|
|
{
|
2015-10-30 09:48:56 +01:00
|
|
|
|
'url': 'http://www.aftenposten.no/webtv/#!/video/21039/trailer-sweatshop-i-can-t-take-any-more',
|
2015-12-22 15:54:51 +01:00
|
|
|
|
'md5': 'fd828cd29774a729bf4d4425fe192972',
|
2015-10-30 09:48:56 +01:00
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '21039',
|
2016-03-05 17:51:46 +01:00
|
|
|
|
'ext': 'mp4',
|
2015-10-30 09:48:56 +01:00
|
|
|
|
'title': 'TRAILER: «SWEATSHOP» - I can´t take any more',
|
|
|
|
|
'description': 'md5:21891f2b0dd7ec2f78d84a50e54f8238',
|
|
|
|
|
'duration': 66,
|
|
|
|
|
'timestamp': 1417002452,
|
|
|
|
|
'upload_date': '20141126',
|
|
|
|
|
'view_count': int,
|
2016-03-05 17:51:46 +01:00
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
# m3u8 download
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
},
|
2014-09-08 16:26:42 +02:00
|
|
|
|
},
|
2022-07-21 14:23:41 +02:00
|
|
|
|
{
|
|
|
|
|
'url': 'https://tv.vg.no/video/241779/politiets-ekstremkjoering',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
},
|
2015-05-08 18:03:03 +02:00
|
|
|
|
{
|
|
|
|
|
'url': 'http://www.bt.no/tv/#!/video/100250/norling-dette-er-forskjellen-paa-1-divisjon-og-eliteserien',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
},
|
2016-03-05 17:51:46 +01:00
|
|
|
|
{
|
|
|
|
|
'url': 'http://ap.vgtv.no/webtv#!/video/111084/de-nye-bysyklene-lettere-bedre-gir-stoerre-hjul-og-feste-til-mobil',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
},
|
2016-08-14 11:25:14 +02:00
|
|
|
|
{
|
|
|
|
|
# geoblocked
|
|
|
|
|
'url': 'http://www.vgtv.no/#!/video/127205/inside-the-mind-of-favela-funk',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
},
|
2021-03-24 23:32:37 +01:00
|
|
|
|
{
|
|
|
|
|
'url': 'https://tv.aftonbladet.se/video/36015/vulkanutbrott-i-rymden-nu-slapper-nasa-bilderna',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
},
|
2016-09-29 19:15:09 +02:00
|
|
|
|
{
|
|
|
|
|
'url': 'http://tv.aftonbladet.se/abtv/articles/36015',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
},
|
2018-06-18 18:08:35 +02:00
|
|
|
|
{
|
|
|
|
|
'url': 'https://www.aftonbladet.se/tv/a/36015',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
},
|
2016-09-29 19:15:09 +02:00
|
|
|
|
{
|
|
|
|
|
'url': 'abtv:140026',
|
|
|
|
|
'only_matching': True,
|
2017-09-15 17:13:30 +02:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'url': 'http://www.vgtv.no/video/84196/hevnen-er-soet-episode-10-abu',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
},
|
2014-09-08 16:26:42 +02:00
|
|
|
|
]
|
2014-09-04 21:02:47 +02:00
|
|
|
|
|
2014-09-08 16:26:42 +02:00
|
|
|
|
def _real_extract(self, url):
|
2021-08-19 03:41:24 +02:00
|
|
|
|
mobj = self._match_valid_url(url)
|
2015-05-08 18:03:03 +02:00
|
|
|
|
video_id = mobj.group('id')
|
|
|
|
|
host = mobj.group('host')
|
2015-12-09 10:50:11 +01:00
|
|
|
|
appname = self._HOST_TO_APPNAME[host] if host else mobj.group('appname')
|
|
|
|
|
vendor = self._APP_NAME_TO_VENDOR[appname]
|
2015-05-08 18:03:03 +02:00
|
|
|
|
|
2014-09-08 16:26:42 +02:00
|
|
|
|
data = self._download_json(
|
2024-06-12 01:09:58 +02:00
|
|
|
|
f'http://svp.vg.no/svp/api/v1/{vendor}/assets/{video_id}?appName={appname}-website',
|
2014-09-08 16:26:42 +02:00
|
|
|
|
video_id, 'Downloading media JSON')
|
2014-09-04 21:02:47 +02:00
|
|
|
|
|
2015-05-30 11:15:42 +02:00
|
|
|
|
if data.get('status') == 'inactive':
|
|
|
|
|
raise ExtractorError(
|
2024-06-12 01:09:58 +02:00
|
|
|
|
f'Video {video_id} is no longer available', expected=True)
|
2015-05-30 11:15:42 +02:00
|
|
|
|
|
2015-12-10 22:18:42 +01:00
|
|
|
|
info = {
|
|
|
|
|
'formats': [],
|
|
|
|
|
}
|
|
|
|
|
if len(video_id) == 5:
|
|
|
|
|
if appname == 'bttv':
|
|
|
|
|
info = self._extract_video_info('btno', video_id)
|
|
|
|
|
|
2014-09-08 16:26:42 +02:00
|
|
|
|
streams = data['streamUrls']
|
2015-05-30 12:12:07 +02:00
|
|
|
|
stream_type = data.get('streamType')
|
2018-06-18 18:15:38 +02:00
|
|
|
|
is_live = stream_type == 'live'
|
2014-09-08 16:26:42 +02:00
|
|
|
|
formats = []
|
2014-09-04 21:02:47 +02:00
|
|
|
|
|
2014-09-08 16:26:42 +02:00
|
|
|
|
hls_url = streams.get('hls')
|
|
|
|
|
if hls_url:
|
2015-12-28 19:58:24 +01:00
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
2022-03-02 18:29:01 +01:00
|
|
|
|
hls_url, video_id, 'mp4', live=is_live, m3u8_id='hls', fatal=False))
|
2014-09-04 21:02:47 +02:00
|
|
|
|
|
2014-09-08 16:26:42 +02:00
|
|
|
|
hds_url = streams.get('hds')
|
2015-12-27 17:44:55 +01:00
|
|
|
|
if hds_url:
|
|
|
|
|
hdcore_sign = 'hdcore=3.7.0'
|
2015-12-09 10:50:11 +01:00
|
|
|
|
f4m_formats = self._extract_f4m_formats(
|
2024-06-12 01:09:58 +02:00
|
|
|
|
hds_url + f'?{hdcore_sign}', video_id, f4m_id='hds', fatal=False)
|
2015-12-06 07:43:46 +01:00
|
|
|
|
if f4m_formats:
|
2015-12-27 17:44:55 +01:00
|
|
|
|
for entry in f4m_formats:
|
|
|
|
|
# URLs without the extra param induce an 404 error
|
|
|
|
|
entry.update({'extra_param_to_segment_url': hdcore_sign})
|
|
|
|
|
formats.append(entry)
|
2014-09-04 21:02:47 +02:00
|
|
|
|
|
2015-12-06 07:43:46 +01:00
|
|
|
|
mp4_urls = streams.get('pseudostreaming') or []
|
2014-09-08 16:26:42 +02:00
|
|
|
|
mp4_url = streams.get('mp4')
|
|
|
|
|
if mp4_url:
|
2015-12-06 07:43:46 +01:00
|
|
|
|
mp4_urls.append(mp4_url)
|
|
|
|
|
for mp4_url in mp4_urls:
|
|
|
|
|
format_info = {
|
|
|
|
|
'url': mp4_url,
|
|
|
|
|
}
|
2017-01-02 13:08:07 +01:00
|
|
|
|
mobj = re.search(r'(\d+)_(\d+)_(\d+)', mp4_url)
|
2015-12-06 07:43:46 +01:00
|
|
|
|
if mobj:
|
2015-12-22 15:54:51 +01:00
|
|
|
|
tbr = int(mobj.group(3))
|
2015-12-06 07:43:46 +01:00
|
|
|
|
format_info.update({
|
|
|
|
|
'width': int(mobj.group(1)),
|
|
|
|
|
'height': int(mobj.group(2)),
|
2015-12-22 15:54:51 +01:00
|
|
|
|
'tbr': tbr,
|
2024-06-12 01:09:58 +02:00
|
|
|
|
'format_id': f'mp4-{tbr}',
|
2014-09-08 16:26:42 +02:00
|
|
|
|
})
|
2015-12-06 07:43:46 +01:00
|
|
|
|
formats.append(format_info)
|
|
|
|
|
|
2015-12-10 22:18:42 +01:00
|
|
|
|
info['formats'].extend(formats)
|
2014-09-08 16:26:42 +02:00
|
|
|
|
|
2016-08-14 11:25:14 +02:00
|
|
|
|
if not info['formats']:
|
|
|
|
|
properties = try_get(
|
|
|
|
|
data, lambda x: x['streamConfiguration']['properties'], list)
|
|
|
|
|
if properties and 'geoblocked' in properties:
|
2017-02-18 21:53:23 +01:00
|
|
|
|
raise self.raise_geo_restricted(
|
|
|
|
|
countries=[host.rpartition('.')[-1].partition('/')[0].upper()])
|
2016-08-14 11:25:14 +02:00
|
|
|
|
|
2015-12-10 22:18:42 +01:00
|
|
|
|
info.update({
|
2014-09-08 16:26:42 +02:00
|
|
|
|
'id': video_id,
|
2021-12-15 17:00:46 +01:00
|
|
|
|
'title': data['title'],
|
2014-09-08 16:26:42 +02:00
|
|
|
|
'description': data['description'],
|
|
|
|
|
'thumbnail': data['images']['main'] + '?t[]=900x506q80',
|
|
|
|
|
'timestamp': data['published'],
|
|
|
|
|
'duration': float_or_none(data['duration'], 1000),
|
|
|
|
|
'view_count': data['displays'],
|
2018-06-18 18:15:38 +02:00
|
|
|
|
'is_live': is_live,
|
2015-12-10 22:18:42 +01:00
|
|
|
|
})
|
|
|
|
|
return info
|
2015-05-08 18:18:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BTArticleIE(InfoExtractor):
|
2015-05-08 18:59:50 +02:00
|
|
|
|
IE_NAME = 'bt:article'
|
|
|
|
|
IE_DESC = 'Bergens Tidende Articles'
|
2016-03-21 16:36:32 +01:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?bt\.no/(?:[^/]+/)+(?P<id>[^/]+)-\d+\.html'
|
2015-05-08 18:18:43 +02:00
|
|
|
|
_TEST = {
|
|
|
|
|
'url': 'http://www.bt.no/nyheter/lokalt/Kjemper-for-internatet-1788214.html',
|
2015-12-22 15:54:51 +01:00
|
|
|
|
'md5': '2acbe8ad129b3469d5ae51b1158878df',
|
2015-05-08 18:18:43 +02:00
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '23199',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Alrekstad internat',
|
|
|
|
|
'description': 'md5:dc81a9056c874fedb62fc48a300dac58',
|
2017-01-02 13:08:07 +01:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg',
|
2015-05-08 18:18:43 +02:00
|
|
|
|
'duration': 191,
|
|
|
|
|
'timestamp': 1289991323,
|
|
|
|
|
'upload_date': '20101117',
|
|
|
|
|
'view_count': int,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
webpage = self._download_webpage(url, self._match_id(url))
|
|
|
|
|
video_id = self._search_regex(
|
2015-12-22 15:54:51 +01:00
|
|
|
|
r'<video[^>]+data-id="(\d+)"', webpage, 'video id')
|
2024-06-12 01:09:58 +02:00
|
|
|
|
return self.url_result(f'bttv:{video_id}', 'VGTV')
|
2015-05-08 18:59:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BTVestlendingenIE(InfoExtractor):
|
|
|
|
|
IE_NAME = 'bt:vestlendingen'
|
|
|
|
|
IE_DESC = 'Bergens Tidende - Vestlendingen'
|
2016-03-21 16:36:32 +01:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?bt\.no/spesial/vestlendingen/#!/(?P<id>\d+)'
|
2015-12-22 15:54:51 +01:00
|
|
|
|
_TESTS = [{
|
2015-05-08 18:59:50 +02:00
|
|
|
|
'url': 'http://www.bt.no/spesial/vestlendingen/#!/86588',
|
|
|
|
|
'md5': 'd7d17e3337dc80de6d3a540aefbe441b',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '86588',
|
|
|
|
|
'ext': 'mov',
|
|
|
|
|
'title': 'Otto Wollertsen',
|
|
|
|
|
'description': 'Vestlendingen Otto Fredrik Wollertsen',
|
|
|
|
|
'timestamp': 1430473209,
|
|
|
|
|
'upload_date': '20150501',
|
|
|
|
|
},
|
2015-12-22 15:54:51 +01:00
|
|
|
|
'skip': '404 Error',
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.bt.no/spesial/vestlendingen/#!/86255',
|
|
|
|
|
'md5': 'a2893f8632e96389f4bdf36aa9463ceb',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '86255',
|
|
|
|
|
'ext': 'mov',
|
|
|
|
|
'title': 'Du må tåle å fryse og være sulten',
|
|
|
|
|
'description': 'md5:b8046f4d022d5830ddab04865791d063',
|
|
|
|
|
'upload_date': '20150321',
|
|
|
|
|
'timestamp': 1426942023,
|
|
|
|
|
},
|
|
|
|
|
}]
|
2015-05-08 18:59:50 +02:00
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2024-06-12 01:09:58 +02:00
|
|
|
|
return self.url_result(f'bttv:{self._match_id(url)}', 'VGTV')
|