From b6f0d40304ab6b4dc62647fe085594c07ec00c18 Mon Sep 17 00:00:00 2001 From: Jonny007-MKD Date: Sun, 4 Sep 2016 21:35:39 +0200 Subject: [PATCH] Add option to disable usage of parent directories --- config.sample | 7 ++++--- otrDecodeAll | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/config.sample b/config.sample index 892d066..c4a923a 100644 --- a/config.sample +++ b/config.sample @@ -24,10 +24,11 @@ function funcConfigPre { # These values are set at the beginning of the script # 1st arg: Label # 2nd arg: Each movie with this label will be moved to this subdirectory of $outDir # 3rd arg: (optional) Whether SaneRenamix shall be used for movies with this label (default: false) - addLabel "movie" "Filme" 0 - addLabel "movie-en" "Filme-En" "false" + # 4th arg: (optional) Whether the name of the movie/series shall be used as parent directory (default: true) + addLabel "movie" "Filme" 0 0 + addLabel "movie-en" "Filme-En" "false" "false" addLabel "docu" "Dokumentationen" - addLabel "tvserie" "Serien" true + addLabel "tvserie" "Serien" true true umask 0002 # Set permissions 775/664 per default } diff --git a/otrDecodeAll b/otrDecodeAll index 8a3452a..380365c 100755 --- a/otrDecodeAll +++ b/otrDecodeAll @@ -19,6 +19,7 @@ lastProcessingEchoedNL=0 warnUnknownLabel=true declare -A label2Dir declare -A label2SaneRename +declare -A label2UseDirAsParent PwD=$(readlink -e $0) # Get the path to this script @@ -111,12 +112,30 @@ function funcUnlock { # Add label to dictionary function addLabel { success=1; + dir=1; case $# in [0-1]) funcLog 1 "Not enough arguments given for addLabel! Give at least name and directory" success=0;; 2) sr=0;; + 4) + case $4 in + 0) ;& + [fF]) ;& + false) ;& + no) + dir=0;; + + 1) ;& + [tT]) ;& + true) ;& + yes) + dir=1;; + *) + funcLog 1 "addLabel: Could not understand fourth argument \"$4\"! Please give \"true\" or \"false\" to specify whether the name of the movie/episode shall be used as parent directory." + success=0;; + esac;& # goto 3) 3) case $3 in 0) ;& @@ -148,6 +167,7 @@ function addLabel { funcLog 5 "Adding label \"$1\" with dir = \"$2\" and sanerename = $sr" label2Dir["$1"]="$2"; label2SaneRename["$1"]=$sr; + label2UseDirAsParent["$1"]=$dir; fi } @@ -564,7 +584,9 @@ function funcMakeVars { funcLog 5 "pathAbsOutCutInsane: $pathAbsOutCutInsane" fi - pathAbsOutDecoded="$pathAbsOutDecoded/$bibname" # Append bibname: This is the series name or the movie name (Kodi likes this) + if [ "${label2UseDirAsParent["$label"]}" -ne 0 ]; then + pathAbsOutDecoded="$pathAbsOutDecoded/$bibname" # Append bibname: This is the series name or the movie name (Kodi likes this) + fi # This will be the absolute path to the output file (e.g. /final/Good.Wife/Good.Wife..S05E14..Ein.paar.Worte.HQ.avi) pathAbsOutDecoded="$outDir/$pathAbsOutDecoded/$sanename"