album_artist_from_path(): remove useless code

len(dirs) == 0 cannot happen, because `whatever.split('/')` is always a list with at least 1 element.

So simplify code and remove useless tests
This commit is contained in:
Laurent Monin
2020-02-22 15:45:14 +01:00
parent 77a9d0110a
commit ef7e154c4f

View File

@@ -391,13 +391,10 @@ def album_artist_from_path(filename, album, artist):
"""
if not album:
dirs = os.path.dirname(filename).replace('\\', '/').lstrip('/').split('/')
if len(dirs) == 0:
return album, artist
# Strip disc subdirectory from list
if len(dirs) > 0:
if re.search(r'(^|\s)(CD|DVD|Disc)\s*\d+(\s|$)', dirs[-1], re.I):
del dirs[-1]
if len(dirs) > 0:
if re.search(r'(^|\s)(CD|DVD|Disc)\s*\d+(\s|$)', dirs[-1], re.I):
del dirs[-1]
if dirs:
# For clustering assume %artist%/%album%/file or %artist% - %album%/file
album = dirs[-1]
if ' - ' in album: