garret1317 / yt-dlp-rajiko

improved radiko.jp extractor for yt-dlp
https://427738.xyz/yt-dlp-rajiko/
Other
23 stars 1 forks source link

(mobile) programme support #12

Closed garret1317 closed 4 months ago

garret1317 commented 11 months ago

mobile app and mobile web give programmes their own pages so you can see all available episodes easily, and be recommended other similar ones

extracting these would be very good indeed - won't have to use a convoluted search query to download weekly episodes (and other stuff that happens to match 🚎)

here's a show page on mobile web https://radiko.jp/mobile/r_seasons/10001894

note- you need a japanese ip/vpn (rajiko deliberately doesnt work), and to spoof your user agent to something mobile or just use curl :p

it appears to be next.js, so we can get most of the interesting stuff from the nice <script id="__NEXT_DATA__" type="application/json"> block at the end it will block you if youre outside japan, but fortunately thats only client side - so downloading the page will work whatever

looks like everything has new (actual) ids, not sure what to do about that while the desktop site's still non-renovated, could resolve to regular #!/ts/ urls by converting the air time and i guess start using those ids once desktop makes the switch

here's an app show page Screenshot_20230714-171610

that one only has currently available eps and recommendations

here's another (not all shown)

Screenshot_20230714-172103

has current eps and future, but no recs

if you follow the show, it lets you choose which station you want

e.g. whole jfn Screenshot_20230714-170206 just one station Screenshot_20230714-170227 partial jfn Screenshot_20230714-170331

^to deal with this, have an extractor arg: preferred stations a list of which station( id)s to try in descending order of preference so for eg. JFN shows you can prioritise the stations with best sound quality and the extractor picks the first one that's available if there is no arg, default the key/"home" station - mobile web js has it, so should be ok

that's not available on mobile web (yet?) though, so don't think i can implement it any time soon - app remains uncooperative with mitmproxy

(todo: compare the entire JFN, find ones with best sound quality) (note: don't know why my phone screenshots display so huge, or what to do about it)

garret1317 commented 11 months ago

some mobile web apis make sure to set Referer: https://radiko.jp/mobile or itll reject you

https://radiko.jp/_next/data/nLQsA4EHzwfgk-EvAu-Nj/mobile.json for front page

https://radiko.jp/_next/data/nLQsA4EHzwfgk-EvAu-Nj/mobile/events/8475499.json - "event" - single episode https://radiko.jp/_next/data/nLQsA4EHzwfgk-EvAu-Nj/mobile/search/events.json?q=%E8%A7%92%E6%9D%BE%E6%95%8F%E7%94%9F+my+blues+life - search with no query also gives results, though not sure what theyre supposed to be

https://radiko.jp/_next/data/nLQsA4EHzwfgk-EvAu-Nj/mobile/r_seasons/10012903.json?rSeasonId=10012903 for a programme

(oh look, it has an isSingleStation key, thats useful)

https://radiko.jp/_next/data/nLQsA4EHzwfgk-EvAu-Nj/mobile/r_seasons/10013635.json?rSeasonId=10013635 - another programme page, this one on multiple stations

annoyingly it doesnt say which other stations it's actually on though

nothing new for streams, https://radiko.jp/v3/station/stream/MobileWebTrial/TBS.xml the 3 mins limitation is just an end time value

garret1317 commented 11 months ago

the nLQsA4EHzwfgk-EvAu-Nj is hardcoded, i think

        5436: function(e, t, r) {
            var i = "undefined" != typeof window ? window : void 0 !== r.g ? r.g : "undefined" != typeof self ? self : {};
            i.SENTRY_RELEASE = {
                id: "nLQsA4EHzwfgk-EvAu-Nj"
            }, i.SENTRY_RELEASES = i.SENTRY_RELEASES || {}, i.SENTRY_RELEASES["annex-frontend@radiko"] = {
                id: "nLQsA4EHzwfgk-EvAu-Nj"
            }
        },

^ (from _app.js) implies its some kind of (sentry) analytics thing

garret1317 commented 4 months ago

mobile should probably be a different extractor/plugin tbh its a pain in the ass, so that plugin will probably not be made by me im afraid