diff --git a/src/tidler b/src/tidler index 1d9215f..b443cc7 100755 --- a/src/tidler +++ b/src/tidler @@ -51,7 +51,14 @@ downloadTrack() { fi json_data=$(curl -s "$proxy_url/track/?id=$id&quality=$quality") + + if [ "$?" -gt 0 ]; then + echo "Error" + exit 1 + fi + track_name=$(echo "$json_data" | jq -r '.[0].title') + artist_name=$(echo "$json_data" | jq -r '.[0].artist.name') album_name=$(echo "$json_data" | jq -r '.[0].album.title') url=$(echo "$json_data" | jq -r '.[-1].OriginalTrackUrl') @@ -68,8 +75,12 @@ downloadTrack() { download_dir="$(pwd)" fi - final_path="$download_dir/$album_dir" - + if [ -z "$album_dir" ]; then + final_path="$download_dir" + else + final_path="$download_dir/$album_dir" + fi + mkdir -p "$final_path" curl "$url" -o "$final_path/$filename" @@ -181,7 +192,7 @@ searchAlbum() { } -echo "Welcome to TiDLer -> Tidal music downloader" && echo "" +echo "Welcome to TiDLer!" && echo "" if [ "$1" = "search" ]; then if [ "$#" -ge 2 ]; then @@ -200,6 +211,10 @@ elif [ "$1" = "download" ]; then elif [ "$1" = "album" ]; then searchAlbum elif [ "$1" = "help" ]; then + echo "" + echo "" + echo "If a valid parameter is provided, the corresponding function executes. Otherwise, TiDLer enters INTERACTIVE mode!" + echo "" echo "" echo "" echo "search {text}-optional -> search any song" @@ -210,11 +225,19 @@ elif [ "$1" = "help" ]; then echo "" echo "help -> print this message and exit" else - echo "Choose 1 for download track or 2 for search track and download" + echo "### Choose function! (Enter number) ###" + echo "" + echo "1. Download single track with ID" + echo "" + echo "2. Search single track with text" + echo "" + echo "3. Search and download whole album with text" read option if [ "$option" -eq 1 ]; then downloadTrack elif [ "$option" -eq 2 ]; then searchTrack + elif [ "$option" -eq 3 ]; then + searchAlbum fi fi diff --git a/src/tidler.conf b/src/tidler.conf index d2ec9e0..4ec5d0d 100644 --- a/src/tidler.conf +++ b/src/tidler.conf @@ -1,5 +1,5 @@ # Default download directory -DOWNLOADS_DIR="~/Music" +DOWNLOADS_DIR="/home/$USER/Music" # hifi-tui API server URL -> https://github.com/sachinsenal0x64/Hifi-Tui # You can use "https://tidal.401658.xyz" with cache enabled