Replace musicbrainz with build in lidarr api

This commit is contained in:
Jasper Aelvoet 2023-08-16 14:05:15 +02:00 committed by GitHub
parent ae56411a0b
commit 93a9515337
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1391,16 +1391,16 @@ SearchProcess () {
if [ $notFoundYoutubeFallback == "true" ]; then if [ $notFoundYoutubeFallback == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Falling back to YouTube" log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Falling back to YouTube"
query_param="release:${lidarrAlbumTitle} AND artist:${lidarrArtistName}&fmt=json" lidarrAlbumData=$(curl -X GET "$arrUrl/api/v1/album/${checkLidarrAlbumId}" --header "X-Api-Key:"${arrApiKey} -H "Content-Type: application/json")
album_id=$(curl --get --data-urlencode "query=${query_param}" --data-urlencode "fmt=json" "https://musicbrainz.org/ws/2/release/" | jq -r '.releases[0].id')
album_data=$(curl --get "https://musicbrainz.org/ws/2/release/${album_id}?inc=recordings&fmt=json") lidarrAlbumId=$(jq -r '.releases[0].albumId' <<< "$lidarrAlbumData")
tracks=$(jq -r '.media[0].tracks' <<< "$album_data" ) tracks=$(curl -X GET "$arrUrl/api/v1/track?albumId=${lidarrAlbumId}" --header "X-Api-Key:"${arrApiKey} -H "Content-Type: application/json")
downloadedAlbumTitleClean="$(echo "$4" | sed -e "s%[^[:alpha:][:digit:]._' ]% %g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')" downloadedAlbumTitleClean="$(echo "$4" | sed -e "s%[^[:alpha:][:digit:]._' ]% %g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')"
downloadedAlbumFolder="$lidarrArtistNameSanitized-$downloadedAlbumTitleClean ($3)-${albumquality^^}-$1-$2" downloadedAlbumFolder="$lidarrArtistNameSanitized-$downloadedAlbumTitleClean ($3)-${albumquality^^}-$1-$2"
if [[ -z $album_id ]]; then if [[ -z $lidarrAlbumId ]]; then
echo "Album not found on MusicBrainz." echo "Album not found on Lidarr."
else else
if [ -d "/temp-yt-dl" ]; then if [ -d "/temp-yt-dl" ]; then
rm -rf "/temp-yt-dl" rm -rf "/temp-yt-dl"
@ -1408,13 +1408,18 @@ SearchProcess () {
mkdir -p /temp-yt-dl/ mkdir -p /temp-yt-dl/
chmod 777 -R /temp-yt-dl/ chmod 777 -R /temp-yt-dl/
chomd 777 -R "${audioPath}/incomplete/" chmod 777 -R "${audioPath}/incomplete/"
jq -c '.[]' <<< "$tracks" | while read track; do trackLength=$(echo $tracks | jq length)
track_title=$(jq -r '.title' <<< "$track") trackLength=$((trackLength-1))
track_id=$(jq -r '.id' <<< "$track") for i in `seq 0 $trackLength`
yt-dlp --audio-quality highest --audio-format aac -o "/temp-yt-dl/${track_id}" -x "ytsearch:${lidarrArtistName} - ${track_title} (Audio)" do
ffmpeg -i "/temp-yt-dl/${track_id}.m4a" -metadata title="${track_title}" -metadata artist="${lidarrArtistName}" -metadata album="${lidarrAlbumTitle}" "${audioPath}/incomplete/${track_id}.m4a" trackTitle=$(jq -r ".[$i].title" <<< "$tracks")
trackId=$(jq -r ".[$i].foreignTrackId" <<< "$tracks")
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: $trackTitle :: Downloading from YouTube"
yt-dlp -q --audio-quality highest --audio-format aac -o "/temp-yt-dl/${trackId}" -x "ytsearch:${lidarrArtistName} - ${trackTitle} (Audio)"
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: $trackTitle :: Adding metadata"
ffmpeg -hide_banner -loglevel error -i "/temp-yt-dl/${trackId}.m4a" -metadata title="${trackTitle}" -metadata artist="${lidarrArtistName}" -metadata album="${lidarrAlbumTitle}" "${audioPath}/incomplete/${trackId}.m4a"
done done
if [ -d "/temp-yt-dl" ]; then if [ -d "/temp-yt-dl" ]; then