mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-23 12:40:11 +09:00
Compare commits
No commits in common. "6bf95b15ee311d673e63ed5bc98d0b74040f24f0" and "1b26bfd425eaf5f7e314a6ebc810d62e8608ce5a" have entirely different histories.
6bf95b15ee
...
1b26bfd425
@ -2,7 +2,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import random
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
@ -23,26 +22,13 @@ from ..utils import (
|
|||||||
|
|
||||||
|
|
||||||
class NRKBaseIE(InfoExtractor):
|
class NRKBaseIE(InfoExtractor):
|
||||||
_GEO_COUNTRIES = ['NO']
|
|
||||||
_CDN_REPL_REGEX = r'''(?x)://
|
|
||||||
(?:
|
|
||||||
nrkod\d{1,2}-httpcache0-47115-cacheod0\.dna\.ip-only\.net/47115-cacheod0|
|
|
||||||
nrk-od-no\.telenorcdn\.net|
|
|
||||||
minicdn-od\.nrk\.no/od/nrkhd-osl-rr\.netwerk\.no/no
|
|
||||||
)/'''
|
|
||||||
|
|
||||||
def _extract_nrk_formats(self, asset_url, video_id):
|
def _extract_nrk_formats(self, asset_url, video_id):
|
||||||
if re.match(r'https?://[^/]+\.akamaihd\.net/i/', asset_url):
|
if re.match(r'https?://[^/]+\.akamaihd\.net/i/', asset_url):
|
||||||
return self._extract_akamai_formats(
|
return self._extract_akamai_formats(
|
||||||
re.sub(r'(?:b=\d+-\d+|__a__=off)&?', '', asset_url), video_id)
|
re.sub(r'(?:b=\d+-\d+|__a__=off)&?', '', asset_url), video_id)
|
||||||
asset_url = re.sub(r'(?:bw_(?:low|high)=\d+|no_audio_only)&?', '', asset_url)
|
return self._extract_m3u8_formats(
|
||||||
formats = self._extract_m3u8_formats(
|
re.sub(r'(?:bw_(?:low|high)=\d+|no_audio_only)&?', '', asset_url),
|
||||||
asset_url, video_id, 'mp4', 'm3u8_native', fatal=False)
|
|
||||||
if not formats and re.search(self._CDN_REPL_REGEX, asset_url):
|
|
||||||
formats = self._extract_m3u8_formats(
|
|
||||||
re.sub(self._CDN_REPL_REGEX, '://nrk-od-%02d.akamaized.net/no/' % random.randint(0, 99), asset_url),
|
|
||||||
video_id, 'mp4', 'm3u8_native', fatal=False)
|
video_id, 'mp4', 'm3u8_native', fatal=False)
|
||||||
return formats
|
|
||||||
|
|
||||||
def _raise_error(self, data):
|
def _raise_error(self, data):
|
||||||
MESSAGES = {
|
MESSAGES = {
|
||||||
@ -121,11 +107,8 @@ class NRKIE(NRKBaseIE):
|
|||||||
|
|
||||||
def _extract_from_playback(self, video_id):
|
def _extract_from_playback(self, video_id):
|
||||||
path_templ = 'playback/%s/' + video_id
|
path_templ = 'playback/%s/' + video_id
|
||||||
|
call_playback_api = lambda x: self._call_api(path_templ % x, video_id, x)
|
||||||
def call_playback_api(item, query=None):
|
manifest = call_playback_api('manifest')
|
||||||
return self._call_api(path_templ % item, video_id, item, query=query)
|
|
||||||
# known values for preferredCdn: akamai, iponly, minicdn and telenor
|
|
||||||
manifest = call_playback_api('manifest', {'preferredCdn': 'akamai'})
|
|
||||||
|
|
||||||
if manifest.get('playability') == 'nonPlayable':
|
if manifest.get('playability') == 'nonPlayable':
|
||||||
self._raise_error(manifest['nonPlayable'])
|
self._raise_error(manifest['nonPlayable'])
|
||||||
@ -212,6 +195,7 @@ class NRKTVIE(NRKBaseIE):
|
|||||||
'series': '20 spørsmål',
|
'series': '20 spørsmål',
|
||||||
'episode': '23.05.2014',
|
'episode': '23.05.2014',
|
||||||
},
|
},
|
||||||
|
'skip': 'NoProgramRights',
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://tv.nrk.no/program/mdfp15000514',
|
'url': 'https://tv.nrk.no/program/mdfp15000514',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -230,15 +214,15 @@ class NRKTVIE(NRKBaseIE):
|
|||||||
# single playlist video
|
# single playlist video
|
||||||
'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015#del=2',
|
'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015#del=2',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'MSPO40010515AH',
|
'id': 'MSPO40010515-part2',
|
||||||
'ext': 'mp4',
|
'ext': 'flv',
|
||||||
'title': 'Sprint fri teknikk, kvinner og menn 06.01.2015',
|
'title': 'Tour de Ski: Sprint fri teknikk, kvinner og menn 06.01.2015 (del 2:2)',
|
||||||
'description': 'md5:c03aba1e917561eface5214020551b7a',
|
'description': 'md5:238b67b97a4ac7d7b4bf0edf8cc57d26',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
'expected_warnings': ['Failed to download m3u8 information'],
|
'expected_warnings': ['Video is geo restricted'],
|
||||||
'skip': 'particular part is not supported currently',
|
'skip': 'particular part is not supported currently',
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015',
|
'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015',
|
||||||
@ -248,7 +232,7 @@ class NRKTVIE(NRKBaseIE):
|
|||||||
'title': 'Sprint fri teknikk, kvinner og menn 06.01.2015',
|
'title': 'Sprint fri teknikk, kvinner og menn 06.01.2015',
|
||||||
'description': 'md5:c03aba1e917561eface5214020551b7a',
|
'description': 'md5:c03aba1e917561eface5214020551b7a',
|
||||||
},
|
},
|
||||||
'expected_warnings': ['Failed to download m3u8 information'],
|
'skip': 'Video is geo restricted',
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://tv.nrk.no/serie/anno/KMTE50001317/sesong-3/episode-13',
|
'url': 'https://tv.nrk.no/serie/anno/KMTE50001317/sesong-3/episode-13',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -328,7 +312,6 @@ class NRKTVIE(NRKBaseIE):
|
|||||||
asset_url = asset.get('url')
|
asset_url = asset.get('url')
|
||||||
if not asset_url or asset_url in urls:
|
if not asset_url or asset_url in urls:
|
||||||
continue
|
continue
|
||||||
urls.append(asset_url)
|
|
||||||
formats = self._extract_nrk_formats(asset_url, video_id)
|
formats = self._extract_nrk_formats(asset_url, video_id)
|
||||||
if not formats:
|
if not formats:
|
||||||
continue
|
continue
|
||||||
@ -697,8 +680,7 @@ class NRKTVSeriesIE(NRKTVSerieBaseIE):
|
|||||||
domain = 'radio' if site == 'radio.nrk' else 'tv'
|
domain = 'radio' if site == 'radio.nrk' else 'tv'
|
||||||
|
|
||||||
series = self._call_api(
|
series = self._call_api(
|
||||||
'%s/catalog/series/%s' % (domain, series_id),
|
'%s/catalog/series/%s' % (domain, series_id), series_id, 'serie')
|
||||||
series_id, 'serie', query={'embeddedInstalmentsPageSize': 50})
|
|
||||||
titles = try_get(series, [
|
titles = try_get(series, [
|
||||||
lambda x: x['titles'],
|
lambda x: x['titles'],
|
||||||
lambda x: x[x['type']]['titles'],
|
lambda x: x[x['type']]['titles'],
|
||||||
|
Loading…
Reference in New Issue
Block a user