More regex slaughing
This commit is contained in:
		
							
								
								
									
										19
									
								
								badwitch.py
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								badwitch.py
									
									
									
									
									
								
							| @@ -342,12 +342,14 @@ class BadWitch: | |||||||
|                     album = result['title'] |                     album = result['title'] | ||||||
|                 if artist == '': |                 if artist == '': | ||||||
|                     artist = result['uploader'] |                     artist = result['uploader'] | ||||||
|         for field in ['genre', 'publisher', 'release_date']: |         # Remove junk from album titles | ||||||
|             if field in metadata: |         for regex in [ | ||||||
|                 continue |                 r'^' + re.escape(artist) + r'[ ]*[-:;~]*[ ]*', # Remove artist from beginning | ||||||
|             in_value = input('Metadata: ' + field + ' = ') |                 r'[ ]*[(\[\{]*[0-9]{4}[)\]\}]*$' # Take years off the end | ||||||
|             if in_value is not '': metadata[field] = in_value |                 ]: | ||||||
|         # Remove artist prefixes because that happens a lot |             cregex = re.compile(regex, re.IGNORECASE) | ||||||
|  |             album = cregex.sub('', album) | ||||||
|  |         # Remove junk from track titles | ||||||
|         for regex in [ |         for regex in [ | ||||||
|                 r'^' + re.escape(artist) + r'[ ]*[-:;~]*[ ]*', # Remove artist from beginning of songs |                 r'^' + re.escape(artist) + r'[ ]*[-:;~]*[ ]*', # Remove artist from beginning of songs | ||||||
|                 re.escape('(Audio)') + r'$' # Remove (Audio) from VEVO tracks AUGH |                 re.escape('(Audio)') + r'$' # Remove (Audio) from VEVO tracks AUGH | ||||||
| @@ -355,6 +357,11 @@ class BadWitch: | |||||||
|             cregex = re.compile(regex, re.IGNORECASE) |             cregex = re.compile(regex, re.IGNORECASE) | ||||||
|             for song, songcontent in playlist.items(): |             for song, songcontent in playlist.items(): | ||||||
|                 songcontent['title'] = cregex.sub('', songcontent['title']) |                 songcontent['title'] = cregex.sub('', songcontent['title']) | ||||||
|  |         for field in ['genre', 'publisher', 'release_date']: | ||||||
|  |             if field in metadata: | ||||||
|  |                 continue | ||||||
|  |             in_value = input('Metadata: ' + field + ' = ') | ||||||
|  |             if in_value is not '': metadata[field] = in_value | ||||||
|         # Build up an album |         # Build up an album | ||||||
|         playlistalbum = {} |         playlistalbum = {} | ||||||
|         playlistalbum['meta'] = metadata |         playlistalbum['meta'] = metadata | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user