diff options
author | garret <garret@airmail.cc> | 2023-10-13 12:25:59 +0100 |
---|---|---|
committer | garret <garret@airmail.cc> | 2023-10-13 12:26:09 +0100 |
commit | 94faf5b37624b228629d2487dcb3c14483562cd7 (patch) | |
tree | efa48d6066c7b0ab7a43b230a67dacd56450996a /yt_dlp_plugins/extractor | |
parent | 9e8da557fb292cad9c12f56e8f6af7b9fcb7de1e (diff) | |
download | yt-dlp-rajiko-94faf5b37624b228629d2487dcb3c14483562cd7.tar.gz yt-dlp-rajiko-94faf5b37624b228629d2487dcb3c14483562cd7.tar.bz2 yt-dlp-rajiko-94faf5b37624b228629d2487dcb3c14483562cd7.zip |
ShareTime: handle day out of range for month
the site will accept this so we have to as well
i should probably try and handle this in SiteTime
but cant be fucked right now
iirc the site just blanks out if the day is out of range
so the datetime exception matches the site's behaviour 👍
Diffstat (limited to 'yt_dlp_plugins/extractor')
-rwxr-xr-x | yt_dlp_plugins/extractor/radiko_time.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/yt_dlp_plugins/extractor/radiko_time.py b/yt_dlp_plugins/extractor/radiko_time.py index c67f644..981a966 100755 --- a/yt_dlp_plugins/extractor/radiko_time.py +++ b/yt_dlp_plugins/extractor/radiko_time.py @@ -113,11 +113,17 @@ class RadikoShareTime(RadikoTime): days_to_add = hour // 24 hour = hour % 24 - # XXX: doesnt handle day invalid for month (the site actually works with this) + days_to_add += max(0, day - 28) + day = min(day, 28) + + # site won't handle month out of range (eg 2023-13-05), thank fuck self.datetime = datetime.datetime(year, month, day, hour, minute, second, tzinfo = JST) self.datetime += datetime.timedelta(days=days_to_add) if __name__ == "__main__": - assert RadikoShareTime('20230630296200').timestring() == '20230701060200' - assert RadikoShareTime('20230630235960').timestring() == '20230701000000' + assert RadikoShareTime('20230630296200').timestring() == '20230701060200' # 30-hour + >59 minutes + assert RadikoShareTime('20230630235960').timestring() == '20230701000000' # month boundary + assert RadikoShareTime('20240229010000').timestring() == '20240229010000' # feb 29th in leap year + assert RadikoShareTime('20230229010000').timestring() == '20230301010000' # feb 29th in not-leap year + assert RadikoShareTime('20230823180000').timestring() == '20230823180000' # normal |