mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-21 20:29:27 +00:00
Unicode changes
This commit is contained in:
@@ -8,6 +8,13 @@ from headphones import db, logger, helpers, importer
|
||||
|
||||
def libraryScan(dir=None):
|
||||
|
||||
# Clean up bad filepaths
|
||||
tracks = myDB.select('SELECT Location, TrackID from tracks WHERE Location IS NOT NULL')
|
||||
|
||||
for track in tracks:
|
||||
if not os.path.isfile(track['Location']):
|
||||
myDB.action('UPDATE tracks SET Location=? WHERE TrackID=?', [None, track['TrackID']])
|
||||
|
||||
if not dir:
|
||||
dir = headphones.MUSIC_DIR
|
||||
|
||||
@@ -162,14 +169,6 @@ def libraryScan(dir=None):
|
||||
continue
|
||||
|
||||
logger.info('Done checking empty filepaths')
|
||||
|
||||
# Clean up bad filepaths
|
||||
tracks = myDB.select('SELECT Location, TrackID from tracks WHERE Location IS NOT NULL')
|
||||
|
||||
for track in tracks:
|
||||
if not os.path.isfile(track['Location']):
|
||||
myDB.action('UPDATE tracks SET Location=? WHERE TrackID=?', [None, track['TrackID']])
|
||||
|
||||
logger.info('Done syncing library with directory: %s' % dir)
|
||||
|
||||
# Clean up the new artist list
|
||||
|
||||
@@ -110,6 +110,11 @@ def verify(albumid, albumpath):
|
||||
release = myDB.action('SELECT * from albums WHERE AlbumID=?', [albumid]).fetchone()
|
||||
tracks = myDB.select('SELECT * from tracks WHERE AlbumID=?', [albumid])
|
||||
|
||||
try:
|
||||
albumpath = str(albumpath)
|
||||
except UnicodeEncodeError:
|
||||
albumpath = unicode(albumpath).encode('unicode_escape')
|
||||
|
||||
downloaded_track_list = []
|
||||
|
||||
for r,d,f in os.walk(albumpath):
|
||||
@@ -324,7 +329,7 @@ def moveFiles(albumpath, release, tracks):
|
||||
folder = newfolder
|
||||
break
|
||||
|
||||
logger.info('Moving files from %s to %s' % (albumpath, destination_path))
|
||||
logger.info('Moving files from %s to %s' % (albumpath, destination_path.encode('utf-8')))
|
||||
|
||||
try:
|
||||
os.makedirs(destination_path)
|
||||
@@ -416,7 +421,7 @@ def renameFiles(albumpath, downloaded_track_list, release):
|
||||
|
||||
new_file = os.path.join(albumpath, new_file_name)
|
||||
|
||||
logger.debug('Renaming %s ---> %s' % (downloaded_track, new_file_name))
|
||||
logger.debug('Renaming %s ---> %s' % (downloaded_track, new_file_name.encode('utf-8')))
|
||||
try:
|
||||
os.rename(downloaded_track, new_file)
|
||||
except Exception, e:
|
||||
|
||||
Reference in New Issue
Block a user