aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/yt_dlp_plugins
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2023-07-15 16:28:31 +0100
committergarret <garret@airmail.cc>2023-07-15 16:28:31 +0100
commita6a5befebafced40da8dd0582a6c486b56184b22 (patch)
tree1cce793b97d5e136cd14db93df4c31c5a29acd3c /yt_dlp_plugins
parent11d5c4a98fadc9f7be8c8f5535de9419ea425a21 (diff)
downloadyt-dlp-rajiko-a6a5befebafced40da8dd0582a6c486b56184b22.tar.gz
yt-dlp-rajiko-a6a5befebafced40da8dd0582a6c486b56184b22.tar.bz2
yt-dlp-rajiko-a6a5befebafced40da8dd0582a6c486b56184b22.zip
handle multi-paged search results
fixes #13
Diffstat (limited to 'yt_dlp_plugins')
-rwxr-xr-xyt_dlp_plugins/extractor/radiko.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/yt_dlp_plugins/extractor/radiko.py b/yt_dlp_plugins/extractor/radiko.py
index 6929f8e..ebe3265 100755
--- a/yt_dlp_plugins/extractor/radiko.py
+++ b/yt_dlp_plugins/extractor/radiko.py
@@ -6,6 +6,7 @@ import urllib.parse
from yt_dlp.extractor.common import InfoExtractor
from yt_dlp.utils import (
+ OnDemandPagedList,
clean_html,
join_nonempty,
parse_qs,
@@ -853,6 +854,14 @@ class RadikoSearchIE(_RadikoBaseIE):
def _strip_date(self, date):
return date.replace(" ", "").replace("-", "").replace(":", "")
+ def _pagefunc(self, url, idx):
+ url = update_url_query(url, {"page_idx": idx})
+ data = self._download_json(url, None, note=f"Downloading page {idx+1}")
+
+ return [self.url_result("https://radiko.jp/#!/ts/{station}/{time}".format(
+ station = i.get("station_id"), time = self._strip_date(i.get("start_time"))))
+ for i in data.get("data")]
+
def _real_extract(self, url):
url = url.replace("/#!/", "/!/", 1)
# urllib.parse interprets the path as just one giant fragment because of the #, so we hack it away
@@ -862,9 +871,10 @@ class RadikoSearchIE(_RadikoBaseIE):
**queries,
"uid": secrets.token_hex(16),
"app_id": "pc",
+ "row_limit": 50, # higher row_limit = more results = less requests = more good
})
- data = self._download_json(search_url, None)
- results = [(i.get("station_id"), self._strip_date(i.get("start_time"))) for i in data.get("data")]
+
+ results = OnDemandPagedList(lambda idx: self._pagefunc(search_url, idx), 50)
key = traverse_obj(queries, ("key", 0))
day = traverse_obj(queries, ('start_day', 0)) or "all"
@@ -877,8 +887,7 @@ class RadikoSearchIE(_RadikoBaseIE):
"_type": "playlist",
"title": traverse_obj(queries, ("key", 0)),
"id": playlist_id,
- "entries": [self.url_result(f"https://radiko.jp/#!/ts/{station}/{time}", RadikoTimeFreeIE)
- for station, time in results]
+ "entries": results,
}
class RadikoShareIE(_RadikoBaseIE):