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