From 8fe60f098eda5cd9056d39d38c2b0a2a498915b8 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Sun, 10 Jul 2022 16:19:50 -0400 Subject: [PATCH] 1.0.132 - new requireQuality process When enabled, all download files must have the requested file extension, if not, the download will fail --- root/scripts/download.sh | 67 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/root/scripts/download.sh b/root/scripts/download.sh index d3c6db6..b1cf1ae 100644 --- a/root/scripts/download.sh +++ b/root/scripts/download.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.131" +scriptVersion="1.0.132" lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" if [ "$lidarrUrlBase" = "null" ]; then lidarrUrlBase="" @@ -23,6 +23,7 @@ musicbrainzMirror=https://musicbrainz.org #addRelatedArtists=true #numberOfRelatedArtistsToAddPerArtist=1 #beetsMatchPercentage=85 +#requireQuality=true sleepTimer=0.5 @@ -121,6 +122,12 @@ Configuration () { log ":: Output format = $audioFormat" log ":: Output bitrate = $audioBitrate" + if [ "$requireQuality" = "true" ]; then + log ":: Download Quality Check Enabled" + else + log ":: Download Quality Check Disabled (enable by setting: requireQuality=true" + fi + if [ $audioLyricType = both ] || [ $audioLyricType = explicit ] || [ $audioLyricType = explicit ]; then log ":: Preferred audio lyric type: $audioLyricType" fi @@ -596,9 +603,12 @@ DownloadProcess () { return fi + # Check download for required quality (checks based on file extension) + DownloadQualityCheck "/downloads/lidarr-extended/incomplete" "$2" + downloadCount=$(find /downloads/lidarr-extended/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l) if [ $downloadCount -le 0 ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: ERROR :: All download Attempst failed..." + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: ERROR :: All download Attempts failed..." return fi @@ -670,6 +680,59 @@ DownloadProcess () { # NotifyPlexToScan } +DownloadQualityCheck () { + + if [ "$requireQuality" = "true" ]; then + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Checking for unwanted files" + + if [ $audioFormat != native ]; then + if find "$1" -type f -regex ".*/.*\.\(opus\|m4a\|mp3\)"| read; then + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Unwanted files found!" + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Performing cleanup..." + rm "$1"/* + else + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No unwanted files found!" + fi + fi + if [ $audioFormat = native ]; then + if [ $audioBitrate = lossless ]; then + if find "$1" -type f -regex ".*/.*\.\(opus\|m4a\|mp3\)"| read; then + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Unwanted files found!" + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Performing cleanup..." + rm "$1"/* + else + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No unwanted files found!" + fi + elif [ $2 = DEEZER ]; then + if find "$1" -type f -regex ".*/.*\.\(opus\|m4a\|flac\)"| read; then + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Unwanted files found!" + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Performing cleanup..." + rm "$1"/* + else + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No unwanted files found!" + fi + elif [ $2 = TIDAL ]; then + if find "$1" -type f -regex ".*/.*\.\(opus\|flac\|mp3\)"| read; then + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Unwanted files found!" + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Performing cleanup..." + rm "$1"/* + else + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: No unwanted files found!" + fi + fi + fi + else + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Skipping download quality check... (enable by setting: requireQuality=true)" + fi +} + +AddReplaygainTags () { + if [ "$replaygain" == "true" ]; then + log "$logheader :: DOWNLOAD :: Adding Replaygain Tags using r128gain" + r128gain -r -a -c $POSTPROCESSTHREADS "$DOWNLOADS/amd/dlclient" + fi +} + NotifyLidarrForImport () { LidarrProcessIt=$(curl -s "$lidarrUrl/api/v1/command" --header "X-Api-Key:"${lidarrApiKey} -H "Content-Type: application/json" --data "{\"name\":\"DownloadedAlbumsScan\", \"path\":\"$1\"}") log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: LIDARR IMPORT NOTIFICATION SENT! :: $1"