Just did it for experimentation. Not encouraging piracy.
The command to run would be:
sh 8tracks-dl.sh username/playlist-title
Cheers!
PS: you need youtube-dl and jq to make it work..
| #!/bin/bash | |
| # Curl the url, get 1-line that contains the mix id, keep only that, remove prefixes and suffixes, add the json url we need for getting the tracklist | |
| url=$(curl https://8tracks.com/$1 | grep embedUrl | awk {'print $3'} | sed -e 's#content="##g' -e 's#player_v3_universal/autoplay"##g' | sed 's/$/tracks_for_international.jsonh/') | |
| # Curl the url that contains tracklist | |
| tracks=$(curl $url) | |
| # Get number of tracks | |
| count=$(echo $tracks | jq '.tracks | length - 1') | |
| # For all tracks download each one | |
| for i in $(seq 0 $count) | |
| do | |
| # Get performer - title in order to search for it | |
| track=$(echo $tracks | jq '(.tracks['"$i"'].performer + " - " + .tracks['"$i"'].name)' | sed "s/\"/'/g") | |
| # Name of the track to save | |
| unquoted_track=$(echo $track | sed "s/'//g") | |
| # If track number less than 10, then make it 01, 02, .. | |
| if [ $i -lt 9 ] | |
| then | |
| number=$(echo "0$((i+1))") | |
| else | |
| number=$(echo $((i+1))) | |
| fi | |
| # Actually download the song by using best available audio (extension), only 1, without playlist, by using string search and output into our folder using correct track number-name.extension | |
| youtube-dl -q -f bestaudio --max-downloads 1 --no-playlist --default-search ${2:-ytsearch} -o "~/Music/8tracks/$1/$number-$unquoted_track.%(ext)s" "${track}" | |
| done |
Just did it for experimentation. Not encouraging piracy.
The command to run would be:
sh 8tracks-dl.sh username/playlist-title
Cheers!
PS: you need youtube-dl and jq to make it work..