diff options
Diffstat (limited to 'yt_dlp_plugins/extractor')
-rw-r--r-- | yt_dlp_plugins/extractor/radiko.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/yt_dlp_plugins/extractor/radiko.py b/yt_dlp_plugins/extractor/radiko.py index 024d9a6..a9f53f5 100644 --- a/yt_dlp_plugins/extractor/radiko.py +++ b/yt_dlp_plugins/extractor/radiko.py @@ -681,3 +681,41 @@ class RadikoStationButtonIE(InfoExtractor): station = traverse_obj(queries, ("station_id", 0)) return self.url_result(f"https://radiko.jp/#!/live/{station}", RadikoLiveIE) + + +class RadikoPersonIE(InfoExtractor): + _VALID_URL = r"https?://(?:www\.)?radiko\.jp/persons/(?P<id>\d+)" + + def _real_extract(self, url): + person_id = self._match_id(url) + + now = rtime.RadikoTime.now(tz=rtime.JST) + + min_start = (now - datetime.timedelta(days=7)).broadcast_day_start() + # 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" + + person_api_url = update_url_query("https://api.radiko.jp/program/api/v1/programs", { + "person_id": person_id, + "start_at_gte": min_start.isoformat(), + "end_at_lt": now.isoformat(), + }) + person_api = self._download_json(person_api_url, person_id) + + def entries(): + for episode in person_api.get("data"): + + share_url = traverse_obj(episode, ("radiko_url", ("pc", "sp", "android", "ios", "app"), + {url_or_none}), get_all=False) + # they're all identical share links at the moment (5th aug 2024) but they might not be in the future + + # predictions: + # pc will probably stay the same + # don't know what sp is, possibly "SmartPhone"?, anyway seems reasonably generic + # android is easier for me to reverse-engineer than ios (no ithing) + # i assume "app" would be some internal tell-it-to-do-something link, not a regular web link + + yield self.url_result(share_url, ie=RadikoShareIE, video_title=episode.get("title")) + + return self.playlist_result(entries(), playlist_id=join_nonempty("person", person_id)) |