Who doesn’t like to be cool on the internet and amongst other developer friends? Anyone? Everyone like to flex their skills. Isn’t it? It’s much more cool to listen 24x7 to Lofi on the terminal, whereas your friends may be stuck on ads every now and then. Besides looking cool, having a browser open for streaming music isn’t a good deal. Browsers are way too bloates especially if you’re low on resources.
Hacking the stream URL
Before actually streaming CodeRadio from the terminal you need to have the stream URLs, which can be easily fetched if you know the correct place to look for. I started by downloading the raw HTML for the website using
Upon investigating the XML, I found out that the site was most probably a React application. I quickly got the link to the main JS file loaded in by the HTML.
Besides formatting the code with
clang-format a part of it was still obfuscated, which was strange. I didn’t use something like Prettier as it would most probably have got Out Of Memory Killed by the kernel, and also Node.js is too slow in comparision to native. Running
clang-format worked magically somehow
Now I just had to somehow try to conmect to the websocket. Fortunately for me, I was able to fetch the API with just HTTP(S), probably because initially websockets are initialed with http requests only.
Here’s the raw JSON (stripped version):
Now in order to stream from the terminal all you have to do is
Besides the main URL, the API also returns relay stream URLs, so you can use them in case you face high latency.
If it’s online, everything will once be available on the terminal.
Enjoy streaming music from your Terminal!