diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index cbaa07391..bde66f660 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -395,6 +395,7 @@ from .nrk import ( NRKIE, NRKPlaylistIE, NRKTVIE, + NRKRadioIE, ) from .ntvde import NTVDeIE from .ntvru import NTVRuIE diff --git a/youtube_dl/extractor/nrk.py b/youtube_dl/extractor/nrk.py index 9e4581cf9..38a727ca7 100644 --- a/youtube_dl/extractor/nrk.py +++ b/youtube_dl/extractor/nrk.py @@ -288,3 +288,36 @@ class NRKTVIE(InfoExtractor): 'formats': formats, 'subtitles': subtitles, } + + +class NRKRadioIE(InfoExtractor): + _VALID_URL = r'(?Phttps?://radio\.nrk(?:super)?\.no/)(?:serie/[^/]+|program)/(?P[a-zA-Z]{4}\d{8})(?:/\d{2}-\d{2}-\d{4})?(?:#del=(?P\d+))?' + + _TEST = { + 'url': 'https://radio.nrk.no/serie/dagsnytt/NPUB21019315/12-07-2015', + 'md5': '988d14c27498759cf1b762aa5cea9e42', + 'info_dict': { + 'id': 'NPUB21019315', + 'ext': 'mp4a', + 'title': 'NRK Radio - Dagsnytt - 12.07.2015', + 'description': 'Nyhetssending', + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + + webpage = self._download_webpage(url, video_id) + + title = self._html_search_regex(r'(.*?)', webpage, 'title') + desc = self._html_search_meta('description', webpage, 'description') + + m3u8_url = re.search(r'data-hls-media="([^"]+)"', webpage) + formats = self._extract_m3u8_formats(m3u8_url.group(1), video_id, 'mp4a') + + return { + 'id': video_id, + 'title': title, + 'description': desc, + 'formats': formats, + }