Fix single track download and fixed tidler.conf and edited text and added album search to interactive mode

This commit is contained in:
Medvidek77 2025-03-19 22:47:33 +01:00
parent f37362444e
commit 18b782a1f4
2 changed files with 28 additions and 5 deletions

View file

@ -51,7 +51,14 @@ downloadTrack() {
fi fi
json_data=$(curl -s "$proxy_url/track/?id=$id&quality=$quality") 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') track_name=$(echo "$json_data" | jq -r '.[0].title')
artist_name=$(echo "$json_data" | jq -r '.[0].artist.name') artist_name=$(echo "$json_data" | jq -r '.[0].artist.name')
album_name=$(echo "$json_data" | jq -r '.[0].album.title') album_name=$(echo "$json_data" | jq -r '.[0].album.title')
url=$(echo "$json_data" | jq -r '.[-1].OriginalTrackUrl') url=$(echo "$json_data" | jq -r '.[-1].OriginalTrackUrl')
@ -68,7 +75,11 @@ downloadTrack() {
download_dir="$(pwd)" download_dir="$(pwd)"
fi 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" mkdir -p "$final_path"
@ -181,7 +192,7 @@ searchAlbum() {
} }
echo "Welcome to TiDLer -> Tidal music downloader" && echo "" echo "Welcome to TiDLer!" && echo ""
if [ "$1" = "search" ]; then if [ "$1" = "search" ]; then
if [ "$#" -ge 2 ]; then if [ "$#" -ge 2 ]; then
@ -200,6 +211,10 @@ elif [ "$1" = "download" ]; then
elif [ "$1" = "album" ]; then elif [ "$1" = "album" ]; then
searchAlbum searchAlbum
elif [ "$1" = "help" ]; then elif [ "$1" = "help" ]; then
echo "<MODE>"
echo ""
echo "If a valid parameter is provided, the corresponding function executes. Otherwise, TiDLer enters INTERACTIVE mode!"
echo ""
echo "<COMMANDS>" echo "<COMMANDS>"
echo "" echo ""
echo "search {text}-optional -> search any song" echo "search {text}-optional -> search any song"
@ -210,11 +225,19 @@ elif [ "$1" = "help" ]; then
echo "" echo ""
echo "help -> print this message and exit" echo "help -> print this message and exit"
else 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 read option
if [ "$option" -eq 1 ]; then if [ "$option" -eq 1 ]; then
downloadTrack downloadTrack
elif [ "$option" -eq 2 ]; then elif [ "$option" -eq 2 ]; then
searchTrack searchTrack
elif [ "$option" -eq 3 ]; then
searchAlbum
fi fi
fi fi

View file

@ -1,5 +1,5 @@
# Default download directory # Default download directory
DOWNLOADS_DIR="~/Music" DOWNLOADS_DIR="/home/$USER/Music"
# hifi-tui API server URL -> https://github.com/sachinsenal0x64/Hifi-Tui # hifi-tui API server URL -> https://github.com/sachinsenal0x64/Hifi-Tui
# You can use "https://tidal.401658.xyz" with cache enabled # You can use "https://tidal.401658.xyz" with cache enabled