1
0
Fork 0
mirror of https://github.com/Jonny007-MKD/OTR-DecodeAll synced 2025-01-22 08:49:50 +01:00

Added option to ignore unknown labels

This commit is contained in:
Jonny007-MKD 2016-06-06 13:46:11 +02:00
parent 92b82007dd
commit 169b9646df
2 changed files with 37 additions and 23 deletions

View file

@ -19,6 +19,7 @@ function funcConfigPre { # These values are set at the beginning of the script
echoLevel=5 # level, which messages shall be written to stdout. echoLevel=5 # level, which messages shall be written to stdout.
labelDb="/home/deluged/labeldb/labelsOfTorrents.db" # File with file names and labels (see at github: Torrent-Label-DB) (optional) labelDb="/home/deluged/labeldb/labelsOfTorrents.db" # File with file names and labels (see at github: Torrent-Label-DB) (optional)
warnUnknownLabel=false # Print a warning for files with an unknown label?
# Add label to directory mapping. (optional) # Add label to directory mapping. (optional)
# 1st arg: Label # 1st arg: Label
# 2nd arg: Each movie with this label will be moved to this subdirectory of $outDir # 2nd arg: Each movie with this label will be moved to this subdirectory of $outDir

View file

@ -16,6 +16,7 @@ cutAppendix="-cut.mkv"
lastProcessingLogPrinted=0 lastProcessingLogPrinted=0
lastProcessingEchoed=0 lastProcessingEchoed=0
lastProcessingEchoedNL=0 lastProcessingEchoedNL=0
warnUnknownLabel=true
declare -A label2Dir declare -A label2Dir
declare -A label2SaneRename declare -A label2SaneRename
@ -355,6 +356,9 @@ function funcProcessFiles {
status=0; status=0;
alrMoved=0; alrMoved=0;
funcMakeVars # Make all path variables funcMakeVars # Make all path variables
if [ -z "$label" ]; then
continue;
fi
if (( lastProcessingEchoedNL == 0 )); then if (( lastProcessingEchoedNL == 0 )); then
echo # create a newline to separate output echo # create a newline to separate output
lastProcessingEchoedNL=1 lastProcessingEchoedNL=1
@ -471,6 +475,9 @@ function funcGetLabel {
# Set all variables for the current file # Set all variables for the current file
function funcMakeVars { function funcMakeVars {
local error;
error=false;
# This contains the OTR name of the file (e.g. Good_Wife_15.02.17_23-55_sixx_50_TVOON_DE.mpg.HQ.avi) # This contains the OTR name of the file (e.g. Good_Wife_15.02.17_23-55_sixx_50_TVOON_DE.mpg.HQ.avi)
funcLog 5 "filename: $filename" funcLog 5 "filename: $filename"
@ -499,20 +506,23 @@ function funcMakeVars {
sanename=$filename # Default value (in case of error) sanename=$filename # Default value (in case of error)
if [ ${#label2Dir[@]} -gt 0 -a "$label" != "N\\A" ]; then # if we want to use labels if [ ${#label2Dir[@]} -gt 0 -a "$label" != "N\\A" ]; then # if we want to use labels
if [ -z "$label" ]; then # don't allow empty labels if [ -z "$label" ]; then # don't allow empty labels
pathAbsOutDecoded="" error=true;
else else
pathAbsOutDecoded="${label2Dir["$label"]}" # get relative output directory for this label pathAbsOutDecoded="${label2Dir["$label"]}" # get relative output directory for this label
if [ -z "$pathAbsOutDecoded" ]; then if [ -z "$pathAbsOutDecoded" ]; then
funcLog 2 "Unrecognized label: $label" if $warnUnknownLabel; then
label="" funcLog 2 "Unknown label: $label"
pathAbsOutDecoded="" fi
error=true;
elif [ ${label2SaneRename["$label"]} -eq 1 ]; then # call SaneRenamix if indicated elif [ ${label2SaneRename["$label"]} -eq 1 ]; then # call SaneRenamix if indicated
tmp="$($cmdSaneRenamix $cmdSaneRenamixArgs $filename)" tmp="$($cmdSaneRenamix $cmdSaneRenamixArgs $filename)"
local err=$? local err=$?
error=true;
case $err in # return value conversion case $err in # return value conversion
0) 0)
bibname="${tmp%%..*}" bibname="${tmp%%..*}"
sanename="$tmp" sanename="$tmp"
error=false;
funcLog 5 "sanename: $sanename";; funcLog 5 "sanename: $sanename";;
1) 1)
funcLog 1 "SaneRenamix: General error!";; funcLog 1 "SaneRenamix: General error!";;
@ -539,28 +549,31 @@ function funcMakeVars {
fi fi
fi # if we do not want to use labels fi # if we do not want to use labels
if $error; then
label="";
else
# Save the insane filename in case saneRenamix did not work once before
if [ $sanename != $filename ]; then # No sanename
bibnameInsane=${filename%%_[0-9][0-9].*}
bibnameInsane="${bibnameInsane%%_S[0-9][0-9]E[0-9][0-9]}"
bibnameInsane="${bibnameInsane//_/.}"
pathAbsOutDecodedInsane="$outDir/$pathAbsOutDecoded/$bibnameInsane/$filename"
funcLog 5 "pathAbsOutDecodedInsane: $pathAbsOutDecodedInsane"
# Save the insane filename in case saneRenamix did not work once before pathAbsOutCutInsane="$pathAbsOutDecodedInsane$cutAppendix"
if [ $sanename != $filename ]; then # No sanename funcLog 5 "pathAbsOutCutInsane: $pathAbsOutCutInsane"
bibnameInsane=${filename%%_[0-9][0-9].*} fi
bibnameInsane="${bibnameInsane%%_S[0-9][0-9]E[0-9][0-9]}"
bibnameInsane="${bibnameInsane//_/.}"
pathAbsOutDecodedInsane="$outDir/$pathAbsOutDecoded/$bibnameInsane/$filename"
funcLog 5 "pathAbsOutDecodedInsane: $pathAbsOutDecodedInsane"
pathAbsOutCutInsane="$pathAbsOutDecodedInsane$cutAppendix" pathAbsOutDecoded="$pathAbsOutDecoded/$bibname" # Append bibname: This is the series name or the movie name (Kodi likes this)
funcLog 5 "pathAbsOutCutInsane: $pathAbsOutCutInsane"
# 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"
funcLog 5 "pathAbsOutDecoded: $pathAbsOutDecoded"
# This will be the absolute path to the cut output file (e.g. /final/Good.Wife/Good.Wife..S05E14..Ein.paar.Worte.HQ.avi-cut.mkv)
pathAbsOutCut="$pathAbsOutDecoded$cutAppendix"
funcLog 5 "pathAbsOutCut: $pathAbsOutCut"
fi fi
pathAbsOutDecoded="$pathAbsOutDecoded/$bibname" # Append bibname: This is the series name or the movie name (Kodi likes this)
# 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"
funcLog 5 "pathAbsOutDecoded: $pathAbsOutDecoded"
# This will be the absolute path to the cut output file (e.g. /final/Good.Wife/Good.Wife..S05E14..Ein.paar.Worte.HQ.avi-cut.mkv)
pathAbsOutCut="$pathAbsOutDecoded$cutAppendix"
funcLog 5 "pathAbsOutCut: $pathAbsOutCut"
} }
# Do the decoding stuff: Call decoder # Do the decoding stuff: Call decoder