In a marathon program from Christmas to New Year’s eve NPO Radio 2 broadcasts the so called “Top 2000“. A list of the 2000 most popular songs of all time. Because I’m not able to listen all 2000 songs in one go, I like to have them on a USB drive in MP3 format, so that I’m able to listen for example in my car.
The shell script below downloads the full “Top 2000” of 2023 in MP3 format from the official website. 80 MP3 files, ~12GB in size.
Required tools: curl
jq
sed
grep
tac
cat
#!/bin/sh
set -e
year=2023
for i in $(seq 25 31); do
echo "Uitzendingen verzamelen voor $i-12-$year.."
curl -s https://www.nporadio2.nl/uitzendingen?date=$i-12-$year | grep __NEXT_DATA__ | sed -e 's/.*application\/json">//' -e 's/<\/script><script>//' | jq -r .props.pageProps.broadcasts[].url | sed -e 's/^/https:\/\/www.nporadio2.nl/' | tac >> pages
done
echo -n "MP3 links verzamelen "
for p in $(cat pages); do
echo -n "."
curl -s $p | grep __NEXT_DATA__ | sed -e 's/.*application\/json">//' -e 's/<\/script><script>//' | jq -r .props.pageProps.radioBroadcast.showAssets[].player.parameters[0].value >> mp3
done
echo ""
# optional: remove the 1st 4 items (00:00-02:00, 02:00-04:00, 04:00-06:00, 06:00-08:00)
#tail -n +5 mp3 | sponge mp3
for m in $(cat mp3); do
curl -OL $m
done
December 31, 2022: Script updated
December 31, 2023: Script updated