From 69b82a3497ccb3798bc2060c3cea61b708b51389 Mon Sep 17 00:00:00 2001 From: emily Date: Tue, 26 Nov 2024 22:00:50 +0100 Subject: [PATCH] Small refactor --- lidarr/ArtworkExtractor.bash | 1 - lidarr/AutoConfig.service.bash | 10 ++++------ lidarr/Video.service.bash | 4 ++-- lidarr/scripts_init.bash | 3 --- universal/functions.bash | 19 +++---------------- 5 files changed, 9 insertions(+), 28 deletions(-) delete mode 100644 lidarr/scripts_init.bash diff --git a/lidarr/ArtworkExtractor.bash b/lidarr/ArtworkExtractor.bash index 54e3d59..0097210 100644 --- a/lidarr/ArtworkExtractor.bash +++ b/lidarr/ArtworkExtractor.bash @@ -1,5 +1,4 @@ #!/usr/bin/env bash -scriptVersion="1.2" scriptName="ArtworkExtractor" #### Import Settings diff --git a/lidarr/AutoConfig.service.bash b/lidarr/AutoConfig.service.bash index 8ff3687..bea9bca 100644 --- a/lidarr/AutoConfig.service.bash +++ b/lidarr/AutoConfig.service.bash @@ -1,6 +1,4 @@ #!/usr/bin/env bash -scriptVersion="3.2" -scriptName="AutoConfig" ### Import Settings source /config/extended.conf @@ -36,7 +34,7 @@ fi if [ "$configureCustomScripts" == "true" ] || [ -z "$configureCustomScripts" ]; then log "Configuring Lidarr Custom Scripts" - if curl -s "$arrUrl/api/v1/notification" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].name | grep "PlexNotify.bash" | read; then + if curl -s "$arrUrl/api/v1/notification" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].name | grep "PlexNotify.bash" | read -r; then log "PlexNotify.bash Already added to Lidarr custom scripts" else log "Adding PlexNotify.bash to Lidarr custom scripts" @@ -46,7 +44,7 @@ if [ "$configureCustomScripts" == "true" ] || [ -z "$configureCustomScripts" ]; fi - if curl -s "$arrUrl/api/v1/notification" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].name | grep "LyricExtractor.bash" | read; then + if curl -s "$arrUrl/api/v1/notification" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].name | grep "LyricExtractor.bash" | read -r; then log "LyricExtractor.bash Already added to Lidarr custom scripts" else log "Adding LyricExtractor.bash to Lidarr custom scripts" @@ -56,7 +54,7 @@ if [ "$configureCustomScripts" == "true" ] || [ -z "$configureCustomScripts" ]; fi - if curl -s "$arrUrl/api/v1/notification" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].name | grep "ArtworkExtractor.bash" | read; then + if curl -s "$arrUrl/api/v1/notification" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].name | grep "ArtworkExtractor.bash" | read -r; then log "ArtworkExtractor.bash Already added to Lidarr custom scripts" else log "Adding ArtworkExtractor.bash to Lidarr custom scripts" @@ -66,7 +64,7 @@ if [ "$configureCustomScripts" == "true" ] || [ -z "$configureCustomScripts" ]; fi - if curl -s "$arrUrl/api/v1/notification" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].name | grep "BeetsTagger.bash" | read; then + if curl -s "$arrUrl/api/v1/notification" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].name | grep "BeetsTagger.bash" | read -r; then log "BeetsTagger.bash Already added to Lidarr custom scripts" else log "Adding BeetsTagger.bash to Lidarr custom scripts" diff --git a/lidarr/Video.service.bash b/lidarr/Video.service.bash index 5460944..a259c64 100644 --- a/lidarr/Video.service.bash +++ b/lidarr/Video.service.bash @@ -325,7 +325,7 @@ VideoTagProcess () { if [[ $filenoext.$videoContainer == *.mkv ]]; then mv "$filenoext.$videoContainer" "$filenoext-temp.$videoContainer" log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: ${imvdbProcessCount}/${imvdbArtistVideoCount} :: ${1}${2} $3 :: Tagging file" - ffmpeg -y \ + ffmpeg -y -nostdin \ -i "$filenoext-temp.$videoContainer" \ -c copy \ -metadata TITLE="${1}" \ @@ -343,7 +343,7 @@ VideoTagProcess () { else mv "$filenoext.$videoContainer" "$filenoext-temp.$videoContainer" log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: ${imvdbProcessCount}/${imvdbArtistVideoCount} :: ${1}${2} $3 :: Tagging file" - ffmpeg -y \ + ffmpeg -y -nostdin \ -i "$filenoext-temp.$videoContainer" \ -i "$videoDownloadPath/incomplete/${1}${2}.jpg" \ -map 1 \ diff --git a/lidarr/scripts_init.bash b/lidarr/scripts_init.bash deleted file mode 100644 index e118895..0000000 --- a/lidarr/scripts_init.bash +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/with-contenv bash -curl https://raw.githubusercontent.com/RandomNinjaAtk/arr-scripts/main/lidarr/setup.bash | bash -exit diff --git a/universal/functions.bash b/universal/functions.bash index dc51a0e..dd9bd97 100644 --- a/universal/functions.bash +++ b/universal/functions.bash @@ -1,19 +1,6 @@ log () { - m_time=`date "+%F %T"` - echo $m_time" :: $scriptName :: $scriptVersion :: "$1 - echo $m_time" :: $scriptName :: $scriptVersion :: "$1 >> "/config/logs/$logFileName" -} - -logfileSetup () { - logFileName="$scriptName-$(date +"%Y_%m_%d_%I_%M_%p").txt" - - # delete log files older than 5 days - find "/config/logs" -type f -iname "$scriptName-*.txt" -mtime +5 -delete - - if [ ! -f "/config/logs/$logFileName" ]; then - echo "" > "/config/logs/$logFileName" - chmod 666 "/config/logs/$logFileName" - fi + m_time=$(date "+%F %T") + echo "$m_time :: $scriptName :: $1" } getArrAppInfo () { @@ -45,7 +32,7 @@ verifyApiAccess () { arrApiVersion="v1" arrApiTest="$(curl -s "$arrUrl/api/$arrApiVersion/system/status?apikey=$arrApiKey" | jq -r .instanceName)" fi - if [ ! -z "$arrApiTest" ]; then + if [ -n "$arrApiTest" ]; then break else log "$arrName is not ready, sleeping until valid response..."