From 1f25017782f42dafcf1a7612fce8b28fe23ff76c Mon Sep 17 00:00:00 2001 From: garret Date: Tue, 15 Aug 2023 22:42:51 +0100 Subject: Add timefree availability check afaict nhk doesn't have timefree, and it says as much on the programme pages The download doesn't fail though, you just get a loop of elevator music and an apology that it's not available (lasting the duration of the programme) from tsDetail.js tsInNg = playable in the area tsOutNg = playable outside the area (maybe - just a guess really, but seems to line up) outside station area + playable in area + not playable outside = not available in your area outside station area + not playable in area + not playable outside area = not available on timefree inside station area + not playable in area = not available on timefree we'll always be in the station area, so we only have to check tsInNg included a message about NHK Radiru because so far i've only seen NHK programmes be unavailable one day i should make the programme_meta func return a dict or something instead of just adding stuff on the end ad infinitum closes #15 --- yt_dlp_plugins/extractor/radiko.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'yt_dlp_plugins') diff --git a/yt_dlp_plugins/extractor/radiko.py b/yt_dlp_plugins/extractor/radiko.py index 0078562..2dc7380 100755 --- a/yt_dlp_plugins/extractor/radiko.py +++ b/yt_dlp_plugins/extractor/radiko.py @@ -8,6 +8,7 @@ from yt_dlp.extractor.common import InfoExtractor from yt_dlp.utils import ( OnDemandPagedList, clean_html, + int_or_none, join_nonempty, parse_qs, traverse_obj, @@ -762,7 +763,7 @@ class RadikoTimeFreeIE(_RadikoBaseIE): "series": "season_name", "tags": "tag", } - )}, (prog.get("ft"), prog.get("to")) + )}, (prog.get("ft"), prog.get("to")), int_or_none(prog.get("ts_in_ng")) != 2 def _extract_chapters(self, station, start, end, video_id=None): start_str = urllib.parse.quote(start.isoformat()) @@ -782,13 +783,18 @@ class RadikoTimeFreeIE(_RadikoBaseIE): def _real_extract(self, url): station, start_time = self._match_valid_url(url).group("station", "id") - meta, times = self._get_programme_meta(station, start_time) + meta, times, available = self._get_programme_meta(station, start_time) noformats_expected = False noformats_msg = "No video formats found!" noformats_force = False live_status = "was_live" + if not available: + noformats_force = True + noformats_expected = True + noformats_msg = "This programme is not available. If this is an NHK station, you may wish to try NHK Radiru." + start_datetime = self._timestring_to_datetime(times[0]) end_datetime = self._timestring_to_datetime(times[1]) -- cgit v1.2.3-70-g09d2