mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-02 09:49:36 +01:00
Fixed unicode error when no track metadata available - also fixed track renaming if no metadata available
This commit is contained in:
@@ -121,6 +121,17 @@ def cleanName(string):
|
||||
|
||||
return out_string
|
||||
|
||||
def cleanTitle(title):
|
||||
|
||||
title = re.sub('[\.\-\/\_]', ' ', title).lower()
|
||||
|
||||
# Strip out extra whitespace
|
||||
title = ' '.join(title.split())
|
||||
|
||||
title = title.title()
|
||||
|
||||
return title
|
||||
|
||||
def extract_data(s):
|
||||
|
||||
from headphones import logger
|
||||
|
||||
@@ -432,8 +432,13 @@ def renameFiles(albumpath, downloaded_track_list, release):
|
||||
tracknumber = '%02d' % f.track
|
||||
|
||||
if not f.title:
|
||||
basename = os.path.basename(downloaded_track)
|
||||
|
||||
basename = unicode(os.path.basename(downloaded_track), headphones.SYS_ENCODING, errors='replace')
|
||||
title = os.path.splitext(basename)[0]
|
||||
ext = os.path.splitext(basename)[1]
|
||||
|
||||
new_file_name = helpers.cleanTitle(title) + ext
|
||||
|
||||
else:
|
||||
title = f.title
|
||||
|
||||
@@ -448,6 +453,7 @@ def renameFiles(albumpath, downloaded_track_list, release):
|
||||
|
||||
new_file_name = helpers.replace_all(headphones.FILE_FORMAT, values).replace('/','_') + ext
|
||||
|
||||
|
||||
new_file_name = new_file_name.replace('?','_').replace(':', '_').encode(headphones.SYS_ENCODING)
|
||||
|
||||
new_file = os.path.join(albumpath, new_file_name)
|
||||
@@ -551,5 +557,3 @@ def forcePostProcess():
|
||||
continue
|
||||
if rgid:
|
||||
verify(rgid, albumpath)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user