Do more regex matching, fix zero-indexed albums
lmao what
This commit is contained in:
parent
6dc1efaab6
commit
f65e3441f0
18
badwitch.py
18
badwitch.py
@ -323,18 +323,18 @@ class BadWitch:
|
||||
'source': entries[i]['webpage_url']
|
||||
}
|
||||
# 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']:
|
||||
print('Detected multiple artists')
|
||||
artist = 'Various Artists'
|
||||
elif artist != entries[i]['artist']:
|
||||
print('Detected 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'])
|
||||
album = entries[i]['album']
|
||||
# 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'])
|
||||
metadata['release_date'] = entries[i]['release_date']
|
||||
# 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 + ' = ')
|
||||
if in_value is not '': metadata[field] = in_value
|
||||
# Remove artist prefixes because that happens a lot
|
||||
artistregex = re.compile(r'^' + re.escape(artist) + r'[ ]*[-:;~]*[ ]*', re.IGNORECASE)
|
||||
for song, songcontent in playlist.items():
|
||||
songcontent['title'] = artistregex.sub('', songcontent['title'])
|
||||
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():
|
||||
songcontent['title'] = cregex.sub('', songcontent['title'])
|
||||
# Build up an album
|
||||
playlistalbum = {}
|
||||
playlistalbum['meta'] = metadata
|
||||
for song, songcontent in playlist.items():
|
||||
playlistalbum[songcontent['title']] = {
|
||||
'track': song,
|
||||
'track': song + 1,
|
||||
'artist': artist,
|
||||
'source': songcontent['source']
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user