1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-22 08:34:32 +01:00

[nrktv:direkte] Add support for live streams (#11488)

This commit is contained in:
Sergey M․ 2016-12-19 23:47:45 +07:00
parent 5aaf012a4e
commit c80db5d398
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D
2 changed files with 30 additions and 3 deletions

View File

@ -655,6 +655,7 @@ from .nrk import (
NRKPlaylistIE, NRKPlaylistIE,
NRKSkoleIE, NRKSkoleIE,
NRKTVIE, NRKTVIE,
NRKTVDirekteIE,
) )
from .ntvde import NTVDeIE from .ntvde import NTVDeIE
from .ntvru import NTVRuIE from .ntvru import NTVRuIE

View File

@ -48,6 +48,13 @@ class NRKBaseIE(InfoExtractor):
entries = [] entries = []
conviva = data.get('convivaStatistics') or {}
live = (data.get('mediaElementType') == 'Live' or
data.get('isLive') is True or conviva.get('isLive'))
def make_title(t):
return self._live_title(t) if live else t
media_assets = data.get('mediaAssets') media_assets = data.get('mediaAssets')
if media_assets and isinstance(media_assets, list): if media_assets and isinstance(media_assets, list):
def video_id_and_title(idx): def video_id_and_title(idx):
@ -61,6 +68,13 @@ class NRKBaseIE(InfoExtractor):
if not formats: if not formats:
continue continue
self._sort_formats(formats) self._sort_formats(formats)
# Some f4m streams may not work with hdcore in fragments' URLs
for f in formats:
extra_param = f.get('extra_param_to_segment_url')
if extra_param and 'hdcore' in extra_param:
del f['extra_param_to_segment_url']
entry_id, entry_title = video_id_and_title(num) entry_id, entry_title = video_id_and_title(num)
duration = parse_duration(asset.get('duration')) duration = parse_duration(asset.get('duration'))
subtitles = {} subtitles = {}
@ -72,7 +86,7 @@ class NRKBaseIE(InfoExtractor):
}) })
entries.append({ entries.append({
'id': asset.get('carrierId') or entry_id, 'id': asset.get('carrierId') or entry_id,
'title': entry_title, 'title': make_title(entry_title),
'duration': duration, 'duration': duration,
'subtitles': subtitles, 'subtitles': subtitles,
'formats': formats, 'formats': formats,
@ -87,7 +101,7 @@ class NRKBaseIE(InfoExtractor):
duration = parse_duration(data.get('duration')) duration = parse_duration(data.get('duration'))
entries = [{ entries = [{
'id': video_id, 'id': video_id,
'title': title, 'title': make_title(title),
'duration': duration, 'duration': duration,
'formats': formats, 'formats': formats,
}] }]
@ -111,7 +125,6 @@ class NRKBaseIE(InfoExtractor):
message_type, message_type)), message_type, message_type)),
expected=True) expected=True)
conviva = data.get('convivaStatistics') or {}
series = conviva.get('seriesName') or data.get('seriesTitle') series = conviva.get('seriesName') or data.get('seriesTitle')
episode = conviva.get('episodeName') or data.get('episodeNumberOrDate') episode = conviva.get('episodeName') or data.get('episodeNumberOrDate')
@ -260,6 +273,19 @@ class NRKTVIE(NRKBaseIE):
}] }]
class NRKTVDirekteIE(NRKTVIE):
IE_DESC = 'NRK TV Direkte and NRK Radio Direkte'
_VALID_URL = r'https?://(?:tv|radio)\.nrk\.no/direkte/(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://tv.nrk.no/direkte/nrk1',
'only_matching': True,
}, {
'url': 'https://radio.nrk.no/direkte/p1_oslo_akershus',
'only_matching': True,
}]
class NRKPlaylistIE(InfoExtractor): class NRKPlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?nrk\.no/(?!video|skole)(?:[^/]+/)+(?P<id>[^/]+)' _VALID_URL = r'https?://(?:www\.)?nrk\.no/(?!video|skole)(?:[^/]+/)+(?P<id>[^/]+)'