1
0
Fork 0
mirror of https://github.com/Jonny007-MKD/OTR-SaneRename synced 2024-05-01 20:44:04 +02:00

Dont exit (12) 1st time TheTvDB returns too many series

This commit is contained in:
Jonny007-MKD 2015-11-25 08:46:00 +01:00
parent 4569f1e74a
commit d432c440a2
2 changed files with 16 additions and 5 deletions

View file

@ -186,11 +186,11 @@ function funcGetSeriesId {
fi
fi
if [ -z "$series_id" ]; then # Otherwise ask TvDB whether they do know the series
funcGetSeriesIdFromTvdb "$file_title"
funcGetSeriesIdFromTvdb "$file_title" false
fi
if [ -z "$series_id" ]; then # Otherwise ask TvDB with translation
funcConvertName "$file_title"
funcGetSeriesIdFromTvdb "$tmp"
funcGetSeriesIdFromTvdb "$tmp" true
fi
if [ -z "$series_id" ]; then # This series was not found anywhere :(
eecho -e " TVDB:\tSeries not found!"
@ -232,7 +232,9 @@ function funcGetSeriesIdFromTvdb {
if $debug; then echo -e "\033[36mfuncGetSeriesIdFromTvdb $1\033[37m"; fi;
local title;
local tmp;
local lastChance;
title="$1";
lastChance="$2";
while true; do
series_db="https://www.thetvdb.com/api/GetSeries.php?seriesname=${title}&language=$lang"
@ -247,14 +249,21 @@ function funcGetSeriesIdFromTvdb {
fi
if $debug; then echo -e "grep -Ei -m 1 -B 3 -A 1 \">${title// /\\W+}<\" \"$wget_file\")"; fi;
tmp="$(grep -Ei -m 1 -B 3 -A 1 ">${title// /\\W+}<" "$wget_file")"
if [ ${#tmp} -eq 0 ]; then # No series with this name found
tmp="$(grep -Pzo --binary-files=text "(?s)>langCurrent</language>\n<SeriesName>" "$wget_file")" # Let's get all series from the query
if $debug; then echo -e "grep -Pzo --binary-files=text \"(?s)>$langCurrent</language>\n<SeriesName>\" \"$wget_file\")"; fi;
tmp="$(grep -Pzo --binary-files=text "(?s)>$langCurrent</language>\n<SeriesName>" "$wget_file")" # Let's get all series from the query
if [ $(echo "$tmp" | wc -l) -eq 1 ]; then # If we only found one series
if $debug; then echo -e "grep -Pzo --binary-files=text \"(?s)<Series>.*?$langCurrent</language>.*?</SeriesName>\" \"$wget_file\")"; fi;
tmp="$(grep -Pzo --binary-files=text "(?s)<Series>.*?$langCurrent</language>.*?</SeriesName>" "$wget_file")" # Lets use this one
else
eecho -e " TvDB: $(echo "$tmp" | wc -l) series found with this title ($title)"
logNexit 12
eecho -e " TvDB: $(echo "$tmp" | wc -l) series found with title \"$title\""
if $lastChance; then # If we really had to find a value now
logNexit 12
else # If we may try something else
return
fi
fi
fi
if [ -n "$tmp" ]; then

View file

@ -20,6 +20,8 @@ files=(
["H2O_Ploetzlich_Meerjungfrau_15.02.28_11-55_orf1_30_TVOON_DE.mpg.avi.otrkey"]="H2O.-.Plötzlich.Meerjungfrau..S03E06..Bella.irrt.otrkey"
# Series and episode name in title
["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.HQ.avi"
# Difficult search for series
["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.avi"
);
if [ -f test.sh ]; then