extract-artist dashes, minus and hyphen + spaces (#250)

extract artist only when found one of: - − – — ― surronded by spaces (to avoid error behaviour on artists or tracks with hyphen in title)
master
George Pchelkin 2018-02-09 17:49:12 +03:00 committed by Ronan
parent 3b067f8766
commit cd979d3078
1 changed files with 6 additions and 4 deletions

View File

@ -633,10 +633,12 @@ def set_metadata(track, filename, album=None):
track['artist'] = user['username']
if arguments['--extract-artist']:
if '-' in track['title']:
artist_title = track['title'].split('-')
track['artist'] = artist_title[0].strip()
track['title'] = artist_title[1].strip()
for dash in [' - ', ' ', ' ', '', '']:
if dash in track['title']:
artist_title = track['title'].split(dash)
track['artist'] = artist_title[0].strip()
track['title'] = artist_title[1].strip()
break
audio = mutagen.File(filename)
audio['TIT2'] = mutagen.id3.TIT2(encoding=3, text=track['title'])