Do more regex matching, fix zero-indexed albums
lmao what
This commit is contained in:
		
							
								
								
									
										16
									
								
								badwitch.py
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								badwitch.py
									
									
									
									
									
								
							| @@ -323,18 +323,18 @@ class BadWitch: | |||||||
|                             'source': entries[i]['webpage_url'] |                             'source': entries[i]['webpage_url'] | ||||||
|                             } |                             } | ||||||
|                     # Song tags like these are per-song, so we have to detect them here |                     # Song tags like these are per-song, so we have to detect them here | ||||||
|                     if 'artist' in item: |                     if 'artist' in entries[i] and entries[i]['artist'] is not None: | ||||||
|                         if artist != '' and artist != entries[i]['artist']: |                         if artist != '' and artist != entries[i]['artist']: | ||||||
|                             print('Detected multiple artists') |                             print('Detected multiple artists') | ||||||
|                             artist = 'Various Artists' |                             artist = 'Various Artists' | ||||||
|                         elif artist != entries[i]['artist']: |                         elif artist != entries[i]['artist']: | ||||||
|                             print('Detected artist ' + entries[i]['artist']) |                             print('Detected artist ' + entries[i]['artist']) | ||||||
|                             artist = entries[i]['artist'] |                             artist = entries[i]['artist'] | ||||||
|                     if 'album' in item and album == '': |                     if 'album' in entries[i] and entries[i]['album'] is not None and album == '': | ||||||
|                         print('Detected album title ' + entries[i]['album']) |                         print('Detected album title ' + entries[i]['album']) | ||||||
|                         album = entries[i]['album'] |                         album = entries[i]['album'] | ||||||
|                     # Sometimes this just comes back None |                     # Sometimes this just comes back None | ||||||
|                     if 'release_date' in item and 'release_date' not in metadata and entries[i]['release_date'] is not None: |                     if 'release_date' in entries[i] and entries[i]['release_date'] is not None and 'release_date' not in metadata: | ||||||
|                         print('Detected release date ' + entries[i]['release_date']) |                         print('Detected release date ' + entries[i]['release_date']) | ||||||
|                         metadata['release_date'] = entries[i]['release_date'] |                         metadata['release_date'] = entries[i]['release_date'] | ||||||
|                 # If YouTube's song tags didn't work, just grab metadata from the playlist |                 # If YouTube's song tags didn't work, just grab metadata from the playlist | ||||||
| @@ -348,15 +348,19 @@ class BadWitch: | |||||||
|             in_value = input('Metadata: ' + field + ' = ') |             in_value = input('Metadata: ' + field + ' = ') | ||||||
|             if in_value is not '': metadata[field] = in_value |             if in_value is not '': metadata[field] = in_value | ||||||
|         # Remove artist prefixes because that happens a lot |         # Remove artist prefixes because that happens a lot | ||||||
|         artistregex = re.compile(r'^' + re.escape(artist) + r'[ ]*[-:;~]*[ ]*', re.IGNORECASE) |         for regex in [ | ||||||
|  |                 r'^' + re.escape(artist) + r'[ ]*[-:;~]*[ ]*', # Remove artist from beginning of songs | ||||||
|  |                 re.escape('(Audio)') + r'$' # Remove (Audio) from VEVO tracks AUGH | ||||||
|  |                 ]: | ||||||
|  |             cregex = re.compile(regex, re.IGNORECASE) | ||||||
|             for song, songcontent in playlist.items(): |             for song, songcontent in playlist.items(): | ||||||
|             songcontent['title'] = artistregex.sub('', songcontent['title']) |                 songcontent['title'] = cregex.sub('', songcontent['title']) | ||||||
|         # Build up an album |         # Build up an album | ||||||
|         playlistalbum = {} |         playlistalbum = {} | ||||||
|         playlistalbum['meta'] = metadata |         playlistalbum['meta'] = metadata | ||||||
|         for song, songcontent in playlist.items(): |         for song, songcontent in playlist.items(): | ||||||
|             playlistalbum[songcontent['title']] = { |             playlistalbum[songcontent['title']] = { | ||||||
|                 'track': song, |                 'track': song + 1, | ||||||
|                 'artist': artist, |                 'artist': artist, | ||||||
|                 'source': songcontent['source'] |                 'source': songcontent['source'] | ||||||
|                 } |                 } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user