Update download.sh

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

@ -162,12 +162,12 @@ fi
GetMissingCutOffList () { GetMissingCutOffList () {
log "Downloading missing list..." log "Downloading missing list..."
missingAlbumIds=$(curl -s "$lidarrUrl/api/v1/wanted/missing?page=1&pagesize=1000000000&sortDir=desc&sortKey=releaseDate&apikey=${lidarrApiKey}" | jq -r '.records | .[] | .id') missingAlbumIds=$(curl -s "$lidarrUrl/api/v1/wanted/missing?page=1&pagesize=1000000000&sortKey=releaseDate&sortDirection=desc&apikey=${lidarrApiKey}" | jq -r '.records | .[] | .id')
missingAlbumIdsTotal=$(echo "$missingAlbumIds" | sed -r '/^\s*$/d' | wc -l) missingAlbumIdsTotal=$(echo "$missingAlbumIds" | sed -r '/^\s*$/d' | wc -l)
log "FINDING MISSING ALBUMS: ${missingAlbumIdsTotal} Found" log "FINDING MISSING ALBUMS: ${missingAlbumIdsTotal} Found"
log "Downloading cutoff list..." log "Downloading cutoff list..."
cutoffAlbumIds=$(curl -s "$lidarrUrl/api/v1/wanted/cutoff?page=1&pagesize=1000000000&sortDir=desc&sortKey=releaseDate&apikey=${lidarrApiKey}" | jq -r '.records | .[] | .id') cutoffAlbumIds=$(curl -s "$lidarrUrl/api/v1/wanted/cutoff?page=1&pagesize=1000000000&sortKey=releaseDate&sortDirection=desc&apikey=${lidarrApiKey}" | jq -r '.records | .[] | .id')
cutoffAlbumIdsTotal=$(echo "$cutoffAlbumIds" | sed -r '/^\s*$/d'| wc -l) cutoffAlbumIdsTotal=$(echo "$cutoffAlbumIds" | sed -r '/^\s*$/d'| wc -l)
log "FINDING CUTOFF ALBUMS: ${cutoffAlbumIdsTotal} Found" log "FINDING CUTOFF ALBUMS: ${cutoffAlbumIdsTotal} Found"
@ -202,19 +202,22 @@ SearchProcess () {
tidalArtistUrl=$(echo "${lidarrArtistData}" | jq -r ".links | .[] | select(.name==\"tidal\") | .url") tidalArtistUrl=$(echo "${lidarrArtistData}" | jq -r ".links | .[] | select(.name==\"tidal\") | .url")
tidalArtistId="$(echo "$tidalArtistUrl" | grep -o '[[:digit:]]*' | sort -u)" tidalArtistId="$(echo "$tidalArtistUrl" | grep -o '[[:digit:]]*' | sort -u)"
deezerArtistUrl=$(echo "${lidarrArtistData}" | jq -r ".links | .[] | select(.name==\"deezer\") | .url") deezerArtistUrl=$(echo "${lidarrArtistData}" | jq -r ".links | .[] | select(.name==\"deezer\") | .url")
deezeArtistId="$(echo "$deezerArtistUrl" | grep -o '[[:digit:]]*' | sort -u)" deezeArtistIds=($(echo "$deezerArtistUrl" | grep -o '[[:digit:]]*' | sort -u))
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Starting Search..." log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Starting Search..."
if [ -f /config/logs/downloaded/notfound/$wantedAlbumId ]; then if [ -f "/config/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId" ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Not Found, skipping..." log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Not Found, skipping..."
continue continue
fi fi
for dId in ${!deezeArtistIds[@]}; do
deezeArtistId="${deezeArtistIds[$dId]}"
if [ ! -d /config/cache/deezer ]; then if [ ! -d /config/cache/deezer ]; then
mkdir -p /config/cache/deezer mkdir -p /config/cache/deezer
fi fi
if [ ! -f /config/cache/deezer/$deezeArtistId-albums.json ]; then if [ ! -f /config/cache/deezer/$deezeArtistId-albums.json ]; then
curl -s "https://api.deezer.com/artist/$deezeArtistId/albums?limit=1000" > /config/cache/deezer/$deezeArtistId-albums.json curl -s "https://api.deezer.com/artist/$deezeArtistId/albums?limit=1000" > /config/cache/deezer/$deezeArtistId-albums.json
fi fi
done
if [ ! -d /config/cache/tidal ]; then if [ ! -d /config/cache/tidal ]; then
mkdir -p /config/cache/tidal mkdir -p /config/cache/tidal
fi fi
@ -224,12 +227,15 @@ SearchProcess () {
if [ ! -f /config/cache/tidal/$tidalArtistId-albums.json ]; then if [ ! -f /config/cache/tidal/$tidalArtistId-albums.json ]; then
curl -s "https://api.tidal.com/v1/artists/${tidalArtistId}/albums?limit=10000&countryCode=$CountryCode&filter=ALL" -H 'x-tidal-token: CzET4vdadNUFQ5JU' > /config/cache/tidal/$tidalArtistId-albums.json curl -s "https://api.tidal.com/v1/artists/${tidalArtistId}/albums?limit=10000&countryCode=$CountryCode&filter=ALL" -H 'x-tidal-token: CzET4vdadNUFQ5JU' > /config/cache/tidal/$tidalArtistId-albums.json
fi fi
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"))
for dId in ${!deezeArtistIds[@]}; do
deezeArtistId="${deezeArtistIds[$dId]}"
deezerArtistAlbumsData=$(cat "/config/cache/deezer/$deezeArtistId-albums.json" | jq -r ".data | sort_by(.release_date) | sort_by(.explicit_lyrics) | reverse | .[]") deezerArtistAlbumsData=$(cat "/config/cache/deezer/$deezeArtistId-albums.json" | jq -r ".data | sort_by(.release_date) | sort_by(.explicit_lyrics) | reverse | .[]")
deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="true") | .id")) deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="true") | .id"))
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")) done
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then if [ $alreadyImported = true ]; then
@ -237,6 +243,11 @@ SearchProcess () {
return return
fi fi
for dId in ${!deezeArtistIds[@]}; do
deezeArtistId="${deezeArtistIds[$dId]}"
deezerArtistAlbumsData=$(cat "/config/cache/deezer/$deezeArtistId-albums.json" | jq -r ".data | sort_by(.release_date) | sort_by(.explicit_lyrics) | reverse | .[]")
deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="true") | .id"))
if echo "${deezerArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then if echo "${deezerArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then
for id in ${!deezerArtistAlbumsIds[@]}; do for id in ${!deezerArtistAlbumsIds[@]}; do
processNumberTwo=$(( $id + 1 )) processNumberTwo=$(( $id + 1 ))
@ -258,6 +269,7 @@ SearchProcess () {
else else
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Explicit Deezer Match Found" log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Explicit Deezer Match Found"
fi fi
done
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then if [ $alreadyImported = true ]; then
@ -296,6 +308,9 @@ SearchProcess () {
return return
fi fi
for dId in ${!deezeArtistIds[@]}; do
deezeArtistId="${deezeArtistIds[$dId]}"
deezerArtistAlbumsData=$(cat "/config/cache/deezer/$deezeArtistId-albums.json" | jq -r ".data | sort_by(.release_date) | sort_by(.explicit_lyrics) | reverse | .[]")
deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="false") | .id")) deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="false") | .id"))
if echo "${deezerArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then if echo "${deezerArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then
@ -320,6 +335,7 @@ SearchProcess () {
else else
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Clean Deezer Match Found" log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Clean Deezer Match Found"
fi fi
done
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then if [ $alreadyImported = true ]; then
@ -354,7 +370,7 @@ SearchProcess () {
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Clean Tidal Match Found" log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Clean Tidal Match Found"
fi fi
mkdir -p /config/logs/downloaded/notfound mkdir -p /config/logs/downloaded/notfound
touch /config/logs/downloaded/notfound/$wantedAlbumId touch /config/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId
done done
} }

Loading…
Cancel
Save