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

Added debug output

This commit is contained in:
Jonny007-MKD 2014-10-29 13:01:39 +01:00
parent e1a8347765
commit a81962ad75

View file

@ -28,6 +28,7 @@
apikey="2C9BB45EFB08AD3B" apikey="2C9BB45EFB08AD3B"
productname="SaneRename for OTR (ALPHA) v0.3" productname="SaneRename for OTR (ALPHA) v0.3"
lang="de" lang="de"
debug=false
########## ##########
@ -61,8 +62,10 @@ wget_running=false;
# Parse the parameters # Parse the parameters
function funcParam { function funcParam {
while getopts "f:l:s" optval; do while getopts "df:l:s" optval; do
case $optval in case $optval in
"d") # Enable debugging
debug=true;;
"f") # Path to file "f") # Path to file
path="$OPTARG";; path="$OPTARG";;
"s") # Silent switch "s") # Silent switch
@ -100,6 +103,7 @@ function funcHeader {
# Get title, date and time # Get title, date and time
function funcAnalyzeFilename { function funcAnalyzeFilename {
if $debug; then echo -e "\033[36mfuncAnalyzeFilename\033[37m"; fi;
local tmp; local tmp;
# Split filename into words, divided by _ (underscores) # Split filename into words, divided by _ (underscores)
@ -138,6 +142,7 @@ function funcAnalyzeFilename {
} }
function funcConvertName { function funcConvertName {
if $debug; then echo -e "\033[36mfuncConvertName $1\033[37m"; fi;
tmp="$1" tmp="$1"
tmp=${tmp// s /\'s } # Replace a single s with 's tmp=${tmp// s /\'s } # Replace a single s with 's
if [ "$lang" == "de" ]; then if [ "$lang" == "de" ]; then
@ -152,6 +157,7 @@ function funcConvertName {
# Get the series ID from TvDB (needed to fetch episodes from TvDB) # Get the series ID from TvDB (needed to fetch episodes from TvDB)
function funcGetSeriesId { function funcGetSeriesId {
if $debug; then echo -e "\033[36mfuncGetSeriesId\033[37m"; fi;
local tmp; local tmp;
if [ -f "$PwD/series.cache" ]; then # Search the series cache if [ -f "$PwD/series.cache" ]; then # Search the series cache
funcGetSeriesIdFromCache "$file_title" funcGetSeriesIdFromCache "$file_title"
@ -178,6 +184,7 @@ function funcGetSeriesId {
# Search the series.cache file for this series and get TvDB series id # Search the series.cache file for this series and get TvDB series id
function funcGetSeriesIdFromCache { function funcGetSeriesIdFromCache {
if $debug; then echo -e "\033[36mfuncGetSeriesIdFromCache $1\033[37m"; fi;
local title; local title;
local tmp; local tmp;
title="$1"; title="$1";
@ -202,6 +209,7 @@ function funcGetSeriesIdFromCache {
# Search the TvDB for this series and get TvDB series id # Search the TvDB for this series and get TvDB series id
function funcGetSeriesIdFromTvdb { function funcGetSeriesIdFromTvdb {
if $debug; then echo -e "\033[36mfuncGetSeriesIdFromTvdb $1\033[37m"; fi;
local title; local title;
local tmp; local tmp;
title="$1"; title="$1";
@ -255,6 +263,7 @@ function funcGetSeriesIdFromTvdb {
# Get the EPG from OnlineTvRecorder and get the title of the episode # Get the EPG from OnlineTvRecorder and get the title of the episode
function funcGetEPG { function funcGetEPG {
if $debug; then echo -e "\033[36mfuncGetEPG\033[37m"; fi;
# Download OTR EPG data and search for series and time # Download OTR EPG data and search for series and time
wget_file="$PwD/epg-${file_date}.csv" wget_file="$PwD/epg-${file_date}.csv"
if [ -f "$wget_file" ]; then if [ -f "$wget_file" ]; then
@ -307,8 +316,10 @@ function funcGetEPG {
# Get the title of the episode from description in EPG using $1 as delimiter to the real description # Get the title of the episode from description in EPG using $1 as delimiter to the real description
function funcGetEpgEpisodeTitle { function funcGetEpgEpisodeTitle {
if $debug; then echo -e "\033[36mfuncGetEpgEpisodeTitle\033[37m"; fi;
local delimiter; local delimiter;
delimiter="$1" delimiter="$1"
episode_title="${epg_text%%$delimiter*}" # Text begins with episode title, cut off the rest episode_title="${epg_text%%$delimiter*}" # Text begins with episode title, cut off the rest
episode_title="${episode_title#$series_title_file}" # Get the title without the series title episode_title="${episode_title#$series_title_file}" # Get the title without the series title
episode_title="$(echo ${episode_title#$series_title_tvdb} | sed -e 's/^[^a-zA-Z0-9]*//' -e 's/ *$//')" # Get the title without the series title episode_title="$(echo ${episode_title#$series_title_tvdb} | sed -e 's/^[^a-zA-Z0-9]*//' -e 's/ *$//')" # Get the title without the series title
@ -322,6 +333,7 @@ function funcGetEpgEpisodeTitle {
# Download episodes list from TvDB, language as argument # Download episodes list from TvDB, language as argument
function funcGetEpisodes { function funcGetEpisodes {
if $debug; then echo -e "\033[36mfuncGetEpisodes\033[37m"; fi;
wget_file="$PwD/episodes-${series_id}-${langCurrent}.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")
@ -347,6 +359,7 @@ function funcGetEpisodes {
# Get the information from episodes list of TvDB # Get the information from episodes list of TvDB
function funcGetEpisodeInfo { function funcGetEpisodeInfo {
if $debug; then echo -e "\033[36mfuncGetEpisodeInfo\033[37m"; fi;
local tmp; local tmp;
local title; local title;
local title1; local title1;
@ -429,6 +442,7 @@ function funcGetEpisodeInfo {
function funcMakeFilename { function funcMakeFilename {
if $debug; then echo -e "\033[36mfuncMakeFilename\033[37m"; fi;
if [ "$lang" == "de" ]; then if [ "$lang" == "de" ]; then
episode_title=${episode_title//Ä/Ae} # Replace umlauts episode_title=${episode_title//Ä/Ae} # Replace umlauts
episode_title=${episode_title//Ö/Oe} episode_title=${episode_title//Ö/Oe}
@ -441,7 +455,7 @@ function funcMakeFilename {
} }
# This function does everything # This function does everything
function doIt { function doIt {
funcHeader funcHeader
if [ -z "$path" ]; then # If no path was specified (-f) if [ -z "$path" ]; then # If no path was specified (-f)