Plugin cleanup and tweaks
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import itertools
|
||||
import random
|
||||
import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..compat import compat_str
|
||||
from ..compat import compat_HTTPError, compat_str
|
||||
from ..utils import (
|
||||
determine_ext,
|
||||
ExtractorError,
|
||||
determine_ext,
|
||||
int_or_none,
|
||||
parse_duration,
|
||||
parse_iso8601,
|
||||
str_or_none,
|
||||
try_get,
|
||||
urljoin,
|
||||
url_or_none,
|
||||
urljoin,
|
||||
)
|
||||
|
||||
|
||||
@@ -60,8 +58,7 @@ class NRKBaseIE(InfoExtractor):
|
||||
return self._download_json(
|
||||
urljoin('https://psapi.nrk.no/', path),
|
||||
video_id, note or 'Downloading %s JSON' % item,
|
||||
fatal=fatal, query=query,
|
||||
headers={'Accept-Encoding': 'gzip, deflate, br'})
|
||||
fatal=fatal, query=query)
|
||||
|
||||
|
||||
class NRKIE(NRKBaseIE):
|
||||
@@ -147,10 +144,14 @@ class NRKIE(NRKBaseIE):
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url).split('/')[-1]
|
||||
|
||||
path_templ = 'playback/%s/program/' + video_id
|
||||
|
||||
def call_playback_api(item, query=None):
|
||||
return self._call_api(path_templ % item, video_id, item, query=query)
|
||||
try:
|
||||
return self._call_api(f'playback/{item}/program/{video_id}', video_id, item, query=query)
|
||||
except ExtractorError as e:
|
||||
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400:
|
||||
return self._call_api(f'playback/{item}/{video_id}', video_id, item, query=query)
|
||||
raise
|
||||
|
||||
# known values for preferredCdn: akamai, iponly, minicdn and telenor
|
||||
manifest = call_playback_api('manifest', {'preferredCdn': 'akamai'})
|
||||
|
||||
@@ -179,7 +180,6 @@ class NRKIE(NRKBaseIE):
|
||||
'format_id': asset_format,
|
||||
'vcodec': 'none',
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
||||
data = call_playback_api('metadata')
|
||||
|
||||
@@ -242,6 +242,7 @@ class NRKIE(NRKBaseIE):
|
||||
'age_limit': age_limit,
|
||||
'formats': formats,
|
||||
'subtitles': subtitles,
|
||||
'timestamp': parse_iso8601(try_get(manifest, lambda x: x['availability']['onDemand']['from'], str))
|
||||
}
|
||||
|
||||
if is_series:
|
||||
@@ -733,7 +734,7 @@ class NRKTVSeriesIE(NRKTVSerieBaseIE):
|
||||
entries, series_id, titles.get('title'), titles.get('subtitle'))
|
||||
|
||||
|
||||
class NRKTVDirekteIE(NRKTVIE):
|
||||
class NRKTVDirekteIE(NRKTVIE): # XXX: Do not subclass from concrete IE
|
||||
IE_DESC = 'NRK TV Direkte and NRK Radio Direkte'
|
||||
_VALID_URL = r'https?://(?:tv|radio)\.nrk\.no/direkte/(?P<id>[^/?#&]+)'
|
||||
|
||||
@@ -792,7 +793,7 @@ class NRKPlaylistBaseIE(InfoExtractor):
|
||||
for video_id in re.findall(self._ITEM_RE, webpage)
|
||||
]
|
||||
|
||||
playlist_title = self. _extract_title(webpage)
|
||||
playlist_title = self._extract_title(webpage)
|
||||
playlist_description = self._extract_description(webpage)
|
||||
|
||||
return self.playlist_result(
|
||||
|
Reference in New Issue
Block a user