mirror of
				https://github.com/Jonny007-MKD/OTR-SaneRename
				synced 2025-11-03 16:15:35 +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,23 +231,25 @@ function funcGetEpgEpisodeTitle {
 | 
			
		|||
 | 
			
		||||
# Download episodes list from TvDB, language as argument
 | 
			
		||||
function funcGetEpisodes {
 | 
			
		||||
	# Download Episode list of series
 | 
			
		||||
	episode_db="https://www.thetvdb.com/api/$apikey/series/$series_id/all/$1.xml"
 | 
			
		||||
	wget_file="$PwD/episodes.xml"
 | 
			
		||||
	wget_running=true;
 | 
			
		||||
	wget $episode_db -O "$wget_file" -o /dev/null
 | 
			
		||||
	wget_running=false;
 | 
			
		||||
	error=$?
 | 
			
		||||
	if [ $error -ne 0 ]; then
 | 
			
		||||
		eecho "Downloading $episode_db failed (Exit code: $error)!"
 | 
			
		||||
		exit 6
 | 
			
		||||
	wget_file="$PwD/episodes-${series_id}.xml"
 | 
			
		||||
	if [ ! -f "$wget_file" ]; then
 | 
			
		||||
		# Download Episode list of series
 | 
			
		||||
		episode_db="https://www.thetvdb.com/api/$apikey/series/$series_id/all/$1.xml"
 | 
			
		||||
		wget_running=true;
 | 
			
		||||
		wget $episode_db -O "$wget_file" -o /dev/null
 | 
			
		||||
		wget_running=false;
 | 
			
		||||
		error=$?
 | 
			
		||||
		if [ $error -ne 0 ]; then
 | 
			
		||||
			eecho "Downloading $episode_db failed (Exit code: $error)!"
 | 
			
		||||
			exit 6
 | 
			
		||||
		fi
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Get the information from episodes list of TvDB
 | 
			
		||||
function funcGetEpisodeInfo {
 | 
			
		||||
	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
 | 
			
		||||
			tmp=${episode_title% *}
 | 
			
		||||
			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
 | 
			
		||||
function doIt {	
 | 
			
		||||
	funcHeader
 | 
			
		||||
| 
						 | 
				
			
			@ -299,12 +314,6 @@ function doIt {
 | 
			
		|||
		exit 15
 | 
			
		||||
	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=$(dirname "$PwD")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -337,7 +346,7 @@ function doIt {
 | 
			
		|||
		
 | 
			
		||||
	
 | 
			
		||||
	if [ -n "$episode_info" ]; then
 | 
			
		||||
		echo "${series_title// /.}..S${episode_season}E${episode_number}..${episode_title// /.}.$file_suffix"
 | 
			
		||||
		funcMakeFilename
 | 
			
		||||
		exit 0
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue