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

Introduced caching for episodes

Replace umlauts in the final filename
This commit is contained in:
Jonny007-MKD 2014-07-31 20:42:42 +02:00
parent 3f2427835e
commit e97e2d8e46

View file

@ -231,23 +231,25 @@ function funcGetEpgEpisodeTitle {
# Download episodes list from TvDB, language as argument # Download episodes list from TvDB, language as argument
function funcGetEpisodes { function funcGetEpisodes {
# Download Episode list of series wget_file="$PwD/episodes-${series_id}.xml"
episode_db="https://www.thetvdb.com/api/$apikey/series/$series_id/all/$1.xml" if [ ! -f "$wget_file" ]; then
wget_file="$PwD/episodes.xml" # Download Episode list of series
wget_running=true; episode_db="https://www.thetvdb.com/api/$apikey/series/$series_id/all/$1.xml"
wget $episode_db -O "$wget_file" -o /dev/null wget_running=true;
wget_running=false; wget $episode_db -O "$wget_file" -o /dev/null
error=$? wget_running=false;
if [ $error -ne 0 ]; then error=$?
eecho "Downloading $episode_db failed (Exit code: $error)!" if [ $error -ne 0 ]; then
exit 6 eecho "Downloading $episode_db failed (Exit code: $error)!"
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
} }