Compare commits

..

2 commits
dev ... stable

Author SHA1 Message Date
95d25195d2 Update README.md 2025-04-20 11:32:08 +02:00
f4060629f1 Update README.md 2025-03-31 22:02:08 +02:00
5 changed files with 130 additions and 192 deletions

View file

@ -11,7 +11,7 @@
- Create install scripts/guides (WIP)
- Migrate from Bash to a POSIX-compliant shell
- Add Cover, and other metadata to vorbis tag (Almost done)
- Lyrics download (Almost done)
- Lyrics download (WIP)
- Implement search & download for playlists, albums, and artists (WIP)
- Support downloading multiple search results
- Allow users to choose audio quality (currently defaults to LOSSLESS)

View file

@ -1,8 +1,8 @@
# Maintainer: Medvidek77 <medvidek77@tuta.io>
pkgname=tidler
pkgver=0.3.1
pkgrel=1
pkgver=0.3.0
pkgrel=3
pkgdesc="Tidal music downloader based on the hifi-tui API"
arch=('any')
url="https://git.medvidek77.tech/Medvidek77/tidler"

View file

@ -1,8 +1,8 @@
# Maintainer: Medvidek77 <medvidek77@tuta.io>
pkgname=tidler
pkgver=0.3.2-beta2
pkgrel=1
pkgver=0.3.0
pkgrel=3
pkgdesc="Tidal music downloader based on the hifi-tui API"
arch=('any')
url="https://git.medvidek77.tech/Medvidek77/tidler"

