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