Update download.sh

pull/6/head
RandomNinjaAtk 2 years ago committed by GitHub
parent d649b73433
commit b383eb5a7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -189,6 +189,7 @@ SearchProcess () {
lidarrAlbumData="$(curl -s "$lidarrUrl/api/v1/album/$wantedAlbumId?apikey=${lidarrApiKey}")"
lidarrAlbumTitle=$(echo "$lidarrAlbumData" | jq -r ".title")
lidarrAlbumTitleClean=$(echo "$lidarrAlbumTitle" | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')
lidarrAlbumForeignAlbumId=$(echo "$lidarrAlbumData" | jq -r ".foreignAlbumId")
lidarrAlbumReleases=$(echo "$lidarrAlbumData" | jq -r ".releases")
#echo $lidarrAlbumData | jq -r
lidarrAlbumWordCount=$(echo $lidarrAlbumTitle | wc -w)
@ -230,7 +231,12 @@ SearchProcess () {
tidalArtistAlbumsData=$(cat "/config/cache/tidal/$tidalArtistId-albums.json" | jq -r ".items | sort_by(.numberOfTracks) | sort_by(.explicit) | reverse |.[]")
tidalArtistAlbumsIds=($(echo "${tidalArtistAlbumsData}" | jq -r "select(.explicit=="true") | .id"))
echo "$lidarrAlbumTitle"
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Already Imported, skipping..."
return
fi
if echo "${deezerArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then
for id in ${!deezerArtistAlbumsIds[@]}; do
processNumberTwo=$(( $id + 1 ))
@ -241,15 +247,22 @@ SearchProcess () {
downloadedAlbumTitle="$(echo ${deezerArtistAlbumData} | jq -r .title)"
downloadedReleaseDate="$(echo ${deezerArtistAlbumData} | jq -r .release_date)"
downloadedReleaseYear="${downloadedReleaseDate:0:4}"
echo "Deezer Explicit MATCH"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumTitleClean vs $deezerArtistAlbumTitleClean :: Explicit Deezer MATCH Found"
if [ -f /config/logs/downloaded/deezer/$deezerArtistAlbumId ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Downloaded, skipping..."
continue
fi
DownloadProcess "$deezerArtistAlbumId" "DEEZER" "$downloadedReleaseYear"
fi
done
else
echo "No Explicit Deezer Match Found"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Explicit Deezer Match Found"
fi
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Already Imported, skipping..."
return
fi
if echo "${tidalArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then
@ -265,15 +278,22 @@ SearchProcess () {
downloadedReleaseDate=$(echo $tidalArtistAlbumData | jq -r '.streamStartDate')
fi
downloadedReleaseYear="${downloadedReleaseDate:0:4}"
echo "Tidal Explicit MATCH"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumTitleClean vs $tidalArtistAlbumTitleClean :: Explicit Tidal Match Found"
if [ -f /config/logs/downloaded/tidal/$tidalArtistAlbumId ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Downloaded, skipping..."
continue
fi
DownloadProcess "$tidalArtistAlbumId" "TIDAL" "$downloadedReleaseYear"
fi
done
else
echo "No Explicit Tidal Match Found"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Explicit Tidal Match Found"
fi
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Already Imported, skipping..."
return
fi
deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="false") | .id"))
@ -289,15 +309,22 @@ SearchProcess () {
downloadedAlbumTitle="$(echo ${deezerArtistAlbumData} | jq -r .title)"
downloadedReleaseDate="$(echo ${deezerArtistAlbumData} | jq -r .release_date)"
downloadedReleaseYear="${downloadedReleaseDate:0:4}"
echo "CLEAN Deezer MATCH"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumTitleClean vs $deezerArtistAlbumTitleClean :: CLEAN Deezer MATCH Found"
if [ -f /config/logs/downloaded/deezer/$deezerArtistAlbumId ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Downloaded, skipping..."
continue
fi
DownloadProcess "$deezerArtistAlbumId" "DEEZER" "$downloadedReleaseYear"
fi
done
else
echo "No Clean Deezer Match Found"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Clean Deezer Match Found"
fi
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Already Imported, skipping..."
return
fi
tidalArtistAlbumsIds=($(echo "${tidalArtistAlbumsData}" | jq -r "select(.explicit=="false") | .id"))
@ -315,15 +342,16 @@ SearchProcess () {
downloadedReleaseDate=$(echo $tidalArtistAlbumData | jq -r '.streamStartDate')
fi
downloadedReleaseYear="${downloadedReleaseDate:0:4}"
echo "CLEAN Tidal MATCH"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumTitleClean vs $tidalArtistAlbumTitleClean :: CLEAN Tidal Match Found"
if [ -f /config/logs/downloaded/tidal/$tidalArtistAlbumId ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Downloaded, skipping..."
continue
fi
DownloadProcess "$tidalArtistAlbumId" "TIDAL" "$downloadedReleaseYear"
fi
done
else
echo "No Clean Tidal Match Found"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Clean Tidal Match Found"
fi
mkdir -p /config/logs/downloaded/notfound
touch /config/logs/downloaded/notfound/$wantedAlbumId
@ -387,14 +415,8 @@ ProcessWithBeets () {
matchedLidarrAlbumArtistName="$(echo "$matchedLidarrAlbumData" | jq -r ".artist.artistName")"
matchedLidarrAlbumArtistCleanName="$(echo "$matchedLidarrAlbumData" | jq -r ".artist.cleanName")"
lidarrAlbumData=$(curl -s --header "X-Api-Key:"${lidarrApiKey} --request GET "$lidarrUrl/api/v1/album/" | jq -r ".[]")
lidarrPercentOfTracks=$(echo "$lidarrAlbumData" | jq -r "select(.foreignAlbumId==\"$matchedTagsAlbumReleaseGroupId\") | .statistics.percentOfTracks")
if [ "$lidarrPercentOfTracks" = "null" ]; then
lidarrPercentOfTracks=0
fi
if [ $lidarrPercentOfTracks -gt 0 ]; then
log ":: ERROR :: Already Imported"
CheckLidarrBeforeImport "$matchedTagsAlbumReleaseGroupId"
if [ $alreadyImported = true ]; then
rm -rf "$1"
return
fi
@ -435,6 +457,21 @@ ProcessWithBeets () {
fi
}
CheckLidarrBeforeImport () {
alreadyImported=false
lidarrAlbumData=$(curl -s --header "X-Api-Key:"${lidarrApiKey} --request GET "$lidarrUrl/api/v1/album/" | jq -r ".[]")
lidarrPercentOfTracks=$(echo "$lidarrAlbumData" | jq -r "select(.foreignAlbumId==\"$1\") | .statistics.percentOfTracks")
if [ "$lidarrPercentOfTracks" = "null" ]; then
lidarrPercentOfTracks=0
fi
if [ $lidarrPercentOfTracks -gt 0 ]; then
log ":: ERROR :: Already Imported"
alreadyImported=true
return
fi
}
GetMissingCutOffList
SearchProcess

Loading…
Cancel
Save