I do not consent to this website being processed by artificial intelligence systems.

yt-dlp-rajiko

improved radiko.jp extractor for yt-dlp

what is it

日本語訳もあります!

yt-dlp-rajiko is an extractor plugin for yt-dlp, an online media downloader. With it, you can download any Japanese commercial radio programme, or record any live station, from radiko.jp— no matter where in the world you are.

It works by impersonating the radiko mobile app, allowing it to completely bypass radiko's geo-blocks. This technique was originally developed by jackyzy823 in the rajiko browser extension.

Compared to yt-dlp's extractor, yt-dlp-rajiko extracts more better metadata for timefree programmes, including tracklists of songs played during the programme (as chapters). Only the station metadata is extracted for the live streams, not the programme that's airing at the time. (this is the good and right-thinking way of doing it.)

if it's so marvellous then why haven't you merged it back upstream

The main reason is that the extractor uses an API key obtained by reverse-engineering the radiko mobile app. As such, I've been advised that it would be risky to merge into yt-dlp proper.

Other than that, it would probably be reasonably straightforward. But if I can't include the mobile key, I can't bypass the geoblock, so I can't use it. Not very much point in that...

how do i install it

Requires yt-dlp 2023.06.22 or above.

If you installed yt-dlp with pip, you can install yt-dlp-rajiko with pip too:
pip3 install --extra-index-url https://427738.xyz/yt-dlp-rajiko/pip/ yt-dlp-rajiko
If you used pipx, use pipx runpip instead.

Otherwise, download yt_dlp_rajiko-1.0-py3-none-any.whl and place it in one of these locations:

Here are the SHA256 checksums for the latest release:

70b95f25a62b465f1fb26f0e6faef45236d55a0c12665ef4f754cd39832118cf  yt_dlp_rajiko-1.0-py3-none-any.whl
993e16a3423a43dbeaee59c6eb37086f4e801dcfe03042aa5c5c01b0085fdc4d  yt-dlp-rajiko-1.0.tar.gz

If you're using pip/pipx, these should be verified automatically when you install.

The source code is available from my personal git host, and github.

If you'd like to be notified of new releases, you can subscribe to this RSS feed:
https://427738.xyz/yt-dlp-rajiko/CHANGELOG.xml
If you'd like to see the changelogs of past releases, you can read that feed in your browser as well.

If you'd prefer to be notified by email, you can use an RSS to email service. I've tested Feedrabbit and found it to work, but other options are available. Alternatively, shoot me a message with your email address and I'll work something out.

how do i use it

simply:

# timefree download
yt-dlp 'https://radiko.jp/#!/ts/INT/20240308230000'
# live recording
yt-dlp 'https://radiko.jp/#!/live/CCL'
# live shorthand
yt-dlp 'https://radiko.jp/#FMT'

You can somewhat automate downloading programmes by using the search page.

# all programmes related to Toshiki Kadomatsu
yt-dlp 'https://radiko.jp/#!/search/live?key=角松敏生&filter=past&region_id=all'
# specific programme from Osaka
yt-dlp 'https://radiko.jp/#!/search/live?key=world%20jazz%20warehouse&filter=past&area_id=JP27'

Just copying from the browser URL bar should work with no changes.

If you can reliably get it in the search, you can somewhat-automate downloading it. If there's a programme that airs on multiple stations, the best way to filter down to the station you want is to use the search's 地域 (region) filter.

recommended settings

yt-dlp's default settings aren't ideal for yt-dlp-rajiko. These are the settings I use to make it better.

TL;DR: -N 30 --embed-metadata --embed-thumbnail -o "%(title)s %(timestamp+32400>%Y-%m-%d_%H%M)s [%(id)s].%(ext)s" (put that in an alias)
+ --download-archive "archive" --playlist-reverse --break-on-existing --break-per-input if using the search page

Metadata

radiko offers a lot of metadata about its shows, a fair amount of which yt-dlp-rajiko extracts. But yt-dlp's default settings don't expose anything except the title.

Add the argument --embed-metadata to your command. This will embed the show name, description, station name and airdate into the file, as tags that should be picked up by a decent media player. It also embeds the tracklist of songs played as timestamped chapters.

You can also add --embed-thumbnail to add the show image as cover art, which your media player can display.

I use an output template to add the airdate into the filename as well:
-o "%(title)s %(timestamp+32400>%Y-%m-%d_%H%M)s [%(id)s].%(ext)s" -> World Jazz Warehouse 2024-05-19_2300 [CCL-20240519230000].m4a
+32400 is the JST time offset (+9h), since yt-dlp's timestamps are all UTC.

Sample mediainfo output

Efficiency

You should use -N (multi-threaded download) to increase download speed.

If you're using search queries, you should:

That way you can avoid scraping any more than necessary. (faster for you, less load on radiko, everyone wins)

putting it all together

It would be a pain to type/paste all those arguments onto the command every time. You can make an alias in your yt-dlp config, so you can just type one short thing and get all of the settings.

Make a config file in one of the supported locations, and add --alias rdk 'PASTE THE ARGUMENTS HERE' to it. Then when you want to download from radiko, do yt-dlp 'url' --rdk and it'll all "just work™". Unfortunately site-specific config isn't possible (yet?), so you will have to remember to add that --rdk every time.

If you're going to be using the search pages regularly, you should put your command into a shell/batch/etc script. That way you can just run it after the programme(s) you're interested in have aired, with no extra faff.

how do i get help

Open an issue on github or send a message via the form.
Please try to include a verbose log if you're reporting a problem.

misc notes/writings

You can find various notes/jottings on a dedicated page. These were formerly hosted on the github wiki.

acknowledgements

The mobile spoofing code is based heavily on the rajiko browser extension by jackyzy823, released under the Unlicense. In particular, the fake phone details and GPS coordinate generation code have been copied almost verbatim. And of course, the mobile API key was (to the best of my knowledge) originally obtained by jackyzy823. You can read their write-up (in Chinese) here.

The authentication code, and some parts of the metadata extraction, have been adapted from yt-dlp's radiko extractor, which was primarily authored by Lesmiscore (also released under the Unlicense).