mirror of
https://github.com/Jonny007-MKD/OTR-SaneRename
synced 2025-01-22 08:49:48 +01:00
Move everything into functions to clean it up.
Main function: doIt()
This commit is contained in:
parent
8eb8d5f1da
commit
e8e74d8e69
1 changed files with 241 additions and 204 deletions
437
saneRenamix.sh
437
saneRenamix.sh
|
@ -1,9 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
# TODO: Umlaute werden beim Download der xml über alle serien nicht richtig übergeben. evtl mit %-Code arbeiten
|
# TODO: Umlaute werden beim Download der xml über alle serien nicht richtig übergeben. evtl mit %-Code arbeiten
|
||||||
|
|
||||||
### CONFIG ###
|
##########
|
||||||
|
# Config #
|
||||||
|
##########
|
||||||
apikey="2C9BB45EFB08AD3B"
|
apikey="2C9BB45EFB08AD3B"
|
||||||
productname="SaneRename for OTR (ALPHA) v0.2"
|
productname="SaneRename for OTR (ALPHA) v0.2"
|
||||||
|
lang="de"
|
||||||
|
|
||||||
|
|
||||||
|
##########
|
||||||
|
# Script #
|
||||||
|
##########
|
||||||
|
|
||||||
|
# Print only of not silent
|
||||||
function eecho {
|
function eecho {
|
||||||
if [ -z "$silent" ]; then
|
if [ -z "$silent" ]; then
|
||||||
echo "$1" "$2" "$3"
|
echo "$1" "$2" "$3"
|
||||||
|
@ -11,233 +22,259 @@ function eecho {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### Check input ###
|
|
||||||
while getopts "f:l:s" optval; do
|
|
||||||
case $optval in
|
|
||||||
"f")
|
|
||||||
path=$OPTARG;;
|
|
||||||
"s")
|
|
||||||
silent=1;;
|
|
||||||
"l")
|
|
||||||
lang="$OPTARG";;
|
|
||||||
"?")
|
|
||||||
echo "Usage: $0 -f pathToAvi [-s] [-l LANG]"
|
|
||||||
exit;;
|
|
||||||
":")
|
|
||||||
echo "No argument value for option $OPTARG"
|
|
||||||
exit;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
eecho " :: $productname"
|
# Parse the parameters
|
||||||
eecho " :: by Leroy Foerster"
|
function funcParam {
|
||||||
eecho
|
while getopts "f:l:s" optval; do
|
||||||
|
case $optval in
|
||||||
|
"f") # Path to file
|
||||||
|
path="$OPTARG";;
|
||||||
|
"s") # Silent switch
|
||||||
|
silent=1;;
|
||||||
|
"l") # Language
|
||||||
|
case "$OPTARG" in
|
||||||
|
de*)
|
||||||
|
lang="de";;
|
||||||
|
en*)
|
||||||
|
lang="en";;
|
||||||
|
us*)
|
||||||
|
lang="en";;
|
||||||
|
fr*)
|
||||||
|
lang="fr";;
|
||||||
|
*)
|
||||||
|
echo "Language not recognized: $OPTARG"
|
||||||
|
exit 11;;
|
||||||
|
esac;;
|
||||||
|
"?") # Help
|
||||||
|
echo "Usage: $0 -f pathToAvi [-s] [-l LANG]"
|
||||||
|
exit;;
|
||||||
|
":")
|
||||||
|
echo "No argument value for option $OPTARG"
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Print the header
|
||||||
|
function funcHeader {
|
||||||
|
eecho " :: $productname"
|
||||||
|
eecho " :: by Leroy Foerster"
|
||||||
|
eecho
|
||||||
|
}
|
||||||
|
|
||||||
if [ -z "$path" ]; then
|
# Get title, date and time
|
||||||
echo "Usage: $0 -f pathToAvi [-s] [-l LANG]"
|
function funcAnalyzeFilename {
|
||||||
exit
|
# Split filename into words, divided by _ (underscores)
|
||||||
fi
|
file="${file_name//_/ }"
|
||||||
|
|
||||||
case "$lang" in
|
firstField="${file%% *}" # Get the first word
|
||||||
de*)
|
test $firstField -eq 0 2>/dev/null # If first word is a number -> cutlist id
|
||||||
lang="de";;
|
if [ $? -ne 2 ]; then
|
||||||
en*)
|
file=${file##$firstField } # remove it
|
||||||
lang="en";;
|
fi
|
||||||
us*)
|
|
||||||
lang="en";;
|
|
||||||
fr*)
|
|
||||||
lang="fr";;
|
|
||||||
"")
|
|
||||||
lang="de";;
|
|
||||||
*)
|
|
||||||
echo "Language not recognized: $lang"
|
|
||||||
exit 11;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
PwD=$(readlink -e $0)
|
file_title=${file%% [0-9][0-9].*} # Cut off everything after the title: date, hour, sender, ...
|
||||||
PwD=$(dirname "$PwD")
|
file_sender=${file##*-[0-9][0-9]} # Cut off everything bevor the sender: title, date, time, ...
|
||||||
|
|
||||||
file_name="$(basename $path)"
|
file_date=${file%%$file_sender} # Cut off the sender
|
||||||
file_suffix="${file_name##*.}"
|
file_date=${file_date##$file_title } # Cut off the title, now we do have the date and time
|
||||||
file_dir="$(dirname $path)"
|
file_time=${file_date##* }
|
||||||
|
file_date=${file_date%% *}
|
||||||
|
|
||||||
if [ ! -f "$path" ]; then
|
file_dateInv=$(date +%d.%m.%Y --date="${file_date//./-}") # Convert YY.MM.DD to DD.MM.YY
|
||||||
echo "This is no file!"
|
file_time=${file_time/-/:} # Convert HH-MM to HH:MM
|
||||||
echo "$path"
|
|
||||||
exit 10
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
file_title=${file_title// s /\'s } # Replace a single s with 's
|
||||||
|
if [ "$lang" == "de" ]; then
|
||||||
|
file_title=${file_title//Ae/Ä} # Replace umlauts
|
||||||
|
file_title=${file_title//Oe/Ö}
|
||||||
|
file_title=${file_title//Ue/Ü}
|
||||||
|
file_title=${file_title//ae/ä}
|
||||||
|
file_title=${file_title//oe/ö}
|
||||||
|
file_title=${file_title//ue/ü}
|
||||||
|
fi
|
||||||
|
|
||||||
# Split filename into fields, divided by _ (underscores)
|
eecho -e " Work dir:\t$PwD"
|
||||||
|
eecho -e " Datum:\t$file_dateInv"
|
||||||
|
eecho -e " Uhrzeit:\t$file_time"
|
||||||
|
eecho -e " Titel:\t$file_title"
|
||||||
|
}
|
||||||
|
|
||||||
fields="${file_name//_/ }"
|
# Get the series ID from TvDB (needed to fetch episodes from TvDB)
|
||||||
|
function funcGetSeriesId {
|
||||||
|
if [ -f "$PwD/series.cache" ]; then # Search the series cache
|
||||||
|
series_id=$(grep "$file_title" "$PwD/series.cache");
|
||||||
|
fi
|
||||||
|
if [ -n "$series_id" ]; then # And get the TvDB series ID from there
|
||||||
|
series_title=${series_id%|#|*}
|
||||||
|
series_id=${series_id#*|#|}
|
||||||
|
eecho -e " Cache:\tSeries found.\tID: $series_id"
|
||||||
|
else # Otherwise ask TvDB whether they do know the series
|
||||||
|
# ------------ Series ID abrufen anhand vom Titel der Serie -------------------- ;;
|
||||||
|
series_db="https://www.thetvdb.com/api/GetSeries.php?seriesname=${file_title}&language=$lang"
|
||||||
|
wget "$series_db" -O "$PwD/series.xml" -o /dev/null
|
||||||
|
error=$?
|
||||||
|
if [ $error -ne 0 ]; then
|
||||||
|
eecho "Downloading $series_db failed (Exit code: $error)!"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
# If first field is a number (cutlist id)
|
series_id=$(grep -m 1 "seriesid" "$PwD/series.xml")
|
||||||
firstField="${fields%% *}"
|
if [ -z "$series_id" ]; then
|
||||||
test $firstField -eq 0 2>/dev/null
|
eecho -e " TVDB:\tSeries NOT found!"
|
||||||
if [ $? -ne 2 ]; then
|
exit 3
|
||||||
fields=${fields##$firstField }
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
fieldsTitle=${fields%% [0-9][0-9].*} # Cut off everything after the title: date, hour, sender, ...
|
series_title=$(grep -m 1 "SeriesName" "$PwD/series.xml") # Get series name from TvDB (for user)
|
||||||
fieldsSender=${fields##*-[0-9][0-9]} # Cut off everything bevor the sender: title, date, time, ...
|
series_alias=$(grep -m 1 "AliasName" "$PwD/series.xml")
|
||||||
|
series_id=${series_id%<*} # Remove XML tags
|
||||||
|
series_id=${series_id#*>}
|
||||||
|
series_title=${series_title%<*}
|
||||||
|
series_title=${series_title#*>}
|
||||||
|
series_alias=${series_alias%<*}
|
||||||
|
series_alias=${series_alias#*>}
|
||||||
|
|
||||||
fieldsDate=${fields%%$fieldsSender} # Cut off the sender
|
echo "$series_title|#|$series_id" >> "$PwD/series.cache"
|
||||||
fieldsDate=${fieldsDate##$fieldsTitle } # Cut off the title, now we do have the date and time
|
eecho -e " TVDB:\tSeries found.\tID: $series_id"
|
||||||
fieldsTime=${fieldsDate##* }
|
fi
|
||||||
fieldsDate=${fieldsDate%% *}
|
eecho -e "\t\t\t\tName: $series_title"
|
||||||
|
if [ -n "$series_alias" ]; then
|
||||||
|
eecho -e "\t\t\t\tAlias: $series_alias"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
fieldsDateInv=$(date +%d.%m.%Y --date="${fieldsDate//./-}") # Convert YY.MM.DD to DD.MM.YY
|
# Get the EPG from OnlineTvRecorder and get the title of the episode
|
||||||
fieldsTime=${fieldsTime/-/:} # Convert HH-MM to HH:MM
|
function funcGetEPG {
|
||||||
|
# Download OTR EPG data and search for series and time
|
||||||
|
if [ ! -f "$PwD/epg-${file_date}.csv" ]; then # This file does not exist
|
||||||
|
rm -f ${PwD// /\\ }/epg-*.csv 2> /dev/null # Delete all old files
|
||||||
|
epg_csv="https://www.onlinetvrecorder.com/epg/csv/epg_20${file_date//./_}.csv"
|
||||||
|
wget "$epg_csv" -O "$PwD/epg-${file_date}.csv" -o /dev/null # Download the csv
|
||||||
|
error=$?
|
||||||
|
if [ $error -ne 0 ]; then
|
||||||
|
eecho "Downloading $epg_csv failed (Exit code: $error)!"
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
fieldsTitle=${fieldsTitle// s /\'s } # Replace a single s with 's
|
epg="$(grep "$series_title" "$PwD/epg-${file_date}.csv" | grep "${file_time}")" # Get the line with the movie
|
||||||
if [ "$lang" == "de" ]; then
|
if [ -z "$epg" ]; then
|
||||||
fieldsTitle=${fieldsTitle//Ae/Ä} # Replace Umlauts
|
eecho -e " EPG:\tSeries not found in EPG data" # This cannot happen :)
|
||||||
fieldsTitle=${fieldsTitle//Oe/Ö}
|
exit 5
|
||||||
fieldsTitle=${fieldsTitle//Ue/Ü}
|
fi
|
||||||
fieldsTitle=${fieldsTitle//ae/ä}
|
|
||||||
fieldsTitle=${fieldsTitle//oe/ö}
|
|
||||||
fieldsTitle=${fieldsTitle//ue/ü}
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Parse EPG data using read
|
||||||
|
OLDIFS=$IFS
|
||||||
|
IFS=";"
|
||||||
|
read epg_id epg_start epg_end epg_duration epg_sender epg_title epg_type epg_text epg_genre epg_fsk epg_language epg_weekday epg_additional epg_rpt epg_downloadlink epg_infolink epg_programlink <<< "$epg"
|
||||||
|
IFS=$OLDIFS
|
||||||
|
}
|
||||||
|
|
||||||
eecho -e " Work dir:\t$PwD"
|
# Get the title of the episode from description in EPG using $1 as delimiter to the real description
|
||||||
eecho -e " Datum:\t$fieldsDateInv"
|
function funcGetEpgEpisodeTitle {
|
||||||
eecho -e " Uhrzeit:\t$fieldsTime"
|
episode_title="${epg_text%%$1*}" # Text begins with episode title, cut off the rest
|
||||||
eecho -e " Titel:\t$fieldsTitle"
|
if [ -z "$episode_title" ]; then
|
||||||
|
eecho -e " EPG:\tNo Episode title found"
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
eecho -e " EPG:\tEpisode title:\t$episode_title" # We found some title :)
|
||||||
|
}
|
||||||
|
|
||||||
if [ -f "$PwD/series.cache" ]; then # Search the series cache
|
function funcGetEpisodes {
|
||||||
series_id=$(grep "fieldsTitle" "$PwD/series.cache");
|
# Download Episode list of series
|
||||||
fi
|
episode_db="https://www.thetvdb.com/api/$apikey/series/$series_id/all/$lang.xml"
|
||||||
if [ -n "$series_id" ]; then # And get the TvDB series ID from there
|
wget $episode_db -O "$PwD/episodes.xml" -o /dev/null
|
||||||
series_title=${series_id%|#|*}
|
|
||||||
series_id=${series_id#*|#|}
|
|
||||||
eecho -e " Cache:\tSeries found.\tID: $series_id"
|
|
||||||
else # Otherwise ask TvDB whether they do know the series
|
|
||||||
# ------------ Series ID abrufen anhand vom Titel der Serie -------------------- ;;
|
|
||||||
series_db="https://www.thetvdb.com/api/GetSeries.php?seriesname=$fieldsTitle&language=$lang"
|
|
||||||
wget "$series_db" -O "$PwD/series.xml" -o /dev/null
|
|
||||||
error=$?
|
error=$?
|
||||||
if [ $error -ne 0 ]; then
|
if [ $error -ne 0 ]; then
|
||||||
eecho "Downloading $series_db failed (Exit code: $error)!"
|
eecho "Downloading $episode_db failed (Exit code: $error)!"
|
||||||
exit 2
|
exit 6
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
series_id=$(grep -m 1 "seriesid" "$PwD/series.xml") # Get series id (needed later)
|
function funcGetEpisodeInfo {
|
||||||
if [ -z "$series_id" ]; then
|
while true; do
|
||||||
eecho -e " TVDB:\tSeries NOT found!"
|
episode_info=$(grep "Name>$episode_title" "$PwD/episodes.xml" -B 10) # Get XML data of episode
|
||||||
exit 3
|
if [ -z "$episode_info" ]; then # Nothing found. Shorten the title
|
||||||
fi
|
tmp=${episode_title% *}
|
||||||
|
if [ ${#episode_title} -le 4 ] || [ "$tmp" == "$episode_title" ]; then
|
||||||
series_title=$(grep -m 1 "SeriesName" "$PwD/series.xml") # Get series name from TvDB (for user)
|
break;
|
||||||
series_alias=$(grep -m 1 "AliasName" "$PwD/series.xml")
|
fi
|
||||||
series_id=${series_id%<*} # Remove XML tags
|
episode_title="$tmp"
|
||||||
series_id=${series_id#*>}
|
eecho -e " EPG:\tEpisode title:\t$episode_title"
|
||||||
series_title=${series_title%<*}
|
else
|
||||||
series_title=${series_title#*>}
|
|
||||||
series_alias=${series_alias%<*}
|
|
||||||
series_alias=${series_alias#*>}
|
|
||||||
|
|
||||||
echo "$series_title|#|$series_id" >> "$PwD/series.cache"
|
|
||||||
eecho -e " TVDB:\tSeries found.\tID: $series_id"
|
|
||||||
fi
|
|
||||||
eecho -e "\t\t\t\tName: $series_title"
|
|
||||||
if [ -n "$series_alias" ]; then
|
|
||||||
eecho -e "\t\t\t\tAlias: $series_alias"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# ------------ EPG vom jeweiligen Tag herunterladen, durchsuchen anhand der Ausstrahlungszeit ------------- ;;
|
|
||||||
# Download OTR EPG data and search for series and time
|
|
||||||
if [ ! -f "$PwD/epg-$fieldsDate.csv" ]; then # didnt cache this file
|
|
||||||
rm -f ${PwD// /\\ }/epg-*.csv 2> /dev/null
|
|
||||||
epg_csv="https://www.onlinetvrecorder.com/epg/csv/epg_20${fieldsDate//./_}.csv"
|
|
||||||
wget "$epg_csv" -O "$PwD/epg-$fieldsDate.csv" -o /dev/null
|
|
||||||
error=$?
|
|
||||||
if [ $error -ne 0 ]; then
|
|
||||||
eecho "Downloading $epg_csv failed (Exit code: $error)!"
|
|
||||||
exit 4
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
epg="$(grep "$series_title" "$PwD/epg-$fieldsDate.csv" | grep "$fieldsTime")"
|
|
||||||
if [ -z "$epg" ]; then
|
|
||||||
eecho " EPG:\tSeries not found in EPG data"
|
|
||||||
exit 5
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Parse EPG data
|
|
||||||
OLDIFS=$IFS
|
|
||||||
IFS=";"
|
|
||||||
read epg_id epg_start epg_end epg_duration epg_sender epg_title epg_type epg_text epg_genre epg_fsk epg_language epg_weekday epg_additional epg_rpt epg_downloadlink epg_infolink epg_programlink <<< "$epg"
|
|
||||||
IFS=$OLDIFS
|
|
||||||
|
|
||||||
|
|
||||||
episode_title="${epg_text%%.*}" # Text begins with episode title
|
|
||||||
if [ -z "$episode_title" ]; then
|
|
||||||
eecho " EPG:\tNo Episode title found"
|
|
||||||
exit 5
|
|
||||||
fi
|
|
||||||
eecho -e " EPG:\tEpisode title:\t$episode_title"
|
|
||||||
|
|
||||||
|
|
||||||
# Download Episode list of series
|
|
||||||
episode_db="https://www.thetvdb.com/api/$apikey/series/$series_id/all/$lang.xml"
|
|
||||||
wget $episode_db -O "$PwD/episodes.xml" -o /dev/null
|
|
||||||
error=$?
|
|
||||||
if [ $error -ne 0 ]; then
|
|
||||||
eecho "Downloading $episode_db failed (Exit code: $error)!"
|
|
||||||
exit 6
|
|
||||||
fi
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
episode_info=$(grep "Name>$episode_title" "$PwD/episodes.xml" -B 10) # Get XML data of episode
|
|
||||||
if [ -z "$episode_info" ]; then
|
|
||||||
episode_title=${episode_title% *}
|
|
||||||
if [ ${#episode_title} -le 4 ]; then
|
|
||||||
break;
|
break;
|
||||||
fi
|
fi
|
||||||
eecho -e " EPG:\tEpisode title:\t$episode_title"
|
done
|
||||||
else
|
|
||||||
break;
|
if [ -n "$episode_info" ]; then # If we have found something
|
||||||
|
episode_number=$(echo -e "$episode_info" | grep -m 1 "Combined_episodenumber") # Get episode number
|
||||||
|
episode_season=$(echo -e "$episode_info" | grep -m 1 "Combined_season") # Get season number
|
||||||
|
episode_title=$(echo -e "$episode_info" | grep -m 1 "EpisodeName") # Get season name
|
||||||
|
episode_number=${episode_number%<*} # remove xml tags
|
||||||
|
episode_number=${episode_number#*>}
|
||||||
|
episode_season=${episode_season%<*}
|
||||||
|
episode_season=${episode_season#*>}
|
||||||
|
episode_title=${episode_title%<*}
|
||||||
|
episode_title=${episode_title#*>}
|
||||||
|
if [[ "$episode_number" == *.* ]]; then # Convert float to integer. Float!?
|
||||||
|
episode_number=${episode_number%%.*}
|
||||||
|
fi
|
||||||
|
if [[ "$episode_season" == *.* ]]; then
|
||||||
|
episode_season=${episode_number%%.*}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $episode_number -le 9 ]; then # add leading zero
|
||||||
|
episode_number="0$episode_number"
|
||||||
|
fi
|
||||||
|
if [ $episode_season -le 9 ]; then
|
||||||
|
episode_season="0$episode_season"
|
||||||
|
fi
|
||||||
|
|
||||||
|
eecho -e " TvDB:\tSeason:\t$episode_season"
|
||||||
|
eecho -e " \tEpisode:\t$episode_number"
|
||||||
fi
|
fi
|
||||||
done
|
}
|
||||||
if [ -z "$episode_info" ]; then
|
|
||||||
echo "No episode info found"
|
|
||||||
exit 13
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
function doIt {
|
||||||
|
funcHeader
|
||||||
|
|
||||||
episode_number=$(echo -e "$episode_info" | grep -m 1 "Combined_episodenumber") # Get episode number
|
if [ -z "$path" ]; then # If no path was specified (-f)
|
||||||
episode_season=$(echo -e "$episode_info" | grep -m 1 "Combined_season") # Get season number
|
echo "Usage: $0 -f pathToAvi [-s] [-l LANG]"
|
||||||
episode_title=$(echo -e "$episode_info" | grep -m 1 "EpisodeName") # Get season name
|
exit 15
|
||||||
episode_number=${episode_number%<*} # remove xml tags
|
fi
|
||||||
episode_number=${episode_number#*>}
|
|
||||||
episode_season=${episode_season%<*}
|
|
||||||
episode_season=${episode_season#*>}
|
|
||||||
episode_season=${episode_season%<*}
|
|
||||||
episode_title=${episode_title%<*}
|
|
||||||
episode_title=${episode_title#*>}
|
|
||||||
episode_season=${episode_season#*>}
|
|
||||||
if [[ "$episode_number" == *.* ]]; then # Convert float to integer. Float!?
|
|
||||||
episode_number=${episode_number%%.*}
|
|
||||||
fi
|
|
||||||
if [[ "$episode_season" == *.* ]]; then
|
|
||||||
episode_season=${episode_number%%.*}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# add leading zero
|
if [ ! -f "$path" ]; then # If the path is no regular file
|
||||||
if [ $episode_number -le 9 ]; then
|
echo "This is no file!"
|
||||||
episode_number="0$episode_number"
|
echo "$path"
|
||||||
fi
|
exit 10
|
||||||
if [ $episode_season -le 9 ]; then
|
fi
|
||||||
episode_season="0$episode_season"
|
|
||||||
fi
|
|
||||||
|
|
||||||
eecho -e " TvDB: Season:\t$episode_season"
|
PwD=$(readlink -e $0) # Get the path to this script
|
||||||
eecho -e " Episode:\t$episode_number"
|
PwD=$(dirname "$PwD")
|
||||||
|
|
||||||
echo "${series_title// /.}..S${episode_season}E${episode_number}..${episode_title// /.}.$file_suffix"
|
file_name="$(basename $path)" # Get file name
|
||||||
|
file_suffix="${file_name##*.}" # Get file suffix
|
||||||
|
file_dir="$(dirname $path)" # Get file directory
|
||||||
|
|
||||||
|
funcAnalyzeFilename # Get info from $file_name
|
||||||
|
funcGetSeriesId # Get series ID from cache or TvDB
|
||||||
|
funcGetEPG # Download epg file
|
||||||
|
funcGetEpgEpisodeTitle "." # Get the episode title using . as delimiter
|
||||||
|
funcGetEpisodes # Download episodes file
|
||||||
|
funcGetEpisodeInfo
|
||||||
|
|
||||||
|
if [ -z "$episode_info" ]; then # No info found!
|
||||||
|
funcGetEpgEpisodeTitle "," # Try again with , as delimiter
|
||||||
|
funcGetEpisodeInfo
|
||||||
|
if [ -z "$episode_info" ]; then # Again no info found!
|
||||||
|
echo "No episode info found!"
|
||||||
|
exit 20
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${series_title// /.}..S${episode_season}E${episode_number}..${episode_title// /.}.$file_suffix"
|
||||||
|
}
|
||||||
|
|
||||||
|
funcParam $@
|
||||||
|
doIt
|
Loading…
Reference in a new issue