From 15012800ad2049ca7ea3ea0a17fe5f7755d5c268 Mon Sep 17 00:00:00 2001 From: garret Date: Sun, 10 Sep 2023 10:53:18 +0100 Subject: check end of broadcast day, not end of air time The old behaviour assumed programmes were deleted precisely a week after their end time. This isn't actually the case though, as long as it's within a week of the _broadcast day_, the site will let you. This lead to the extractor bailing out (Programme is no longer available) when in fact the programme was still playable on the site. The fix uses the same logic as RadikoTime.broadcast_day to find the broadcast day (TODO: one func for both?), then sets the time to 05:00:00 the next day - i.e. the start of a new broadcast day. --- yt_dlp_plugins/extractor/radiko.py | 3 ++- yt_dlp_plugins/extractor/radiko_time.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/yt_dlp_plugins/extractor/radiko.py b/yt_dlp_plugins/extractor/radiko.py index 7498a91..d035cfd 100755 --- a/yt_dlp_plugins/extractor/radiko.py +++ b/yt_dlp_plugins/extractor/radiko.py @@ -783,10 +783,11 @@ class RadikoTimeFreeIE(_RadikoBaseIE): start = times[0] end = times[1] + end_day = end.broadcast_day_end() now = datetime.datetime.now(tz=rtime.JST) - if end < now - datetime.timedelta(days=7): + if end_day < now - datetime.timedelta(days=7): self.raise_no_formats("Programme is no longer available.", video_id=meta["id"], expected=True) elif start > now: self.raise_no_formats("Programme has not aired yet.", video_id=meta["id"], expected=True) diff --git a/yt_dlp_plugins/extractor/radiko_time.py b/yt_dlp_plugins/extractor/radiko_time.py index 441085e..be7f6cd 100644 --- a/yt_dlp_plugins/extractor/radiko_time.py +++ b/yt_dlp_plugins/extractor/radiko_time.py @@ -20,6 +20,14 @@ class RadikoTime(): dt -= datetime.timedelta(days=1) return dt.strftime("%Y%m%d") + def broadcast_day_end(self): + dt = self.datetime + if dt.hour < 5: + dt -= datetime.timedelta(days=1) + dt += datetime.timedelta(days=1) + dt.replace(hour=5, minute=0, second=0) + return dt + def timestamp(self): return self.datetime.timestamp() def isoformat(self): -- cgit v1.2.3-70-g09d2