Skip to content

Instantly share code, notes, and snippets.

@cvan
Last active October 4, 2023 19:17
Show Gist options
  • Save cvan/dc68dced3641a8e7784877ce4d9a92ba to your computer and use it in GitHub Desktop.
Save cvan/dc68dced3641a8e7784877ce4d9a92ba to your computer and use it in GitHub Desktop.
play radiooooo using a CLI on the command-line terminal

play radiooooo.com from the terminal

From the comfort of your desktop computer, would you like to play the lovely sounds of radiooooo.com without having to create an account, log in, and open your browser?

An awesome individual, @olshevskiy87, wrote a command-line interface (CLI) for radiooooo.com: goradiooooo

Paste this bash script in somewhere handy, such as ~/bin/rdio ($HOME/bin/rdio).

mkdir -p "$HOME/bin/";
echo 'export PATH="$PATH:$HOME/bin"' >> $HOME/.bashrc;

# source: https://stackoverflow.com/a/62517779
if grep -q -i microsoft /proc/version; then
  # on WSL: version contains the string "microsoft"
  alias copy="clip.exe"
  alias paste="powershell.exe Get-Clipboard"
elif grep -q -i cygwin $(uname -a); then
  # on CYGWIN: uname contains the string "cygwin"
  alias copy="/dev/clipboard"
  alias paste="cat /dev/clipboard"
elif [[ ! -r /proc/version ]]; then
  # on MAC: version is not readable at all
  alias copy="pbcopy"
  alias paste="pbpaste"
else
  # on "normal" linux
  alias copy="xclip -sel clip"
  alias paste="xclip -sel clip -o"
fi

copy this block below:

#!/bin/bash

printf '\nchecking latest version …\n%s\n\n' "https://github.com/olshevskiy87/goradiooooo/releases/latest"
latest_version="$(curl 'https://api.github.com/repos/olshevskiy87/goradiooooo/releases/latest' --silent | grep tag_name | cut -d ':' -f 2 | tr -d '"' | tr -d ',' | tr -d ' ')"
printf $'\nfound latest version …\t%s\n\n' "$latest_version"
printf $'\ninstalling version …\t%s\n\n' "$latest_version"

if ! command -v play &> /dev/null; then
 case $(uname -s) in
    Darwin)
      echo "Installing symlink from ~/bin/play -> afplay …"
      ln -s `which afplay` $HOME/bin/play
      ;;
  esac
fi

go install "github.com/olshevskiy87/goradiooooo@$latest_version"

# todo: catch URLs from stderr logs
# see example below…

audio_url='https://radiooooo-track.b-cdn.net/FRA/1970/479b2af0-14c4-4217-b70f-eb871d9af150.m4a?token=sMNNiq3juKwxBXGe_LCZMg&expires=1686206261';
audio_url_no_querystring="$(echo "$audio_url" | sed -e $'s#\?.*##g')"
audio_hash="$(md5 <<< audio_url_no_querystring)";

mkdir -p "$HOME/.rdio-tmp/";
audio_local_fn="$HOME/.rdio-tmp/$audio_hash.m4a";

curl 'https://radiooooo-track.b-cdn.net/FRA/1970/479b2af0-14c4-4217-b70f-eb871d9af150.m4a?token=sMNNiq3juKwxBXGe_LCZMg&expires=1686206261' -L > "$audio_local_fn" && \
  afplay "$audio_local_fn" || play "$audio_local_fn";

then using the paste command from above:

paste > "$HOME/bin/rdio";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment