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
mkdir -p /config/cache/deezer
fi
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
fi
done
if [ ! -d /config/cache/deezer ]; then
mkdir -p /config/cache/deezer
fi
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
fi
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 | .[]")
deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="true") | .id"))
deezerArtistAlbumsData=$(cat "/config/cache/deezer/$deezeArtistId-albums.json" | jq -r ".data | sort_by(.release_date) | sort_by(.explicit_lyrics) | reverse | .[]") done
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"))
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then if [ $alreadyImported = true ]; then
@ -237,27 +243,33 @@ SearchProcess () {
return return
fi fi
if echo "${deezerArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then for dId in ${!deezeArtistIds[@]}; do
for id in ${!deezerArtistAlbumsIds[@]}; do deezeArtistId="${deezeArtistIds[$dId]}"
processNumberTwo=$(( $id + 1 )) deezerArtistAlbumsData=$(cat "/config/cache/deezer/$deezeArtistId-albums.json" | jq -r ".data | sort_by(.release_date) | sort_by(.explicit_lyrics) | reverse | .[]")
deezerArtistAlbumId="${deezerArtistAlbumsIds[$id]}" deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="true") | .id"))
deezerArtistAlbumData=$(echo "$deezerArtistAlbumsData" | jq -r "select(.id=="$deezerArtistAlbumId")")
deezerArtistAlbumTitleClean=$(echo ${deezerArtistAlbumData} | jq -r .title | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g') if echo "${deezerArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then
if echo ${deezerArtistAlbumTitleClean} | grep -i "^$lidarrAlbumTitleClean" | read; then for id in ${!deezerArtistAlbumsIds[@]}; do
downloadedAlbumTitle="$(echo ${deezerArtistAlbumData} | jq -r .title)" processNumberTwo=$(( $id + 1 ))
downloadedReleaseDate="$(echo ${deezerArtistAlbumData} | jq -r .release_date)" deezerArtistAlbumId="${deezerArtistAlbumsIds[$id]}"
downloadedReleaseYear="${downloadedReleaseDate:0:4}" deezerArtistAlbumData=$(echo "$deezerArtistAlbumsData" | jq -r "select(.id=="$deezerArtistAlbumId")")
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumTitleClean vs $deezerArtistAlbumTitleClean :: Explicit Deezer MATCH Found" deezerArtistAlbumTitleClean=$(echo ${deezerArtistAlbumData} | jq -r .title | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')
if [ -f /config/logs/downloaded/deezer/$deezerArtistAlbumId ]; then if echo ${deezerArtistAlbumTitleClean} | grep -i "^$lidarrAlbumTitleClean" | read; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Downloaded, skipping..." downloadedAlbumTitle="$(echo ${deezerArtistAlbumData} | jq -r .title)"
continue downloadedReleaseDate="$(echo ${deezerArtistAlbumData} | jq -r .release_date)"
fi downloadedReleaseYear="${downloadedReleaseDate:0:4}"
DownloadProcess "$deezerArtistAlbumId" "DEEZER" "$downloadedReleaseYear" log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumTitleClean vs $deezerArtistAlbumTitleClean :: Explicit Deezer MATCH Found"
fi if [ -f /config/logs/downloaded/deezer/$deezerArtistAlbumId ]; then
done log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Downloaded, skipping..."
else continue
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Explicit Deezer Match Found" fi
fi DownloadProcess "$deezerArtistAlbumId" "DEEZER" "$downloadedReleaseYear"
fi
done
else
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Explicit Deezer Match Found"
fi
done
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then if [ $alreadyImported = true ]; then
@ -296,30 +308,34 @@ SearchProcess () {
return return
fi fi
deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="false") | .id")) for dId in ${!deezeArtistIds[@]}; do
deezeArtistId="${deezeArtistIds[$dId]}"
if echo "${deezerArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then deezerArtistAlbumsData=$(cat "/config/cache/deezer/$deezeArtistId-albums.json" | jq -r ".data | sort_by(.release_date) | sort_by(.explicit_lyrics) | reverse | .[]")
for id in ${!deezerArtistAlbumsIds[@]}; do deezerArtistAlbumsIds=($(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="false") | .id"))
processNumberTwo=$(( $id + 1 ))
deezerArtistAlbumId="${deezerArtistAlbumsIds[$id]}" if echo "${deezerArtistAlbumsData}" | jq -r .title | grep -i "^$lidarrAlbumTitle" | read; then
deezerArtistAlbumData=$(echo "$deezerArtistAlbumsData" | jq -r "select(.id=="$deezerArtistAlbumId")") for id in ${!deezerArtistAlbumsIds[@]}; do
deezerArtistAlbumExplicit=$(echo ${deezerArtistAlbumData} | jq -r .explicit_lyrics) processNumberTwo=$(( $id + 1 ))
deezerArtistAlbumTitleClean=$(echo ${deezerArtistAlbumData} | jq -r .title | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g') deezerArtistAlbumId="${deezerArtistAlbumsIds[$id]}"
if echo ${deezerArtistAlbumTitleClean} | grep -i "^$lidarrAlbumTitleClean" | read; then deezerArtistAlbumData=$(echo "$deezerArtistAlbumsData" | jq -r "select(.id=="$deezerArtistAlbumId")")
downloadedAlbumTitle="$(echo ${deezerArtistAlbumData} | jq -r .title)" deezerArtistAlbumExplicit=$(echo ${deezerArtistAlbumData} | jq -r .explicit_lyrics)
downloadedReleaseDate="$(echo ${deezerArtistAlbumData} | jq -r .release_date)" deezerArtistAlbumTitleClean=$(echo ${deezerArtistAlbumData} | jq -r .title | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')
downloadedReleaseYear="${downloadedReleaseDate:0:4}" if echo ${deezerArtistAlbumTitleClean} | grep -i "^$lidarrAlbumTitleClean" | read; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumTitleClean vs $deezerArtistAlbumTitleClean :: CLEAN Deezer MATCH Found" downloadedAlbumTitle="$(echo ${deezerArtistAlbumData} | jq -r .title)"
if [ -f /config/logs/downloaded/deezer/$deezerArtistAlbumId ]; then downloadedReleaseDate="$(echo ${deezerArtistAlbumData} | jq -r .release_date)"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Downloaded, skipping..." downloadedReleaseYear="${downloadedReleaseDate:0:4}"
continue log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumTitleClean vs $deezerArtistAlbumTitleClean :: CLEAN Deezer MATCH Found"
fi if [ -f /config/logs/downloaded/deezer/$deezerArtistAlbumId ]; then
DownloadProcess "$deezerArtistAlbumId" "DEEZER" "$downloadedReleaseYear" log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Previously Downloaded, skipping..."
fi continue
done fi
else DownloadProcess "$deezerArtistAlbumId" "DEEZER" "$downloadedReleaseYear"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Clean Deezer Match Found" fi
fi done
else
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No Clean Deezer Match Found"
fi
done
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId"
if [ $alreadyImported = true ]; then if [ $alreadyImported = true ]; then
@ -353,9 +369,9 @@ SearchProcess () {
else else
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
} }
ProcessWithBeets () { ProcessWithBeets () {

Loading…
Cancel
Save