diff options
author | garret <garret@airmail.cc> | 2023-08-24 02:46:40 +0100 |
---|---|---|
committer | garret <garret@airmail.cc> | 2023-08-24 02:46:40 +0100 |
commit | eae5f58a14ebd84470a6c6e186c87458daa5e474 (patch) | |
tree | affcdf7ac2c6eb15cfe83e739362c4fa9e984e3f | |
parent | 1f25017782f42dafcf1a7612fce8b28fe23ff76c (diff) | |
download | yt-dlp-rajiko-eae5f58a14ebd84470a6c6e186c87458daa5e474.tar.gz yt-dlp-rajiko-eae5f58a14ebd84470a6c6e186c87458daa5e474.tar.bz2 yt-dlp-rajiko-eae5f58a14ebd84470a6c6e186c87458daa5e474.zip |
bail sooner when programme is unavailable
ie dont do the dumb noformats vars, just raise the message there and then
-rwxr-xr-x | yt_dlp_plugins/extractor/radiko.py | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/yt_dlp_plugins/extractor/radiko.py b/yt_dlp_plugins/extractor/radiko.py index 2dc7380..d652133 100755 --- a/yt_dlp_plugins/extractor/radiko.py +++ b/yt_dlp_plugins/extractor/radiko.py @@ -784,16 +784,11 @@ class RadikoTimeFreeIE(_RadikoBaseIE): def _real_extract(self, url): station, start_time = self._match_valid_url(url).group("station", "id") 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." + self.raise_no_formats("This programme is not available. If this is an NHK station, you may wish to try NHK Radiru.", + video_id=meta["id"], expected=True) start_datetime = self._timestring_to_datetime(times[0]) end_datetime = self._timestring_to_datetime(times[1]) @@ -801,17 +796,13 @@ class RadikoTimeFreeIE(_RadikoBaseIE): now = datetime.datetime.now(tz=self._JST) if end_datetime < now - datetime.timedelta(days=7): - noformats_expected = True - noformats_msg = "Programme is no longer available." + self.raise_no_formats("Programme is no longer available.", video_id=meta["id"], expected=True) elif start_datetime > now: - noformats_expected = True - noformats_msg = "Programme has not aired yet." + self.raise_no_formats("Programme has not aired yet.", video_id=meta["id"], expected=True) live_status = "is_upcoming" elif start_datetime <= now < end_datetime: live_status = "is_upcoming" - noformats_expected = True - noformats_msg = "Programme has not finished airing yet." - noformats_force = True + self.raise_no_formats("Programme has not finished airing yet.", video_id=meta["id"], expected=True) region = self._get_station_region(station) station_meta = self._get_station_meta(region, station) @@ -819,10 +810,6 @@ class RadikoTimeFreeIE(_RadikoBaseIE): auth_data = self._auth(region) formats = self._get_station_formats(station, True, auth_data, start_at=times[0], end_at=times[1]) - if len(formats) == 0 or noformats_force: - self.raise_no_formats(noformats_msg, video_id=meta["id"], expected=noformats_expected) - formats = [] - return { **station_meta, "alt_title": None, |