From c03ea70461b9825e3172ba6f553808915333aeff Mon Sep 17 00:00:00 2001 From: Darshaka Pathirana Date: Wed, 28 Jul 2021 23:09:25 +0200 Subject: [PATCH] [orf:radiothek] Add support for ORF Radiothek URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ORF radio stations are also provided via https://radiothek.orf.at. When doing so, the URLs are different. Currently only OE1 and OE3 have been tested. The ORFRADIOTHEK extractor has been tested with: ❯ python -m unittest -v test/test_download.py -k ORFRADIOTHEK test_ORFRADIOTHEK (test.test_download.TestDownload): ... [orf:radiothek] 645522: Downloading JSON metadata [download] Downloading playlist: Pandemie, Fossilien, Mars [orf:radiothek] playlist Pandemie, Fossilien, Mars: Collected 1 video ids (downloading 1 of them) [download] Downloading video 1 of 1 [info] Writing video description metadata as JSON to: test_ORFRADIOTHEK_2021-07-23_1355_tl_51_7DaysFri25_1594313.info.json [debug] Invoking downloader on 'https://loopstream01.apa.at/?channel=oe1&id=2021-07-23_1355_tl_51_7DaysFri25_1594313.mp3' [download] Destination: test_ORFRADIOTHEK_2021-07-23_1355_tl_51_7DaysFri25_1594313.mp3 [download] 100% of 10.00KiB in 00:00 [download] Finished downloading playlist: Pandemie, Fossilien, Mars ok test_ORFRADIOTHEK_1 (test.test_download.TestDownload): ... [orf:radiothek] 3SDL: Downloading JSON metadata [download] Downloading playlist: Der Song deines Lebens [orf:radiothek] playlist Der Song deines Lebens: Collected 1 video ids (downloading 1 of them) [download] Downloading video 1 of 1 [info] Writing video description metadata as JSON to: test_ORFRADIOTHEK_1_2021-07-28_1200_tl_53_7DaysWed3_1610654.info.json [debug] Invoking downloader on 'https://loopstream01.apa.at/?channel=oe3&id=2021-07-28_1200_tl_53_7DaysWed3_1610654.mp3' [download] Destination: test_ORFRADIOTHEK_1_2021-07-28_1200_tl_53_7DaysWed3_1610654.mp3 [download] 100% of 10.00KiB in 00:00 [download] Finished downloading playlist: Der Song deines Lebens ok ---------------------------------------------------------------------- Ran 2 tests in 0.863s ❯ flake8 youtube_dl/extractor/orf.py But as the files are only available for 7 days, "only_matching" was set to true. While at it removed 'skip' in favour of it. Closes: #29394 --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/orf.py | 58 +++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 535080d0a..74a7861db 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -880,6 +880,7 @@ from .ooyala import ( from .ora import OraTVIE from .orf import ( ORFTVthekIE, + ORFRADIOTHEKIE, ORFFM4IE, ORFFM4StoryIE, ORFOE1IE, diff --git a/youtube_dl/extractor/orf.py b/youtube_dl/extractor/orf.py index 8d537d7ae..98b610917 100644 --- a/youtube_dl/extractor/orf.py +++ b/youtube_dl/extractor/orf.py @@ -186,6 +186,10 @@ class ORFRadioIE(InfoExtractor): mobj = re.match(self._VALID_URL, url) show_date = mobj.group('date') show_id = mobj.group('show') + station = mobj.group('station') + if self._API_STATION == 'radiothek': + self._API_STATION = station + self._LOOP_STATION = station data = self._download_json( 'http://audioapi.orf.at/%s/api/json/current/broadcast/%s/%s' @@ -241,7 +245,6 @@ class ORFFM4IE(ORFRadioIE): 'timestamp': 1483819257, 'upload_date': '20170107', }, - 'skip': 'Shows from ORF radios are only available for 7 days.', 'only_matching': True, } @@ -384,20 +387,57 @@ class ORFOE1IE(ORFRadioIE): _LOOP_STATION = 'oe1' _TEST = { - 'url': 'http://oe1.orf.at/player/20170108/456544', - 'md5': '34d8a6e67ea888293741c86a099b745b', + 'url': 'https://oe1.orf.at/player/20210723/645522', + 'md5': '237da997b084f2f5cf40043dda42e8e5', 'info_dict': { - 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141', + 'id': '2021-07-23_1355_tl_51_7DaysFri25_1594313', 'ext': 'mp3', - 'title': 'Morgenjournal', - 'duration': 609, - 'timestamp': 1483858796, - 'upload_date': '20170108', + 'title': 'Pandemie, Fossilien, Mars', + 'description': 'Kommunikationshürden in der Pandemie +++ Fossilien-App für Hobbysammler und Wissenschaft +++ Das Innere des Mars erkunden', + 'duration': 287, + 'timestamp': 1627041300, + 'upload_date': '20210723', }, - 'skip': 'Shows from ORF radios are only available for 7 days.' + 'only_matching': True, } +class ORFRADIOTHEKIE(ORFRadioIE): + IE_NAME = 'orf:radiothek' + IE_DESC = 'radiothek.orf.at' + _VALID_URL = r'https?://radiothek\.orf\.at/(?P\w+)/(?P[0-9]+)/(?P\w+)' + _API_STATION = 'radiothek' + _LOOP_STATION = 'radiothek' + + _TESTS = [{ + 'url': 'https://radiothek.orf.at/oe1/20210723/645522', + 'md5': '237da997b084f2f5cf40043dda42e8e5', + 'info_dict': { + 'id': '2021-07-23_1355_tl_51_7DaysFri25_1594313', + 'ext': 'mp3', + 'title': 'Pandemie, Fossilien, Mars', + 'description': 'Kommunikationshürden in der Pandemie +++ Fossilien-App für Hobbysammler und Wissenschaft +++ Das Innere des Mars erkunden', + 'duration': 287, + 'timestamp': 1627041300, + 'upload_date': '20210723', + }, + 'only_matching': True, + }, { + 'url': 'https://radiothek.orf.at/oe3/20210728/3SDL', + 'md5': 'c2deeb2ab910e443d36c6497ed7044d9', + 'info_dict': { + "id": "2021-07-28_1200_tl_53_7DaysWed3_1610654", + 'ext': 'mp3', + "title": "Der Song deines Lebens", + "description": None, + "duration": 3603, + "timestamp": 1627466402, + "upload_date": "20210728", + }, + 'only_matching': True, + }] + + class ORFIPTVIE(InfoExtractor): IE_NAME = 'orf:iptv' IE_DESC = 'iptv.ORF.at'