1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-15 11:33:30 +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,
NRKSkoleIE,
NRKTVIE,
NRKTVDirekteIE,
)
from .ntvde import NTVDeIE
from .ntvru import NTVRuIE

View File

@ -48,6 +48,13 @@ class NRKBaseIE(InfoExtractor):
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')
if media_assets and isinstance(media_assets, list):
def video_id_and_title(idx):
@ -61,6 +68,13 @@ class NRKBaseIE(InfoExtractor):
if not formats:
continue
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)
duration = parse_duration(asset.get('duration'))
subtitles = {}
@ -72,7 +86,7 @@ class NRKBaseIE(InfoExtractor):
})
entries.append({
'id': asset.get('carrierId') or entry_id,
'title': entry_title,
'title': make_title(entry_title),
'duration': duration,
'subtitles': subtitles,
'formats': formats,
@ -87,7 +101,7 @@ class NRKBaseIE(InfoExtractor):
duration = parse_duration(data.get('duration'))
entries = [{
'id': video_id,
'title': title,
'title': make_title(title),
'duration': duration,
'formats': formats,
}]
@ -111,7 +125,6 @@ class NRKBaseIE(InfoExtractor):
message_type, message_type)),
expected=True)
conviva = data.get('convivaStatistics') or {}
series = conviva.get('seriesName') or data.get('seriesTitle')
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):
_VALID_URL = r'https?://(?:www\.)?nrk\.no/(?!video|skole)(?:[^/]+/)+(?P<id>[^/]+)'