1.0.200 - switch to downloadPath

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

@ -1,5 +1,5 @@
#!/usr/bin/env bash
scriptVersion="1.0.199"
scriptVersion="1.0.200"
lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)"
if [ "$lidarrUrlBase" = "null" ]; then
lidarrUrlBase=""
@ -186,12 +186,12 @@ DownloadFormat () {
DownloadFolderCleaner () {
# check for completed download folder
if [ -d "/downloads/lidarr-extended/complete" ]; then
if [ -d "$downloadPath/complete" ]; then
log ":: Removing prevously completed downloads that failed to import..."
# check for completed downloads older than 1 day
if find /downloads/lidarr-extended/complete -mindepth 1 -type d -mtime +1 | read; then
if find $downloadPath/complete -mindepth 1 -type d -mtime +1 | read; then
# delete completed downloads older than 1 day, these most likely failed to import due to Lidarr failing to match
find /downloads/lidarr-extended/complete -mindepth 1 -type d -mtime +1 -exec rm -rf "{}" \; &>/dev/null
find $downloadPath/complete -mindepth 1 -type d -mtime +1 -exec rm -rf "{}" \; &>/dev/null
fi
fi
}
@ -330,7 +330,7 @@ TidalClientSetup () {
fi
tidal-dl -o /downloads/lidarr-extended/incomplete
tidal-dl -o $downloadPath/incomplete
DownloadFormat
@ -358,19 +358,13 @@ TidalClientSetup () {
log ":: TIDAL :: Purging album list cache..."
find /config/extended/cache/tidal -type f -name "*.json" -delete
fi
if [ ! -d "/downloads/lidarr-extended" ]; then
mkdir -p /downloads/lidarr-extended
chmod 777 /downloads/lidarr-extended
chown abc:abc /downloads/lidarr-extended
fi
if [ ! -d "/downloads/lidarr-extended/incomplete" ]; then
mkdir -p /downloads/lidarr-extended/incomplete
chmod 777 /downloads/lidarr-extended/incomplete
chown abc:abc /downloads/lidarr-extended/incomplete
if [ ! -d "$downloadPath/incomplete" ]; then
mkdir -p $downloadPath/incomplete
chmod 777 $downloadPath/incomplete
chown abc:abc $downloadPath/incomplete
else
rm -rf /downloads/lidarr-extended/incomplete/*
rm -rf $downloadPath/incomplete/*
fi
log ":: TIDAL :: Upgrade tidal-dl to the latest..."
@ -380,9 +374,9 @@ TidalClientSetup () {
TidalClientTest () {
log ":: TIDAL :: tidal-dl client setup verification..."
tidal-dl -o /downloads/lidarr-extended/incomplete -l "166356219"
tidal-dl -o $downloadPath/incomplete -l "166356219"
downloadCount=$(find /downloads/lidarr-extended/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l)
downloadCount=$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l)
if [ $downloadCount -le 0 ]; then
if [ -f /config/xdg/.tidal-dl.token.json ]; then
rm /config/xdg/.tidal-dl.token.json
@ -390,10 +384,10 @@ TidalClientTest () {
log ":: TIDAL :: ERROR :: Download failed"
log ":: TIDAL :: ERROR :: You will need to re-authenticate on next script run..."
log ":: TIDAL :: ERROR :: Exiting..."
rm -rf /downloads/lidarr-extended/incomplete/*
rm -rf $downloadPath/incomplete/*
exit
else
rm -rf /downloads/lidarr-extended/incomplete/*
rm -rf $downloadPath/incomplete/*
log ":: TIDAL :: Successfully Verified"
fi
}
@ -408,27 +402,21 @@ DownloadProcess () {
# $5 = Expected Track Count
# Create Required Directories
if [ ! -d "/downloads/lidarr-extended" ]; then
mkdir -p /downloads/lidarr-extended
chmod 777 /downloads/lidarr-extended
chown abc:abc /downloads/lidarr-extended
fi
if [ ! -d "/downloads/lidarr-extended/incomplete" ]; then
mkdir -p /downloads/lidarr-extended/incomplete
chmod 777 /downloads/lidarr-extended/incomplete
chown abc:abc /downloads/lidarr-extended/incomplete
# Create Required Directories
if [ ! -d "$downloadPath/incomplete" ]; then
mkdir -p $downloadPath/incomplete
chmod 777 $downloadPath/incomplete
chown abc:abc $downloadPath/incomplete
else
rm -rf /downloads/lidarr-extended/incomplete/*
rm -rf $downloadPath/incomplete/*
fi
if [ ! -d "/downloads/lidarr-extended/complete" ]; then
mkdir -p /downloads/lidarr-extended/complete
chmod 777 /downloads/lidarr-extended/complete
chown abc:abc /downloads/lidarr-extended/complete
if [ ! -d "$downloadPath/complete" ]; then
mkdir -p $downloadPath/complete
chmod 777 $downloadPath/complete
chown abc:abc $downloadPath/complete
else
rm -rf /downloads/lidarr-extended/complete/*
rm -rf $downloadPath/complete/*
fi
if [ ! -d "/config/extended/logs" ]; then
@ -469,7 +457,7 @@ DownloadProcess () {
downloadedAlbumTitleClean="$(echo "$4" | sed -e "s%[^[:alpha:][:digit:]._' ]% %g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')"
if find /downloads/lidarr-extended/complete -type d -iname "$lidarrArtistNameSanitized-$downloadedAlbumTitleClean ($3)-*-$1-$2" | read; then
if find $downloadPath/complete -type d -iname "$lidarrArtistNameSanitized-$downloadedAlbumTitleClean ($3)-*-$1-$2" | read; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Downloaded..."
return
fi
@ -513,17 +501,17 @@ DownloadProcess () {
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Download Attempt number $downloadTry"
if [ "$2" = "DEEZER" ]; then
deemix -b $deemixQuality -p /downloads/lidarr-extended/incomplete "https://www.deezer.com/album/$1"
deemix -b $deemixQuality -p $downloadPath/incomplete "https://www.deezer.com/album/$1"
if [ -d "/tmp/deemix-imgs" ]; then
rm -rf /tmp/deemix-imgs
fi
fi
if [ "$2" = "TIDAL" ]; then
tidal-dl -o /downloads/lidarr-extended/incomplete -l "$1"
tidal-dl -o $downloadPath/incomplete -l "$1"
fi
find "/downloads/lidarr-extended/incomplete" -type f -iname "*.flac" -newer "/temp-download" -print0 | while IFS= read -r -d '' file; do
find "$downloadPath/incomplete" -type f -iname "*.flac" -newer "/temp-download" -print0 | while IFS= read -r -d '' file; do
audioFlacVerification "$file"
if [ $verifiedFlacFile = 0 ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Flac Verification :: $file :: Verified"
@ -533,7 +521,7 @@ DownloadProcess () {
fi
done
downloadCount=$(find /downloads/lidarr-extended/incomplete/ -type f -regex ".*/.*\.\(flac\|m4a\|mp3\)" | wc -l)
downloadCount=$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|m4a\|mp3\)" | wc -l)
if [ $downloadCount -ne $5 ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: download failed, missing tracks..."
completedVerification="false"
@ -545,8 +533,8 @@ DownloadProcess () {
if [ "$completedVerification" = "true" ]; then
break
elif [ $downloadTry = 5 ]; then
if [ -d /downloads/lidarr-extended/incomplete ]; then
rm -rf /downloads/lidarr-extended/incomplete/*
if [ -d $downloadPath/incomplete ]; then
rm -rf $downloadPath/incomplete/*
fi
break
else
@ -558,19 +546,19 @@ DownloadProcess () {
# Consolidate files to a single folder
if [ "$2" = "TIDAL" ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Consolidating files to single folder"
find "/downloads/lidarr-extended/incomplete" -type f -exec mv "{}" /downloads/lidarr-extended/incomplete/ \;
if [ -d /downloads/lidarr-extended/incomplete/atd ]; then
rm -rf /downloads/lidarr-extended/incomplete/atd
find "$downloadPath/incomplete" -type f -exec mv "{}" $downloadPath/incomplete/ \;
if [ -d $downloadPath/incomplete/atd ]; then
rm -rf $downloadPath/incomplete/atd
fi
fi
downloadCount=$(find /downloads/lidarr-extended/incomplete/ -type f -regex ".*/.*\.\(flac\|m4a\|mp3\)" | wc -l)
downloadCount=$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|m4a\|mp3\)" | wc -l)
if [ $downloadCount -gt 0 ]; then
# Check download for required quality (checks based on file extension)
DownloadQualityCheck "/downloads/lidarr-extended/incomplete" "$2"
DownloadQualityCheck "$downloadPath/incomplete" "$2"
fi
downloadCount=$(find /downloads/lidarr-extended/incomplete/ -type f -regex ".*/.*\.\(flac\|m4a\|mp3\)" | wc -l)
downloadCount=$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|m4a\|mp3\)" | wc -l)
if [ $downloadCount -ne $5 ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: All download Attempts failed..."
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Logging $1 as failed download..."
@ -616,7 +604,7 @@ DownloadProcess () {
extension="m4a"
fi
find "/downloads/lidarr-extended/incomplete" -type f -iname "*.flac" -print0 | while IFS= read -r -d '' audio; do
find "$downloadPath/incomplete" -type f -iname "*.flac" -print0 | while IFS= read -r -d '' audio; do
file="${audio}"
filename="$(basename "$audio")"
foldername="$(dirname "$audio")"
@ -633,12 +621,12 @@ DownloadProcess () {
fi
if [ $enableReplaygainTags = true ]; then
AddReplaygainTags "/downloads/lidarr-extended/incomplete"
AddReplaygainTags "$downloadPath/incomplete"
else
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Replaygain Tagging Disabled (set enableReplaygainTags=true to enable...)"
fi
find "/downloads/lidarr-extended/incomplete" -type f -iname "*.flac" -print0 | while IFS= read -r -d '' file; do
find "$downloadPath/incomplete" -type f -iname "*.flac" -print0 | while IFS= read -r -d '' file; do
lrcFile="${file%.*}.lrc"
if [ -f "$lrcFile" ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Embedding lyrics (lrc) into $file"
@ -648,38 +636,38 @@ DownloadProcess () {
fi
done
albumquality="$(find /downloads/lidarr-extended/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | head -n 1 | egrep -i -E -o "\.{1}\w*$" | sed 's/\.//g')"
albumquality="$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | head -n 1 | egrep -i -E -o "\.{1}\w*$" | sed 's/\.//g')"
downloadedAlbumFolder="$lidarrArtistNameSanitized-$downloadedAlbumTitleClean ($3)-${albumquality^^}-$1-$2"
find "/downloads/lidarr-extended/incomplete" -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" -print0 | while IFS= read -r -d '' audio; do
find "$downloadPath/incomplete" -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" -print0 | while IFS= read -r -d '' audio; do
file="${audio}"
filenoext="${file%.*}"
filename="$(basename "$audio")"
extension="${filename##*.}"
filenamenoext="${filename%.*}"
if [ ! -d "/downloads/lidarr-extended/complete" ]; then
mkdir -p /downloads/lidarr-extended/complete
chmod 777 /downloads/lidarr-extended/complete
chown abc:abc /downloads/lidarr-extended/complete
if [ ! -d "$downloadPath/complete" ]; then
mkdir -p $downloadPath/complete
chmod 777 $downloadPath/complete
chown abc:abc $downloadPath/complete
fi
mkdir -p "/downloads/lidarr-extended/complete/$downloadedAlbumFolder"
mv "$file" "/downloads/lidarr-extended/complete/$downloadedAlbumFolder"/
mkdir -p "$downloadPath/complete/$downloadedAlbumFolder"
mv "$file" "$downloadPath/complete/$downloadedAlbumFolder"/
done
chmod -R 777 /downloads/lidarr-extended/complete
chown -R abc:abc /downloads/lidarr-extended/complete
chmod -R 777 $downloadPath/complete
chown -R abc:abc $downloadPath/complete
if [ $enableBeetsTagging = true ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Processing files with beets..."
ProcessWithBeets "/downloads/lidarr-extended/complete/$downloadedAlbumFolder" "${albumquality^^}" "$2" "$1"
ProcessWithBeets "$downloadPath/complete/$downloadedAlbumFolder" "${albumquality^^}" "$2" "$1"
else
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Beets Tagging Disabled (set enableBeetsTagging=true to enable...)"
fi
if [ -d "/downloads/lidarr-extended/complete/$downloadedAlbumFolder" ]; then
NotifyLidarrForImport "/downloads/lidarr-extended/complete/$downloadedAlbumFolder"
if [ -d "$downloadPath/complete/$downloadedAlbumFolder" ]; then
NotifyLidarrForImport "$downloadPath/complete/$downloadedAlbumFolder"
fi
rm -rf /downloads/lidarr-extended/incomplete/*
rm -rf $downloadPath/incomplete/*
# NotifyPlexToScan
}
@ -784,18 +772,12 @@ DeemixClientSetup () {
find /config/extended/cache/deezer -type f -name "*-albums.json" -delete
fi
if [ ! -d "/downloads/lidarr-extended" ]; then
mkdir -p /downloads/lidarr-extended
chmod 777 /downloads/lidarr-extended
chown abc:abc /downloads/lidarr-extended
fi
if [ ! -d "/downloads/lidarr-extended/incomplete" ]; then
mkdir -p /downloads/lidarr-extended/incomplete
chmod 777 /downloads/lidarr-extended/incomplete
chown abc:abc /downloads/lidarr-extended/incomplete
if [ ! -d "$downloadPath/incomplete" ]; then
mkdir -p $downloadPath/incomplete
chmod 777 $downloadPath/incomplete
chown abc:abc $downloadPath/incomplete
else
rm -rf /downloads/lidarr-extended/incomplete/*
rm -rf $downloadPath/incomplete/*
fi
log ":: DEEZER :: Upgrade deemix to the latest..."
@ -806,20 +788,20 @@ DeemixClientSetup () {
DeezerClientTest () {
log ":: DEEZER :: deemix client setup verification..."
deemix -b $deemixQuality -p /downloads/lidarr-extended/incomplete "https://www.deezer.com/album/197472472"
deemix -b $deemixQuality -p $downloadPath/incomplete "https://www.deezer.com/album/197472472"
if [ -d "/tmp/deemix-imgs" ]; then
rm -rf /tmp/deemix-imgs
fi
downloadCount=$(find /downloads/lidarr-extended/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l)
downloadCount=$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l)
if [ $downloadCount -le 0 ]; then
log ":: DEEZER :: ERROR :: Download failed"
log ":: DEEZER :: ERROR :: Please review log for errors in client"
log ":: DEEZER :: ERROR :: Try updating your ARL Token to possibly resolve the issue..."
log ":: DEEZER :: ERROR :: Exiting..."
rm -rf /downloads/lidarr-extended/incomplete/*
rm -rf $downloadPath/incomplete/*
exit
else
rm -rf /downloads/lidarr-extended/incomplete/*
rm -rf $downloadPath/incomplete/*
log ":: DEEZER :: Successfully Verified"
fi
@ -1834,17 +1816,17 @@ ProcessWithBeets () {
downloadedAlbumFolder="${matchedLidarrAlbumArtistCleanName}-${matchedTagsAlbumTitleClean} ($matchedTagsAlbumYear)-${albumquality^^}-$4-$3"
if [ "$1" != "/downloads/lidarr-extended/complete/$downloadedAlbumFolder" ];then
if [ -d "/downloads/lidarr-extended/complete/$downloadedAlbumFolder" ]; then
rm -rf "/downloads/lidarr-extended/complete/$downloadedAlbumFolder"
if [ "$1" != "$downloadPath/complete/$downloadedAlbumFolder" ];then
if [ -d "$downloadPath/complete/$downloadedAlbumFolder" ]; then
rm -rf "$downloadPath/complete/$downloadedAlbumFolder"
sleep 0.1
fi
if [ ! -d "/downloads/lidarr-extended/complete/$downloadedAlbumFolder" ]; then
mv "$1" "/downloads/lidarr-extended/complete/$downloadedAlbumFolder"
if [ ! -d "$downloadPath/complete/$downloadedAlbumFolder" ]; then
mv "$1" "$downloadPath/complete/$downloadedAlbumFolder"
fi
fi
chmod -R 777 "/downloads/lidarr-extended/complete"
chown -R abc:abc "/downloads/lidarr-extended/complete"
chmod -R 777 "$downloadPath/complete"
chown -R abc:abc "$downloadPath/complete"
}
CheckLidarrBeforeImport () {

Loading…
Cancel
Save