mirror of
https://github.com/Jonny007-MKD/OTR-SaneRename
synced 2025-01-22 08:49:48 +01:00
Introduced caching for episodes
Replace umlauts in the final filename
This commit is contained in:
parent
3f2427835e
commit
e97e2d8e46
1 changed files with 27 additions and 18 deletions
|
@ -231,9 +231,10 @@ function funcGetEpgEpisodeTitle {
|
||||||
|
|
||||||
# Download episodes list from TvDB, language as argument
|
# Download episodes list from TvDB, language as argument
|
||||||
function funcGetEpisodes {
|
function funcGetEpisodes {
|
||||||
|
wget_file="$PwD/episodes-${series_id}.xml"
|
||||||
|
if [ ! -f "$wget_file" ]; then
|
||||||
# Download Episode list of series
|
# Download Episode list of series
|
||||||
episode_db="https://www.thetvdb.com/api/$apikey/series/$series_id/all/$1.xml"
|
episode_db="https://www.thetvdb.com/api/$apikey/series/$series_id/all/$1.xml"
|
||||||
wget_file="$PwD/episodes.xml"
|
|
||||||
wget_running=true;
|
wget_running=true;
|
||||||
wget $episode_db -O "$wget_file" -o /dev/null
|
wget $episode_db -O "$wget_file" -o /dev/null
|
||||||
wget_running=false;
|
wget_running=false;
|
||||||
|
@ -242,12 +243,13 @@ function funcGetEpisodes {
|
||||||
eecho "Downloading $episode_db failed (Exit code: $error)!"
|
eecho "Downloading $episode_db failed (Exit code: $error)!"
|
||||||
exit 6
|
exit 6
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the information from episodes list of TvDB
|
# Get the information from episodes list of TvDB
|
||||||
function funcGetEpisodeInfo {
|
function funcGetEpisodeInfo {
|
||||||
while true; do
|
while true; do
|
||||||
episode_info=$(grep "Name>$episode_title" "$PwD/episodes.xml" -B 10) # Get XML data of episode
|
episode_info=$(grep "Name>$episode_title" "$PwD/episodes-${series_id}.xml" -B 10) # Get XML data of episode
|
||||||
if [ -z "$episode_info" ]; then # Nothing found. Shorten the title
|
if [ -z "$episode_info" ]; then # Nothing found. Shorten the title
|
||||||
tmp=${episode_title% *}
|
tmp=${episode_title% *}
|
||||||
if [ ${#tmp} -le 4 ] || [ "$tmp" == "$episode_title" ]; then
|
if [ ${#tmp} -le 4 ] || [ "$tmp" == "$episode_title" ]; then
|
||||||
|
@ -290,6 +292,19 @@ function funcGetEpisodeInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function funcMakeFilename {
|
||||||
|
if [ "$lang" == "de" ]; then
|
||||||
|
episode_title=${episode_title//Ä/Ae} # Replace umlauts
|
||||||
|
episode_title=${episode_title//Ö/Oe}
|
||||||
|
episode_title=${episode_title//Ü/Ue}
|
||||||
|
episode_title=${episode_title//ä/ae}
|
||||||
|
episode_title=${episode_title//ö/oe}
|
||||||
|
episode_title=${episode_title//ü/ue}
|
||||||
|
fi
|
||||||
|
echo "${series_title// /.}..S${episode_season}E${episode_number}..${episode_title// /.}.$file_suffix"
|
||||||
|
}
|
||||||
|
|
||||||
# This function does everything
|
# This function does everything
|
||||||
function doIt {
|
function doIt {
|
||||||
funcHeader
|
funcHeader
|
||||||
|
@ -299,12 +314,6 @@ function doIt {
|
||||||
exit 15
|
exit 15
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$path" ]; then # If the path is no regular file
|
|
||||||
echo "This is no file!"
|
|
||||||
echo "$path"
|
|
||||||
exit 10
|
|
||||||
fi
|
|
||||||
|
|
||||||
PwD=$(readlink -e $0) # Get the path to this script
|
PwD=$(readlink -e $0) # Get the path to this script
|
||||||
PwD=$(dirname "$PwD")
|
PwD=$(dirname "$PwD")
|
||||||
|
|
||||||
|
@ -337,7 +346,7 @@ function doIt {
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$episode_info" ]; then
|
if [ -n "$episode_info" ]; then
|
||||||
echo "${series_title// /.}..S${episode_season}E${episode_number}..${episode_title// /.}.$file_suffix"
|
funcMakeFilename
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue