From b92d101a8c88add0870b9ad8d51d7565c9c1596a Mon Sep 17 00:00:00 2001 From: poka Date: Sat, 7 May 2022 13:47:41 +0200 Subject: [PATCH] Edit lib location; Add .env file wirh sourcing --- .env.template | 2 ++ .gitignore | 1 + README.md | 1 + install.sh | 4 ++-- spotify-dl.sh | 6 ++---- 5 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 .env.template diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..1197e32 --- /dev/null +++ b/.env.template @@ -0,0 +1,2 @@ +output="$HOME" +format="{artist} - {track_name}.{ext}" diff --git a/.gitignore b/.gitignore index 8d61611..2dfc4e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ lib/* .login.auth +.env diff --git a/README.md b/README.md index e196cb6..72706b7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ This is not a youtube scrapper. This is a real Spotify music downloader, to mp3 320kb/s 44100 Hz, no DRM, with good tags. **You will need a premium account to Spotify and set your ids in `.login.auth` file.** +You should also edit `.env` file to configure your tracks output format and location. If you want to use keywords search, you will also need a developer token, set to the same file (TODO: bypass this token). You can get this token here: https://developer.spotify.com/console/get-search-item/, but this one expire after one hour... diff --git a/install.sh b/install.sh index b217114..4efde26 100755 --- a/install.sh +++ b/install.sh @@ -17,8 +17,8 @@ wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add - #add mopidy' 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 +[[ ! -f .login.auth ]] && cp .login.auth.template .login.auth && chmod 600 .login.auth +[[ ! -f .env ]] && cp .env.template .env git clone https://github.com/lavolp3/spotify-ripper.git lib/spotify-ripper && cd lib/spotify-ripper && python setup.py install pyenv rehash diff --git a/spotify-dl.sh b/spotify-dl.sh index 550b99b..f4b32dc 100755 --- a/spotify-dl.sh +++ b/spotify-dl.sh @@ -1,10 +1,8 @@ #!/bin/bash -output="/mnt/e/Musique" -format="{artist} - {track_name}.{ext}" - [[ ! $1 ]] && echo "Please give a search" && exit 1 source .login.auth +source .env track=$(echo "$@" | sed 's/ /%20/g ') @@ -15,4 +13,4 @@ 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" +SPOTIPY_CLIENT_ID="" SPOTIPY_CLIENT_SECRET="" SPOTIPY_REDIRECT_URI="" python lib/spotify_ripper/spotify_ripper/main.py -k .spotify_appkey.key -u "$sp_id" -p "$sp_password" $link -f "$output/$format"