From 032c7951143e6452aeda34863bb38fed7ad26d3e Mon Sep 17 00:00:00 2001 From: garret Date: Sun, 11 Aug 2024 11:29:02 +0100 Subject: fix RadikoSiteTime test (forgot) changed func in eb94441420845970d48fe7b4e30cc5eed78ac95a , forgot to change the test also --- yt_dlp_plugins/extractor/radiko_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yt_dlp_plugins/extractor/radiko_time.py') diff --git a/yt_dlp_plugins/extractor/radiko_time.py b/yt_dlp_plugins/extractor/radiko_time.py index 9e77008..4d51ce5 100755 --- a/yt_dlp_plugins/extractor/radiko_time.py +++ b/yt_dlp_plugins/extractor/radiko_time.py @@ -79,7 +79,7 @@ if __name__ == "__main__": # cursed (no seconds) - seems to do -1s assert RadikoSiteTime('202308240100').timestring() == "20230824005959" # broadcast day starts at 05:00, ends at 04:59 (29:59) - assert RadikoSiteTime('20230824030000').broadcast_day() == '20230823' + assert RadikoSiteTime('20230824030000').broadcast_day_string() == '20230823' assert RadikoSiteTime('20230824130000').broadcast_day_end() == datetime.datetime(2023, 8, 25, 5, 0, 0, tzinfo=JST) assert RadikoSiteTime('20230824030000').broadcast_day_end() == datetime.datetime(2023, 8, 24, 5, 0, 0, tzinfo=JST) # checking timezone -- cgit v1.2.3-70-g09d2 From e9655881313b9b7ca1e402a82f51bbeed8a81e04 Mon Sep 17 00:00:00 2001 From: garret Date: Tue, 17 Sep 2024 01:18:09 +0100 Subject: prepare for "timefree 30" https://prtimes.jp/main/html/rd/p/000000032.000007490.html "radiko to launch new service "Timefree 30" this autumn, allows listening to programmes from the past 30 days, no 3-hour time limit" probably can't spoof having the plan, that's fine it might work if you pass cookies of a timefree30 account though, so i'm adapting the time stuff to account for that the plan doesn't exist yet, and i don't know how i would go about detecting it yet, so i'm just hardcoding to False for now --- yt_dlp_plugins/extractor/radiko.py | 4 ++-- yt_dlp_plugins/extractor/radiko_time.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'yt_dlp_plugins/extractor/radiko_time.py') diff --git a/yt_dlp_plugins/extractor/radiko.py b/yt_dlp_plugins/extractor/radiko.py index caaa020..d12f203 100644 --- a/yt_dlp_plugins/extractor/radiko.py +++ b/yt_dlp_plugins/extractor/radiko.py @@ -493,7 +493,7 @@ class RadikoTimeFreeIE(_RadikoBaseIE): end = times[1] now = datetime.datetime.now(tz=rtime.JST) - if end.broadcast_day_end() < now - datetime.timedelta(days=7): + if end.expiry(False) < now: 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) @@ -701,7 +701,7 @@ class RadikoPersonIE(InfoExtractor): now = rtime.RadikoTime.now(tz=rtime.JST) - min_start = (now - datetime.timedelta(days=7)).broadcast_day_start() + min_start = rtime.earliest_available(False) # we set the earliest time as the earliest we can get, # so, the start of the broadcast day 1 week ago # that way we can get everything we can actually download, including stuff that aired at eg "26:00" diff --git a/yt_dlp_plugins/extractor/radiko_time.py b/yt_dlp_plugins/extractor/radiko_time.py index 4d51ce5..b383098 100755 --- a/yt_dlp_plugins/extractor/radiko_time.py +++ b/yt_dlp_plugins/extractor/radiko_time.py @@ -36,6 +36,17 @@ class RadikoTime(datetime.datetime): dt = datetime.datetime(date.year, date.month, date.day, 5, 0, 0, tzinfo=JST) return dt + def expiry(self, tf30): + available_days = 30 if tf30 else 7 + return self.broadcast_day_end() + datetime.timedelta(days=available_days) + # IF SOMETHING CHANGES HERE YOU NEED TO UPDATE ↓↓earliest_available↓↓ AS WELL! + + +def earliest_available(tf30): + available_days = 30 if tf30 else 7 + return (RadikoTime.now(tz=JST) - datetime.timedelta(days=available_days)).broadcast_day_start() + # IF SOMETHING CHANGES HERE YOU NEED TO UPDATE ↑↑expiry↑↑ AS WELL! + class RadikoSiteTime(RadikoTime): -- cgit v1.2.3-70-g09d2 From 8805fd0326aff58332c626107625e80a597b6e45 Mon Sep 17 00:00:00 2001 From: garret Date: Fri, 1 Nov 2024 09:10:15 +0000 Subject: more right-thinking way of handling timefree 30 still hardcoded to not work though --- yt_dlp_plugins/extractor/radiko.py | 12 ++++++++---- yt_dlp_plugins/extractor/radiko_time.py | 13 ++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'yt_dlp_plugins/extractor/radiko_time.py') diff --git a/yt_dlp_plugins/extractor/radiko.py b/yt_dlp_plugins/extractor/radiko.py index d12f203..6b8a4c3 100644 --- a/yt_dlp_plugins/extractor/radiko.py +++ b/yt_dlp_plugins/extractor/radiko.py @@ -492,9 +492,13 @@ class RadikoTimeFreeIE(_RadikoBaseIE): start = times[0] end = times[1] now = datetime.datetime.now(tz=rtime.JST) + expiry_free, expiry_tf30 = end.expiry() + have_tf30 = False - if end.expiry(False) < now: + if expiry_tf30 < now: self.raise_no_formats("Programme is no longer available.", video_id=meta["id"], expected=True) + elif not have_tf30 and expiry_free < now: + self.raise_login_required("Programme is only available with a Timefree 30 subscription") elif start > now: self.raise_no_formats("Programme has not aired yet.", video_id=meta["id"], expected=True) live_status = "is_upcoming" @@ -701,9 +705,9 @@ class RadikoPersonIE(InfoExtractor): now = rtime.RadikoTime.now(tz=rtime.JST) - min_start = rtime.earliest_available(False) - # we set the earliest time as the earliest we can get, - # so, the start of the broadcast day 1 week ago + min_start = now - datetime.timedelta(days=30).broadcast_day_start() + # we set the earliest time as the earliest we can get (or at least, that it's possible to get), + # so, the start of the broadcast day 30 days ago # that way we can get everything we can actually download, including stuff that aired at eg "26:00" person_api_url = update_url_query("https://api.radiko.jp/program/api/v1/programs", { diff --git a/yt_dlp_plugins/extractor/radiko_time.py b/yt_dlp_plugins/extractor/radiko_time.py index b383098..d2084aa 100755 --- a/yt_dlp_plugins/extractor/radiko_time.py +++ b/yt_dlp_plugins/extractor/radiko_time.py @@ -36,16 +36,11 @@ class RadikoTime(datetime.datetime): dt = datetime.datetime(date.year, date.month, date.day, 5, 0, 0, tzinfo=JST) return dt - def expiry(self, tf30): - available_days = 30 if tf30 else 7 - return self.broadcast_day_end() + datetime.timedelta(days=available_days) - # IF SOMETHING CHANGES HERE YOU NEED TO UPDATE ↓↓earliest_available↓↓ AS WELL! + def expiry(self): + free = self.broadcast_day_end() + datetime.timedelta(days=7) + tf30 = self.broadcast_day_end() + datetime.timedelta(days=30) - -def earliest_available(tf30): - available_days = 30 if tf30 else 7 - return (RadikoTime.now(tz=JST) - datetime.timedelta(days=available_days)).broadcast_day_start() - # IF SOMETHING CHANGES HERE YOU NEED TO UPDATE ↑↑expiry↑↑ AS WELL! + return free, tf30 class RadikoSiteTime(RadikoTime): -- cgit v1.2.3-70-g09d2