Added some experimental features: Album directory create, Config file, Choose files location

This commit is contained in:
Medvidek77 2025-03-05 23:24:30 +01:00
parent b1d1d61064
commit d5fe38b570
2 changed files with 35 additions and 9 deletions

View file

@ -1,5 +1,6 @@
#!/bin/bash
. tidler.conf
downloadTrack() {
if [ "$#" -ge 1 ]; then
@ -17,14 +18,28 @@ downloadTrack() {
url=$(echo "$json_data" | jq -r '.[-1].OriginalTrackUrl')
cover_data=$(curl -s "https://tidal.401658.xyz/cover/?id=$id")
cover_url=$(echo "$cover_data" | jq -r '.[0]["1280"]')
# lyrics_data=$(curl -s "https://tidal.401658.xyz/lyrics/?id=$id")
# lyrics=$(echo "$lyrics_data" | jq -r '.[0].lyrics')
filename="$track_name.flac"
curl "$url" -o "$filename"
curl "$cover_url" -o "cover.png"
if [ -n "$DOWNLOADS_DIR" ]; then
download_dir="$DOWNLOADS_DIR"
else
download_dir="$(pwd)"
fi
mkdir -p "$download_dir"
curl "$url" -o "$download_dir/$filename"
curl "$cover_url" -o "$download_dir/cover.png"
# Metadata
metaflac --set-tag="NAME=$track_name" --set-tag="ARTIST=$artist_name" --set-tag="ALBUM=$album_name" --import-picture-from="cover.png" "$filename"
rm cover.png
metaflac \
--set-tag="NAME=$track_name" \
--set-tag="ARTIST=$artist_name" \
--set-tag="ALBUM=$album_name" \
--import-picture-from="$download_dir/cover.png" \
"$download_dir/$filename"
rm "$download_dir/cover.png"
}
@ -65,21 +80,31 @@ searchTrack() {
downloadAlbum() {
id="$1"
if [ -n "$DOWNLOADS_DIR" ]; then
base_dir="$DOWNLOADS_DIR"
else
base_dir="$(pwd)"
fi
json_data=$(curl -s "https://tidal.401658.xyz/track/?id=$id&quality=LOSSLESS")
album_name=$(echo "$json_data" | jq -r '.[0].album.title')
artist_name=$(echo "$json_data" | jq -r '.[0].artist.name')
album_title="$artist_name - $album_name"
album_dir="$base_dir/$album_title"
mkdir -p "$album_dir"
album_tracks_ids=$(curl -s "https://tidal.401658.xyz/album/?id=$id" | jq -r '.[1].items[] | .item.id')
tracks_ids_list=()
while IFS= read -r list; do
tracks_ids_list+=("$list")
done <<< "$album_tracks_ids"
for i in "${tracks_ids_list[@]}"
for track_id in "${tracks_ids_list[@]}"
do
downloadTrack "$i"
downloadTrack "$track_id" "$album_dir"
done
}
searchAlbum() {
if [ "$#" -ge 1 ]; then
album_name="$1"

1
src/tidler.conf Normal file
View file

@ -0,0 +1 @@
# DOWNLOADS_DIR=path