1
0
Fork 0
mirror of https://github.com/Jonny007-MKD/OTR-SaneRename synced 2024-05-10 22:14:03 +02:00
OTR-SaneRename/testing/test.sh

107 lines
3.4 KiB
Bash
Raw Permalink Normal View History

2014-10-30 08:49:07 +01:00
#!/bin/bash
# use first parameter to add parameters for sanerenamix
srArgs="$1"
2014-10-30 08:49:07 +01:00
2015-03-12 22:31:55 +01:00
declare -A files
2014-11-03 11:04:34 +01:00
files=(
2015-03-12 23:11:54 +01:00
# Nothing special
2020-04-03 22:20:16 +02:00
["Inspector_Barnaby_15.03.09_21-45_zdfneo_100_TVOON_DE.mpg.HQ.avi"]="Inspector.Barnaby..S07E02..Immer.wenn.der.Scherenschleifer....mpg.HQ.avi"
2015-03-12 23:11:54 +01:00
# Remove 3 words from the beginning and some from the end
2020-04-03 22:20:16 +02:00
["Bibi_Blocksberg_15.03.07_08-30_zdf_30_TVOON_DE.mpg.avi"]="Bibi.Blocksberg..S01E06..Bibi.im.Dschungel.mpg.avi"
2015-03-12 23:11:54 +01:00
# Use season and episode information from the beginning
2020-04-03 22:20:16 +02:00
["S05_E22_Good_Wife_15.03.11_00-40_sixx_40_TVOON_DE.mpg.HQ.avi"]="Good.Wife..S05E22..Ein.seltsames.Jahr.mpg.HQ.avi"
2015-04-06 23:01:10 +02:00
# Use season and episode information from the end
2020-04-03 22:20:16 +02:00
["Bibi_Blocksberg_S02E07_15.04.05_07-20_zdf_25_TVOON_DE.mpg.avi.otrkey"]="Bibi.Blocksberg..S02E07..Der.Hexengeburtstag.mpg.avi.otrkey"
2015-03-12 23:11:54 +01:00
# Cut 3 words from the end
2020-04-03 22:20:16 +02:00
["Good_Wife_15.03.11_00-40_sixx_40_TVOON_DE.mpg.HQ.avi.otrkey"]="Good.Wife..S05E22..Ein.seltsames.Jahr.mpg.HQ.avi.otrkey"
2015-03-12 23:11:54 +01:00
# Use , as delimiter
2020-04-03 22:20:16 +02:00
["H2O_Ploetzlich_Meerjungfrau_15.02.28_11-55_orf1_30_TVOON_DE.mpg.avi.otrkey"]="H2O.-.Plötzlich.Meerjungfrau..S03E06..Bella.irrt.mpg.avi.otrkey"
# Series and episode name in title
2020-04-03 22:20:16 +02:00
["Irene_Huss_Kripo_Goeteborg_Der_im_Dunkeln_wacht_S02E01_15.08.08_22-55_ard_90_TVOON_DE.mpg.HQ.avi"]="Irene.Huss,.Kripo.Göteborg..S02E01..Der.im.Dunkeln.wacht.mpg.HQ.avi"
# Difficult search for series
2020-04-03 22:20:16 +02:00
["Ein_Fall_fuer_TKKG_S01E01_15.11.16_13-20_kika_20_TVOON_DE.mpg.avi"]="Ein.Fall.für.TKKG..S01E01..Das.leere.Grab.im.Moor.mpg.avi"
2020-05-02 13:57:09 +02:00
# Take Season and Episode info from manual.json
["Die_Bruecke_Transit_in_den_Tod_18.09.22_00-45_zdf_115_TVOON_DE.mpg.HD.avi.otrkey"]="Die.Brücke..Transit.in.den.Tod..S01E01..Teil.1.mpg.HD.avi.otrkey"
2014-11-03 11:04:34 +01:00
);
2014-10-30 08:49:07 +01:00
2015-03-12 22:33:07 +01:00
if [ -f test.sh ]; then
path=".."
2015-03-12 22:33:07 +01:00
else
path="."
2015-03-12 22:33:07 +01:00
fi
2020-04-03 22:20:16 +02:00
if [ ! -f "$path/saneRenamix.py" ]; then
echo "saneRenamix.py not found!" >&2
2020-05-02 13:55:33 +02:00
exit 1
fi
2020-05-02 13:55:33 +02:00
function finish {
pushd $path
2020-05-02 13:57:09 +02:00
# Restore manual.json
if [ -f "manual.json.orig" ]; then
mv "manual.json.orig" "manual.json"
fi
2020-05-02 13:55:33 +02:00
# Restore *.cache
for f in `ls *.cache.orig`; do
mv "$f" "${f::-5}"
done
popd
}
trap finish EXIT
2020-05-02 13:55:33 +02:00
function init {
pushd $path
2020-05-02 13:57:09 +02:00
# Backup and replace manual.json
if [ -f "$path/manual.json" ]; then
mv "$path/manual.json" "$path/manual.json.orig"
fi
cp "$(dirname $0)/manual.json" "$path/manual.json"
2020-05-02 13:55:33 +02:00
# Remove caches
for f in `ls *.cache`; do
mv "$f" "$f.orig"
done
popd
}
2020-05-02 13:55:33 +02:00
function runTest {
for the_file in "${!files[@]}"; do
echo -e "\033[37m${the_file}";
2020-05-02 13:55:33 +02:00
file="${the_file//_/ }"
2020-05-02 13:55:33 +02:00
file_title=${file%% [0-9][0-9].*} # Cut off everything after the title: date, hour, sender, ...
file_sender=${file##*-[0-9][0-9]} # Cut off everything bevor the sender: title, date, time, ...
2020-05-02 13:55:33 +02:00
file_date=${file%%$file_sender} # Cut off the sender
file_date=${file_date##$file_title } # Cut off the title, now we do have the date and time
file_time=${file_date##* }
file_date=${file_date%% *}
2020-05-02 13:55:33 +02:00
epg_file="epg-$file_date.csv"
if ! [ -f $path/$epg_file ]; then # Create EPG file if neccessary
ln -s "testing/$epg_file" "$path/$epg_file"
fi
result="$(python3 $path/saneRenamix.py $srArgs -s -f "$the_file")";
if [ "$result" != "${files["$the_file"]}" ]; then
echo -e "\033[31m$the_file -> $result (cache)";
echo "'$result' != '${files[$the_file]}'";
else
if [ -L $path/$epg_file ]; then # We have created it above
rm $path/$epg_file
fi
fi
2020-05-02 13:55:33 +02:00
echo -ne "\033[37m"
read -p "ok. next? "
done;
}
2020-04-03 22:20:16 +02:00
2020-05-02 13:55:33 +02:00
init
runTest
runTest