View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash
#!/bin/bash
. tidler.conf # Load ENVs from config file
version="0.3.2-beta2"
version="0.3.0"
if [ -n "$PROXY_URL" ]; then
@ -50,7 +50,6 @@ else
max_attempts="10" # Default value
fi
downloadTrack() {
if [ "$#" -ge 1 ]; then
echo "Downloading track with ID: $1"
@ -60,10 +59,14 @@ downloadTrack() {
read -r id
fi
if [ "$#" -ge 2 ]; then
album_dir="$2"
else
album_dir=""
fi
attempt_num=1
success=false
lrc_success=false
while [ $attempt_num -le $max_attempts ]; do
json_data=$(curl -# "$proxy_url/track/?id=$id&quality=$quality")
@ -84,32 +87,11 @@ downloadTrack() {
cover_data=$(curl -# "$proxy_url/cover/?id=$id")
cover_url=$(echo "$cover_data" | jq -r '.[]["1280"] // empty')
if [ -n "$cover_url" ]; then
date_data=$(echo "$json_data" | jq -r '.[0].streamStartDate // empty' )
date=$(expr substr "$date_data" 1 10)
year=$(expr substr "$date_data" 1 4)
if [ -n "$year" ]; then
track_number=$(echo "$json_data" | jq -r '.[0].trackNumber')
filename="$track_name.flac"
cover_name="tidler_temp_cover_$track_name.png"
cover_name="cover.png"
success=true
lyrics_data=$(curl -# "$proxy_url/lyrics/?id=$id")
if [ $? -eq 0 ]; then
timed_lyrics=$(echo "$lyrics_data" | jq -r '.[0].subtitles')
if [ -n "$timed_lyrics" ]; then
lrc_success=true
elif [ "$timed_lyrics" == "null" ]; then
echo "Lyrics not found"
fi
fi
fi
break
fi
fi
@ -118,52 +100,45 @@ downloadTrack() {
fi
fi
if [ "$success" = false ]; then
echo "Attempt $attempt_num failed. Retrying..."
((attempt_num++))
sleep "1.$(tr -cd 0-9 < /dev/urandom | head -c 5)"
sleep "1.$(tr -cd 0-9 </dev/urandom | head -c 5)"
fi
done
if [ "$success" = false ]; then
echo "Failed to download after $max_attempts attempts."
exit 1
fi
if [ -n "$DOWNLOADS_DIR" ]; then
download_dir="$DOWNLOADS_DIR"
else
echo "Using current path..."
download_dir="$(pwd)"
fi
final_path="$download_dir/$artist_name/$album_name"
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"
curl -# "$cover_url" -o "/tmp/$cover_name"
curl -# "$cover_url" -o "$final_path/$cover_name"
# Metadata
metaflac \
--set-tag="NAME=$track_name" \
--set-tag="ARTIST=$artist_name" \
--set-tag="ALBUM=$album_name" \
--set-tag="TRACKNUMBER=$track_number" \
${lrc_success:+--set-tag="LYRICS=$timed_lyrics"} \
--set-tag="DATE=$date" \
--set-tag="YEAR=$year" \
--import-picture-from="/tmp/$cover_name" \
--import-picture-from="$final_path/$cover_name" \
"$final_path/$filename"
rm "/tmp/$cover_name"
}
searchTrack() {
if [ "$#" -ge 1 ]; then
track_name="$1"
@ -182,27 +157,19 @@ searchTrack() {
if [ "${#tracks_list[@]}" -eq 1 ]; then
echo "No tracks found :("
exit 1
else
i=0
while [ "$i" -lt "${#tracks_list[@]}" ]; do
echo "$((i + 1))) ${tracks_list["$i"]}"
i=$(( i + 1 ))
done
read -a inp
echo "${inp[0]}"
i=0
while [ "$i" -lt "${#inp[@]}" ]; do
inp2=$(("${inp[i]}" - 1))
if [ "$inp2" -ge 0 ] && [ "$inp2" -lt "${#tracks_list[@]}" ]; then
track_id=$(echo "${tracks_list["$inp2"]}" | awk -F ' - ' '{print $1}')
fi
PS3="Please select a track: "
select t in "${tracks_list[@]}"; do
if [ -n "$t" ]; then
track_id=$(echo "$t" | awk -F ' - ' '{print $1}')
echo "You selected: $t"
downloadTrack "$track_id"
break
else
echo "Invalid selection. Please try again."
fi
i=$(( i + 1 ))
done
fi
}
@ -277,27 +244,18 @@ searchAlbum() {
((attempt_num++))
sleep "1.$(tr -cd 0-9 </dev/urandom | head -c 5)"
else
i=0
while [ "$i" -lt "${#albums_list[@]}" ]; do
echo "$((i + 1))) ${albums_list["$i"]}"
i=$(( i + 1 ))
done
read -a inp
echo "${inp[0]}"
i=0
while [ "$i" -lt "${#inp[@]}" ]; do
inp2=$(("${inp[i]}" - 1))
if [ "$inp2" -ge 0 ] && [ "$inp2" -lt "${#albums_list[@]}" ]; then
album_id=$(echo "${albums_list["$inp2"]}" | awk -F ': ' '{print $1}')
PS3="Please select an album: "
select t in "${albums_list[@]}"; do
if [ -n "$t" ]; then
album_id=$(echo "$t" | awk -F ': ' '{print $1}')
echo "You selected: $t"
downloadAlbum "$album_id"
success=true
break
else
echo "Invalid selection. Please try again."
fi
i=$(( i + 1 ))
done
success=true
if [ "$success" = true ]; then
break
fi
@ -310,13 +268,6 @@ searchAlbum() {
fi
}
#searchArtist() {
#}
#downloadArtist() {
#}
if [ "$1" = "search" ]; then
if [ "$#" -ge 2 ]; then
@ -326,14 +277,12 @@ if [ "$1" = "search" ]; then
else
searchTrack
fi
elif [ "$1" = "download" ]; then
if [ "$#" -ge 2 ]; then
downloadTrack "$2"
else
downloadTrack
fi
elif [ "$1" = "album" ]; then
if [ "$#" -ge 2 ]; then
shift
@ -342,7 +291,6 @@ elif [ "$1" = "album" ]; then
else
searchAlbum
fi
elif [ "$1" == "version" ]; then
echo "TiDLer $version by Medvidek77"
@ -370,17 +318,7 @@ else
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
if [ "$option" -eq 1 ]; then
downloadTrack
elif [ "$option" -eq 2 ]; then

View file

@ -12,4 +12,4 @@ QUALITY="LOSSLESS"
COVER_RESOLUTION="1280"
# If there is any problem with the API, Tidler will attempt to download the track again -> possible values are "1" to "100"
MAX_ATTEMPTS="15"
MAX_ATTEMPTS="10"