From eb94441420845970d48fe7b4e30cc5eed78ac95a Mon Sep 17 00:00:00 2001 From: garret Date: Mon, 5 Aug 2024 08:10:43 +0100 Subject: change names of RadikoTime functions so that datetime is the "default" generally we should work in datetimes, the strings should be the "special" ones --- yt_dlp_plugins/extractor/radiko.py | 2 +- yt_dlp_plugins/extractor/radiko_time.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'yt_dlp_plugins') diff --git a/yt_dlp_plugins/extractor/radiko.py b/yt_dlp_plugins/extractor/radiko.py index b76387d..2ec36d9 100644 --- a/yt_dlp_plugins/extractor/radiko.py +++ b/yt_dlp_plugins/extractor/radiko.py @@ -436,7 +436,7 @@ class RadikoTimeFreeIE(_RadikoBaseIE): }] def _get_programme_meta(self, station_id, url_time): - day = url_time.broadcast_day() + day = url_time.broadcast_day_string() meta = self._download_json(f"https://radiko.jp/v4/program/station/date/{day}/{station_id}.json", station_id, note="Downloading programme data") programmes = traverse_obj(meta, ("stations", lambda _, v: v["station_id"] == station_id, diff --git a/yt_dlp_plugins/extractor/radiko_time.py b/yt_dlp_plugins/extractor/radiko_time.py index c6be6ed..9e77008 100755 --- a/yt_dlp_plugins/extractor/radiko_time.py +++ b/yt_dlp_plugins/extractor/radiko_time.py @@ -8,7 +8,7 @@ class RadikoTime(datetime.datetime): def timestring(self): return self.strftime("%Y%m%d%H%M%S") - def broadcast_day_date(self): + def broadcast_day(self): # timetable api counts 05:00 -> 28:59 (04:59 next day) as all the same day # like the 30-hour day, 06:00 -> 29:59 (05:59) # https://en.wikipedia.org/wiki/Date_and_time_notation_in_Japan#Time @@ -21,14 +21,18 @@ class RadikoTime(datetime.datetime): dt = dt.date() # dont care about hours/mins, we're working in days return dt - def broadcast_day(self): - dt = self.broadcast_day_date() + def broadcast_day_string(self): + dt = self.broadcast_day() return dt.strftime("%Y%m%d") def broadcast_day_end(self): - date = self.broadcast_day_date() + date = self.broadcast_day() date += datetime.timedelta(days=1) + dt = datetime.datetime(date.year, date.month, date.day, 5, 0, 0, tzinfo=JST) + return dt + def broadcast_day_start(self): + date = self.broadcast_day() dt = datetime.datetime(date.year, date.month, date.day, 5, 0, 0, tzinfo=JST) return dt -- cgit v1.2.3-70-g09d2