mirror of
https://github.com/Jonny007-MKD/OTR-SaneRename
synced 2025-01-22 08:49:48 +01:00
Language appendix for episode xml
This commit is contained in:
parent
893742c49e
commit
95c32e74e6
1 changed files with 14 additions and 8 deletions
|
@ -260,8 +260,10 @@ function funcGetEPG {
|
||||||
if [ -f "$wget_file" ]; then
|
if [ -f "$wget_file" ]; then
|
||||||
wget_file_date=$(stat --format=%Y "$wget_file")
|
wget_file_date=$(stat --format=%Y "$wget_file")
|
||||||
if [ $(( $(date +%s) - $wget_file_date)) -gt $((60*60*24*7*2)) ]; then # if file is older than 2 weeks
|
if [ $(( $(date +%s) - $wget_file_date)) -gt $((60*60*24*7*2)) ]; then # if file is older than 2 weeks
|
||||||
|
#echo "Deleting file with timestamp $wget_file_date"
|
||||||
rm "$wget_file"
|
rm "$wget_file"
|
||||||
elif [ $(stat --format=%s "$wget_file") -eq 0 ]; then # if file is empty
|
elif [ $(stat --format=%s "$wget_file") -eq 0 ]; then # if file is empty
|
||||||
|
#echo "Deleting file with size $(stat --format=%s $wget_file)"
|
||||||
rm "$wget_file"
|
rm "$wget_file"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -320,7 +322,7 @@ 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"
|
wget_file="$PwD/episodes-${series_id}-${langCurrent}.xml"
|
||||||
if [ -f "$wget_file" ]; then
|
if [ -f "$wget_file" ]; then
|
||||||
wget_file_date=$(stat --format=%Y "$wget_file")
|
wget_file_date=$(stat --format=%Y "$wget_file")
|
||||||
if [ $(( $(date +%s) - $wget_file_date)) -gt $(( 60*60*24*7*2 )) ]; then # if file is older than 2 weeks
|
if [ $(( $(date +%s) - $wget_file_date)) -gt $(( 60*60*24*7*2 )) ]; then # if file is older than 2 weeks
|
||||||
|
@ -331,7 +333,7 @@ function funcGetEpisodes {
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$wget_file" ]; then
|
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/$langCurrent.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;
|
||||||
|
@ -356,7 +358,7 @@ function funcGetEpisodeInfo {
|
||||||
title1=false;
|
title1=false;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wget_file="$PwD/episodes-${series_id}.xml"
|
wget_file="$PwD/episodes-${series_id}-${langCurrent}.xml"
|
||||||
while true; do
|
while true; do
|
||||||
episode_info=$(grep -i "sodeName>$title" "$wget_file" -B 10) # Get XML data of episode
|
episode_info=$(grep -i "sodeName>$title" "$wget_file" -B 10) # Get XML data of episode
|
||||||
if [ -z "$episode_info" ]; then # Nothing found. Search the description
|
if [ -z "$episode_info" ]; then # Nothing found. Search the description
|
||||||
|
@ -470,20 +472,24 @@ function doIt {
|
||||||
episode_title_set=false
|
episode_title_set=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
doItEpisodes $lang # Search for the episode in the specified language
|
langCurrent="$lang"
|
||||||
|
doItEpisodes # Search for the episode in the specified language
|
||||||
if [ -z "$episode_info" ]; then # Episode was not found!
|
if [ -z "$episode_info" ]; then # Episode was not found!
|
||||||
if [ "$lang" != "en" ]; then
|
if [ "$lang" != "en" ]; then
|
||||||
doItEpisodes "en" # Try it again with english
|
langCurrent="en"
|
||||||
|
doItEpisodes # Try it again with english
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $episode_title_set && [ -z "$episode_info" ]; then # Episode was not found!
|
if $episode_title_set && [ -z "$episode_info" ]; then # Episode was not found!
|
||||||
episode_title_set=false # Do not use file name as episode title
|
episode_title_set=false # Do not use file name as episode title
|
||||||
funcGetEPG # Download epg file
|
funcGetEPG # Download epg file
|
||||||
doItEpisodes $lang # Search for the episode in the specified language and get title from EPG
|
langCurrent="$lang"
|
||||||
|
doItEpisodes # Search for the episode in the specified language and get title from EPG
|
||||||
if [ -z "$episode_info" ]; then # Episode was not found!
|
if [ -z "$episode_info" ]; then # Episode was not found!
|
||||||
if [ "$lang" != "en" ]; then
|
if [ "$lang" != "en" ]; then
|
||||||
doItEpisodes "en" # Try it again with english
|
langCurrent="en"
|
||||||
|
doItEpisodes # Try it again with english
|
||||||
fi
|
fi
|
||||||
if [ -z "$episode_info" ]; then # Again/still no info found! Damn :(
|
if [ -z "$episode_info" ]; then # Again/still no info found! Damn :(
|
||||||
eecho "No episode info found!"
|
eecho "No episode info found!"
|
||||||
|
@ -504,7 +510,7 @@ function doItEpisodes {
|
||||||
if ! $episode_title_set; then
|
if ! $episode_title_set; then
|
||||||
funcGetEpgEpisodeTitle "." # Get the episode title using . as delimiter
|
funcGetEpgEpisodeTitle "." # Get the episode title using . as delimiter
|
||||||
fi
|
fi
|
||||||
funcGetEpisodes $1 # Download episodes file
|
funcGetEpisodes # Download episodes file
|
||||||
if [ -n "$episode_title" ]; then
|
if [ -n "$episode_title" ]; then
|
||||||
funcGetEpisodeInfo
|
funcGetEpisodeInfo
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue