This commit is contained in:
poka 2022-05-07 02:47:04 +02:00
commit b071f74a7f
5 changed files with 47 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
lib/*
.login.auth

3
.login.auth.template Normal file
View File

@ -0,0 +1,3 @@
sp_id=""
sp_password=""
sp_token=""

BIN
.spotify_appkey.key Executable file

Binary file not shown.

24
install.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
if [[ ! $(which python) ]]; then
if [[ ! $(which pyenv) ]]; then
echo "pyenv installation..."
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
echo "Restat terminal and relaunch this install script"
exit 0
fi
pyenv install 3.9.6
pyenv global 3.9.6
fi
sudo apt install lame build-essential libffi-dev
wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add - #add mopidy's libspotify repository
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/stretch.list #valid for Debian Stretch.
sudo apt update && sudo apt install libspotify12 libspotify-dev python-spotify #install libspotify from mopidy's repository
mkdir -p lib
cp .login.auth.template .login.auth
chmod 600 .login.auth
git clone https://github.com/lavolp3/spotify-ripper.git lib/spotify-ripper && cd lib/spotify-ripper && python setup.py install
pyenv rehash

18
spotify-dl.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
output="/mnt/e/Musique"
format="{artist} - {track_name}.{ext}"
[[ ! $1 ]] && echo "Please give a search" && exit 1
source .login.auth
track=$(echo "$@" | sed 's/ /%20/g ')
if [[ $(echo "$track" | grep "open.spotify.com") ]]; then
link="$track"
[[ $(echo "$link" | grep "open.spotify.com/album") ]] && format="{artist} - {album}/{track_name}.{ext}"
else
link=$(curl -sX "GET" "https://api.spotify.com/v1/search?q=$track&type=track" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $sp_token" | jq -r '.[].items[0].external_urls.spotify')
fi
SPOTIPY_CLIENT_ID="" SPOTIPY_CLIENT_SECRET="" SPOTIPY_REDIRECT_URI="" python lib/spotify_ripper/main.py -k .spotify_appkey.key -u "$sp_id" -p "$sp_password" $link -f "$output/$format"