aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/yt_dlp_plugins/extractor/radiko_podcast.py
diff options
context:
space:
mode:
authorgarret1317 <garret@airmail.cc>2025-09-19 00:48:09 +0100
committergarret1317 <garret@airmail.cc>2025-09-19 00:48:09 +0100
commitca5cf0703d7a3171c7c9e5b1a9c89a96e0b8d6e8 (patch)
tree8b5c40834a637374fa057a1fa8ec7e2ed065c604 /yt_dlp_plugins/extractor/radiko_podcast.py
parent25d4c20be556825a5b3e2b6a66c719ad2c5d8c1f (diff)
downloadyt-dlp-rajiko-ca5cf0703d7a3171c7c9e5b1a9c89a96e0b8d6e8.tar.gz
yt-dlp-rajiko-ca5cf0703d7a3171c7c9e5b1a9c89a96e0b8d6e8.tar.bz2
yt-dlp-rajiko-ca5cf0703d7a3171c7c9e5b1a9c89a96e0b8d6e8.zip
add podcast search IE
Diffstat (limited to 'yt_dlp_plugins/extractor/radiko_podcast.py')
-rw-r--r--yt_dlp_plugins/extractor/radiko_podcast.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/yt_dlp_plugins/extractor/radiko_podcast.py b/yt_dlp_plugins/extractor/radiko_podcast.py
index 21e3dfd..67d6475 100644
--- a/yt_dlp_plugins/extractor/radiko_podcast.py
+++ b/yt_dlp_plugins/extractor/radiko_podcast.py
@@ -1,12 +1,16 @@
from yt_dlp.extractor.common import InfoExtractor
from yt_dlp.utils import (
clean_html,
+ OnDemandPagedList,
+ parse_qs,
traverse_obj,
+ update_url_query,
url_or_none,
str_or_none,
)
import dataclasses
+import random
from yt_dlp_plugins.extractor.radiko_dependencies import protobug
if protobug:
@@ -123,3 +127,40 @@ class RadikoPodcastChannelIE(_RadikoPodcastBaseIE):
}),
"entries": entries(),
}
+
+
+class RadikoPodcastSearchIE(InfoExtractor):
+ _VALID_URL = r"https?://(?:www\.)?radiko\.jp/#!/search/podcast/(?:timeshift|live)\?"
+
+ def _pagefunc(self, url, idx):
+ url = update_url_query(url, {"pageIdx": idx})
+ data = self._download_json(url, None, note=f"Downloading page {idx+1}")
+
+ results = []
+ for channel in data.get("channels"):
+ results.append(
+ self.url_result(
+ channel.get("channelUrl"),
+ id=channel.get("id"),
+ ie=RadikoPodcastChannelIE,
+ )
+ )
+ return results
+
+
+ def _real_extract(self, url):
+ # hack away the # so urllib.parse will work (same as normal RadikoSearchIE)
+ url = url.replace("/#!/", "/!/", 1)
+ queries = parse_qs(url)
+
+ keywords = traverse_obj(queries, ("key", 0))
+ search_url = update_url_query("https://api.annex-cf.radiko.jp/v1/podcasts/channels/search_with_keywords_by_offset", {
+ "keywords": keywords,
+ "uid": "".join(random.choices("0123456789abcdef", k=32)),
+ "limit": 50, # result limit. the actual limit before the api errors is 5000, but that seems a bit rude so i'll leave as 50 like the radio one
+ })
+
+ return self.playlist_result(
+ OnDemandPagedList(lambda idx: self._pagefunc(search_url, idx), 50),
+ title=keywords,
+ )