mirror of
				https://github.com/Jonny007-MKD/OTR-SaneRename
				synced 2025-10-30 15:35:33 +01:00 
			
		
		
		
	Remove up to 3 words from the beginning of the EPG title
This commit is contained in:
		
							parent
							
								
									8b2b6dbf25
								
							
						
					
					
						commit
						f042c8b1aa
					
				
					 1 changed files with 46 additions and 35 deletions
				
			
		|  | @ -389,55 +389,66 @@ function funcDownloadEpisodesFile { | ||||||
| # Get the information from episodes list of TvDB | # Get the information from episodes list of TvDB | ||||||
| function funcGetEpisodeInfoByTitle { | function funcGetEpisodeInfoByTitle { | ||||||
| 	if $debug; then echo -e "\033[36mfuncGetEpisodeInfoByTitle\033[37m"; fi; | 	if $debug; then echo -e "\033[36mfuncGetEpisodeInfoByTitle\033[37m"; fi; | ||||||
| 	local tmp; | 	local i; | ||||||
| 	local title; | 	local tmp;									# Some tmp variable | ||||||
| 	local title1; | 	local title;								# The current string of the title | ||||||
|  | 	local title_not_converted;					# Whether the title was converted | ||||||
|  | 	local remove_begin;							# How many words shall be removed from the beginnig | ||||||
| 	title="$episode_title"														# Use coded version of episode title | 	title="$episode_title"														# Use coded version of episode title | ||||||
| 	funcConvertName "$episode_title" | 	funcConvertName "$episode_title" | ||||||
| 	if [ "$episode_title" != "$tmp" ]; then										# Save state to change to decoded version later | 	if [ "$episode_title" != "$tmp" ]; then										# Save state to change to decoded version later | ||||||
| 		title1=true; | 		title_not_converted=true; | ||||||
| 	else | 	else | ||||||
| 		title1=false; | 		title_not_converted=false; | ||||||
| 	fi | 	fi | ||||||
| 
 | 
 | ||||||
| 	wget_file="$PwD/episodes-${series_id}-${langCurrent}.xml" | 	wget_file="$PwD/episodes-${series_id}-${langCurrent}.xml" | ||||||
| 	while true; do | 
 | ||||||
|  | 	while true; do								# Loop: Convert title | ||||||
|  | 		for remove_begin in 1 2 3 4; do			# Loop: Remove up to 3 words from beginning | ||||||
|  | 			while true; do						# Loop: Remove words from end | ||||||
|  | 				eecho -e "        \tEpisode title:\t$title" | ||||||
| 				episode_info=$(grep -i "sodeName>$title" "$wget_file" -B 10 | tail -11)	# Get XML data of episode | 				episode_info=$(grep -i "sodeName>$title" "$wget_file" -B 10 | tail -11)	# 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 | ||||||
| 					if [ ${#title} -gt 10 ]; then										# If title is long enough | 					if [ ${#title} -gt 10 ]; then										# If title is long enough | ||||||
| 						episode_info=$(grep -i "verView>$title" "$wget_file" -B 16 | tail -17) | 						episode_info=$(grep -i "verView>$title" "$wget_file" -B 16 | tail -17) | ||||||
| 					fi | 					fi | ||||||
| 			if [ -z "$episode_info" ]; then										# Still nothing found. Shorten the title | 					if [ -n "$episode_info" ]; then										# We have found something! | ||||||
|  | 						break; | ||||||
|  | 					else																# Still nothing found. Shorten the title | ||||||
| 						tmp=${title% *} | 						tmp=${title% *} | ||||||
| 				if [ ${#tmp} -le 4 ] || [ "$tmp" == "$title" ]; then | 						if [ ${#tmp} -le 4 ] || [ "$tmp" == "$title" ]; then			# Stop when the title is to short | ||||||
| 					if $title1; then |  | ||||||
| 						funcConvertName "$episode_title" |  | ||||||
| 						title1=false; |  | ||||||
| 					else |  | ||||||
| 							break; | 							break; | ||||||
| 						fi | 						fi | ||||||
| 					fi | 					fi | ||||||
| 			else |  | ||||||
| 				break; |  | ||||||
| 			fi |  | ||||||
| 					title="$(echo $tmp | sed -e 's/^[^a-zA-Z0-9]*//' -e 's/ *$//')"		# Remove special characters | 					title="$(echo $tmp | sed -e 's/^[^a-zA-Z0-9]*//' -e 's/ *$//')"		# Remove special characters | ||||||
| 			eecho -e "        \tEpisode title:\t$title" |  | ||||||
| 				else | 				else | ||||||
| 					break; | 					break; | ||||||
| 				fi | 				fi | ||||||
| 	done | 			done								# Loop: Remove words from end | ||||||
|  | 			if [ -n "$episode_info" ]; then					# We have found something! :) | ||||||
|  | 				break; | ||||||
|  | 			fi | ||||||
| 
 | 
 | ||||||
| 	if [ -z "$episode_info" ]; then												# If we have not found anything | 			title="$episode_title" | ||||||
| 		tmp="${episode_title%% *}"												# Get the first word | 			for i in $(seq 1 $remove_begin); do											# Remove $remove_begin words from the beginning | ||||||
| 		title="${episode_title#$tmp }"											# Remove it from the title | 				echo $remove_begin $i | ||||||
| 		eecho -e "        \tEpisode title:\t$title" | 				tmp="${title%% *}"														# Get the first word | ||||||
| 		episode_info=$(grep -i "sodeName>$title" "$wget_file" -B 10 | tail -11)	# Get XML data of episode | 				title="${title#$tmp }"													# Remove it from the title | ||||||
| 	fi | 				echo $tmp -- $title | ||||||
| 	if [ -z "$episode_info" ]; then												# Nothing found. Search the description | 			done | ||||||
| 		if [ ${#title} -gt 10 ]; then											# If title is long enough | 		done									# Loop: Remove words from beginning | ||||||
| 			episode_info=$(grep -i "verView>$title" "$wget_file" -B 16 | tail -17) | 			 | ||||||
|  | 		if [ -n "$episode_info" ]; then						# We have found something! :) | ||||||
|  | 			break; | ||||||
| 		fi | 		fi | ||||||
|  | 		if $title_not_converted; then						# We have not yet tried to convert the title | ||||||
|  | 			funcConvertName "$episode_title" | ||||||
|  | 			title_not_converted=false; | ||||||
|  | 		else | ||||||
|  | 			break; | ||||||
| 		fi | 		fi | ||||||
|  | 	done										# Loop: Convert title | ||||||
| 
 | 
 | ||||||
| 	funcGetEpisodeInfo_ParseData | 	funcGetEpisodeInfo_ParseData | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Jonny007-MKD
						Jonny007-MKD