mirror of
https://github.com/Jonny007-MKD/OTR-SaneRename
synced 2025-01-22 08:49:48 +01:00
Better search for series name at TvDB (egrep)
This commit is contained in:
parent
037b36b4c0
commit
abb14b2aae
2 changed files with 18 additions and 23 deletions
|
@ -232,9 +232,7 @@ function funcGetSeriesIdFromTvdb {
|
||||||
if $debug; then echo -e "\033[36mfuncGetSeriesIdFromTvdb $1\033[37m"; fi;
|
if $debug; then echo -e "\033[36mfuncGetSeriesIdFromTvdb $1\033[37m"; fi;
|
||||||
local title;
|
local title;
|
||||||
local tmp;
|
local tmp;
|
||||||
local shorten;
|
|
||||||
title="$1";
|
title="$1";
|
||||||
shorten=false;
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
series_db="https://www.thetvdb.com/api/GetSeries.php?seriesname=${title}&language=$lang"
|
series_db="https://www.thetvdb.com/api/GetSeries.php?seriesname=${title}&language=$lang"
|
||||||
|
@ -249,11 +247,11 @@ function funcGetSeriesIdFromTvdb {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
tmp="$(grep -i -m 1 -B 3 -A 1 ">$title<" "$wget_file")"
|
tmp="$(grep -Ei -m 1 -B 3 -A 1 ">${title// /\\W+}<" "$wget_file")"
|
||||||
if [ ${#tmp} -eq 0 ]; then # No series with this name found
|
if [ ${#tmp} -eq 0 ]; then # No series with this name found
|
||||||
tmp="$(grep -Pzo "(?s)>langCurrent</language>\n<SeriesName>" "$wget_file")" # Let's get all series from the query
|
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 [ $(echo "$tmp" | wc -l) -eq 1 ]; then # If we only found one series
|
||||||
tmp="$(grep -Pzo "(?s)<Series>.*?$langCurrent</language>.*?</SeriesName>" "$wget_file")" # Lets use this one
|
tmp="$(grep -Pzo --binary-files=text "(?s)<Series>.*?$langCurrent</language>.*?</SeriesName>" "$wget_file")" # Lets use this one
|
||||||
else
|
else
|
||||||
eecho -e " TvDB: $(echo "$tmp" | wc -l) series found with this title ($title)"
|
eecho -e " TvDB: $(echo "$tmp" | wc -l) series found with this title ($title)"
|
||||||
logNexit 12
|
logNexit 12
|
||||||
|
@ -271,24 +269,19 @@ function funcGetSeriesIdFromTvdb {
|
||||||
series_alias=${series_alias%<*}
|
series_alias=${series_alias%<*}
|
||||||
series_alias=${series_alias#*>}
|
series_alias=${series_alias#*>}
|
||||||
|
|
||||||
echo "$file_title|_|$series_title_tvdb|#|$series_id" >> "$PwD/series.cache"
|
if [ -n "$series_id" -a -n "$series_title_tvdb" ]; then
|
||||||
eecho -e " TVDB:\tSeries found.\tID: $series_id"
|
echo "$file_title|_|$series_title_tvdb|#|$series_id" >> "$PwD/series.cache"
|
||||||
eecho -e " \t \tName: $series_title_tvdb"
|
eecho -e " TVDB:\tSeries found.\tID: $series_id"
|
||||||
|
eecho -e " \t \tName: $series_title_tvdb"
|
||||||
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $shorten; then
|
tmp="${title% *}" # Shorten the title by one word
|
||||||
title="${title//\*/ }" # Remove wildcards from current run
|
if [ ${#tmp} -le 4 ] || [ "$tmp" == "$title" ]; then # Too short or was not shortened
|
||||||
tmp="${title% *}" # Shorten the title by one word
|
break;
|
||||||
if [ ${#tmp} -le 4 ] || [ "$tmp" == "$title" ]; then # Too short or was not shortened
|
|
||||||
break;
|
|
||||||
fi
|
|
||||||
title="$(echo $tmp | sed -e 's/^[^a-zA-Z0-9]*//' -e 's/ *$//')"
|
|
||||||
shorten=false;
|
|
||||||
else
|
|
||||||
title="${title// /*}" # Replace spaces with wildcards
|
|
||||||
shorten=true;
|
|
||||||
fi
|
fi
|
||||||
|
title="$(echo $tmp | sed -e 's/^[^a-zA-Z0-9]*//' -e 's/ *$//')"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ files=(
|
||||||
["Good_Wife_15.03.11_00-40_sixx_40_TVOON_DE.mpg.HQ.avi.otrkey"]="Good.Wife..S05E22..Ein.seltsames.Jahr.otrkey"
|
["Good_Wife_15.03.11_00-40_sixx_40_TVOON_DE.mpg.HQ.avi.otrkey"]="Good.Wife..S05E22..Ein.seltsames.Jahr.otrkey"
|
||||||
# Use , as delimiter
|
# Use , as delimiter
|
||||||
["H2O_Ploetzlich_Meerjungfrau_15.02.28_11-55_orf1_30_TVOON_DE.mpg.avi.otrkey"]="H2O.-.Plötzlich.Meerjungfrau..S03E06..Bella.irrt.otrkey"
|
["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"
|
||||||
);
|
);
|
||||||
|
|
||||||
if [ -f test.sh ]; then
|
if [ -f test.sh ]; then
|
||||||
|
@ -52,12 +54,12 @@ for the_file in "${!files[@]}"; do
|
||||||
|
|
||||||
result="$($path/saneRenamix.sh $srArgs -s -f "$the_file")";
|
result="$($path/saneRenamix.sh $srArgs -s -f "$the_file")";
|
||||||
|
|
||||||
if [ -L $path/$epg_file ]; then # We have created it above
|
|
||||||
rm $path/$epg_file
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$result" != "${files["$the_file"]}" ]; then
|
if [ "$result" != "${files["$the_file"]}" ]; then
|
||||||
echo -e "\033[31m$the_file -> $result";
|
echo -e "\033[31m$the_file -> $result";
|
||||||
echo "'$result' != '${files[$the_file]}'";
|
echo "'$result' != '${files[$the_file]}'";
|
||||||
|
else
|
||||||
|
if [ -L $path/$epg_file ]; then # We have created it above
|
||||||
|
rm $path/$epg_file
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done;
|
done;
|
||||||
|
|
Loading…
Reference in a new issue