add spotifydl.sh
This commit is contained in:
parent
445e2b5721
commit
cc496bce62
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
#depends on ffmpeg, youtube-dl, curl, jq
|
||||
spotifylist="12i9fRZF3DG4J5KfMIS675" # The Spotify playlist id
|
||||
spotifyauth="Bearer BQBcsUG3bGZmBnSK..." # spotify token .. get with firefox network view -> any request against api.spotify.com -> http header authentication
|
||||
spotifylimit="100"
|
||||
outdir="ytdl/" # outputdirectory
|
||||
|
||||
total=$(curl -s -H "authorization: $spotifyauth" "https://api.spotify.com/v1/playlists/$spotifylist/tracks?offset=0&limit=100&market=from_token" | jq '.total')
|
||||
off="0"
|
||||
while [ "$off" -lt "$total" ]; do
|
||||
echo "get data: $off"
|
||||
curl -s -H "authorization: $spotifyauth" "https://api.spotify.com/v1/playlists/$spotifylist/tracks?offset=$off&limit=$spotifylimit&market=from_token" | jq '.items | .[] | .track | (.artists | .[0] | .name) + " - " + (.name)' >> data
|
||||
off=$((off+spotifylimit))
|
||||
done
|
||||
|
||||
echo "loaded Songs:"
|
||||
wc -l data
|
||||
|
||||
|
||||
youtube-dl --default-search "ytsearch" -f 251 -a data -o "$outdir%(creator)s%(title)s.%(ext)s" --restrict-filenames -w -x --audio-format mp3 --embed-thumbnail --add-metadata --xattrs # | grep --color=never "youtube:search"
|
||||
#ytmdl --disable-file --quiet --ignore-errors --choice 1 --format mp3 --list data
|
||||
|
||||
#while read in; do
|
||||
# in=$(echo "$in" | sed 's/"//g')
|
||||
# artist=$(echo "$in" | sed 's/###.*//')
|
||||
# song=$(echo "$in" | sed 's/.*###//')
|
||||
# echo "Download $song by $artist"
|
||||
# ytmdl --disable-file --quiet --choice 1 -t --format mp3 --artist "$artist" "$song"
|
||||
#done < data
|
||||
|
||||
rm -i data
|
||||
|
Loading…
Reference in New Issue