mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-21 16:34:01 +01:00
Merge branch 'develop'
This commit is contained in:
Executable → Regular
@@ -57,11 +57,11 @@
|
|||||||
"oLanguage": {
|
"oLanguage": {
|
||||||
"sLengthMenu":"Show _MENU_ results per page",
|
"sLengthMenu":"Show _MENU_ results per page",
|
||||||
"sEmptyTable": "No results",
|
"sEmptyTable": "No results",
|
||||||
"sInfo":"Showing _TOTAL_ results",
|
"sInfo":"Showing _START_ to _END_ of _TOTAL_ results",
|
||||||
"sInfoEmpty":"Showing 0 to 0 of 0 results",
|
"sInfoEmpty":"Showing 0 to 0 of 0 results",
|
||||||
"sInfoFiltered":"(filtered from _MAX_ total results)"},
|
"sInfoFiltered":"(filtered from _MAX_ total results)"},
|
||||||
"bPaginate": false,
|
"iDisplayLength": 25,
|
||||||
"bFilter": false,
|
"sPaginationType": "full_numbers",
|
||||||
"aaSorting": []
|
"aaSorting": []
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Executable → Regular
@@ -161,12 +161,12 @@ def addArtisttoDB(artistid, extrasonly=False):
|
|||||||
"CleanName": cleanname
|
"CleanName": cleanname
|
||||||
}
|
}
|
||||||
|
|
||||||
match = myDB.action('SELECT Location, BitRate from have WHERE TrackID=?', [track['id']]).fetchone()
|
match = myDB.action('SELECT Location, BitRate from have WHERE CleanName=?', [cleanname]).fetchone()
|
||||||
|
|
||||||
if not match:
|
|
||||||
match = myDB.action('SELECT Location, BitRate from have WHERE CleanName=?', [cleanname]).fetchone()
|
|
||||||
if not match:
|
if not match:
|
||||||
match = myDB.action('SELECT Location, BitRate from have WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [artist['artist_name'], rg['title'], track['title']]).fetchone()
|
match = myDB.action('SELECT Location, BitRate from have WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [artist['artist_name'], rg['title'], track['title']]).fetchone()
|
||||||
|
if not match:
|
||||||
|
match = myDB.action('SELECT Location, BitRate from have WHERE TrackID=?', [track['id']]).fetchone()
|
||||||
if match:
|
if match:
|
||||||
newValueDict['Location'] = match['Location']
|
newValueDict['Location'] = match['Location']
|
||||||
newValueDict['BitRate'] = match['BitRate']
|
newValueDict['BitRate'] = match['BitRate']
|
||||||
@@ -287,14 +287,14 @@ def addReleaseById(rid):
|
|||||||
"CleanName": cleanname
|
"CleanName": cleanname
|
||||||
}
|
}
|
||||||
|
|
||||||
match = myDB.action('SELECT Location, BitRate from have WHERE TrackID=?', [track['id']]).fetchone()
|
match = myDB.action('SELECT Location, BitRate from have WHERE CleanName=?', [cleanname]).fetchone()
|
||||||
|
|
||||||
if not match:
|
|
||||||
match = myDB.action('SELECT Location, BitRate from have WHERE CleanName=?', [cleanname]).fetchone()
|
|
||||||
|
|
||||||
if not match:
|
if not match:
|
||||||
match = myDB.action('SELECT Location, BitRate from have WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [release_dict['artist_name'], release_dict['rg_title'], track['title']]).fetchone()
|
match = myDB.action('SELECT Location, BitRate from have WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [release_dict['artist_name'], release_dict['rg_title'], track['title']]).fetchone()
|
||||||
|
|
||||||
|
if not match:
|
||||||
|
match = myDB.action('SELECT Location, BitRate from have WHERE TrackID=?', [track['id']]).fetchone()
|
||||||
|
|
||||||
if match:
|
if match:
|
||||||
newValueDict['Location'] = match['Location']
|
newValueDict['Location'] = match['Location']
|
||||||
newValueDict['BitRate'] = match['BitRate']
|
newValueDict['BitRate'] = match['BitRate']
|
||||||
|
|||||||
+18
-19
@@ -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'].encode(headphones.SYS_ENCODING)):
|
||||||
|
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
|
||||||
|
|
||||||
@@ -44,17 +51,6 @@ def libraryScan(dir=None):
|
|||||||
if f.bitrate:
|
if f.bitrate:
|
||||||
bitrates.append(f.bitrate)
|
bitrates.append(f.bitrate)
|
||||||
|
|
||||||
# Try to match on metadata first, starting with the track id
|
|
||||||
if f.mb_trackid:
|
|
||||||
|
|
||||||
# Wondering if theres a better way to do this -> do one thing if the row exists,
|
|
||||||
# do something else if it doesn't
|
|
||||||
track = myDB.action('SELECT TrackID from tracks WHERE TrackID=?', [f.mb_trackid]).fetchone()
|
|
||||||
|
|
||||||
if track:
|
|
||||||
myDB.action('UPDATE tracks SET Location=?, BitRate=? WHERE TrackID=?', [file, f.bitrate, track['TrackID']])
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Try to find a match based on artist/album/tracktitle
|
# Try to find a match based on artist/album/tracktitle
|
||||||
if f.albumartist:
|
if f.albumartist:
|
||||||
f_artist = f.albumartist
|
f_artist = f.albumartist
|
||||||
@@ -74,6 +70,17 @@ def libraryScan(dir=None):
|
|||||||
myDB.action('UPDATE tracks SET Location=?, BitRate=? WHERE TrackID=?', [file, f.bitrate, track['TrackID']])
|
myDB.action('UPDATE tracks SET Location=?, BitRate=? WHERE TrackID=?', [file, f.bitrate, track['TrackID']])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Try to match on mbid if available and we couldn't find a match based on metadata
|
||||||
|
if f.mb_trackid:
|
||||||
|
|
||||||
|
# Wondering if theres a better way to do this -> do one thing if the row exists,
|
||||||
|
# do something else if it doesn't
|
||||||
|
track = myDB.action('SELECT TrackID from tracks WHERE TrackID=?', [f.mb_trackid]).fetchone()
|
||||||
|
|
||||||
|
if track:
|
||||||
|
myDB.action('UPDATE tracks SET Location=?, BitRate=? WHERE TrackID=?', [file, f.bitrate, track['TrackID']])
|
||||||
|
continue
|
||||||
|
|
||||||
# if we can't find a match in the database on a track level, it might be a new artist or it might be on a non-mb release
|
# if we can't find a match in the database on a track level, it might be a new artist or it might be on a non-mb release
|
||||||
new_artists.append(f_artist)
|
new_artists.append(f_artist)
|
||||||
|
|
||||||
@@ -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,8 @@ 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])
|
||||||
|
|
||||||
|
albumpath = albumpath.encode(headphones.SYS_ENCODING)
|
||||||
|
|
||||||
downloaded_track_list = []
|
downloaded_track_list = []
|
||||||
|
|
||||||
for r,d,f in os.walk(albumpath):
|
for r,d,f in os.walk(albumpath):
|
||||||
@@ -311,20 +313,20 @@ def moveFiles(albumpath, release, tracks):
|
|||||||
if folder.endswith('.'):
|
if folder.endswith('.'):
|
||||||
folder = folder.replace(folder[len(folder)-1], '_')
|
folder = folder.replace(folder[len(folder)-1], '_')
|
||||||
|
|
||||||
destination_path = os.path.normpath(os.path.join(headphones.DESTINATION_DIR, folder))
|
destination_path = os.path.normpath(os.path.join(headphones.DESTINATION_DIR, folder)).encode(headphones.SYS_ENCODING)
|
||||||
|
|
||||||
if os.path.exists(destination_path):
|
if os.path.exists(destination_path):
|
||||||
i = 1
|
i = 1
|
||||||
while True:
|
while True:
|
||||||
newfolder = folder + '[%i]' % i
|
newfolder = folder + '[%i]' % i
|
||||||
destination_path = os.path.normpath(os.path.join(headphones.DESTINATION_DIR, newfolder))
|
destination_path = os.path.normpath(os.path.join(headphones.DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING)
|
||||||
if os.path.exists(destination_path):
|
if os.path.exists(destination_path):
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
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' % (unicode(albumpath, headphones.SYS_ENCODING, errors="replace"), unicode(destination_path, headphones.SYS_ENCODING, errors="replace")))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(destination_path)
|
os.makedirs(destination_path)
|
||||||
@@ -342,7 +344,7 @@ def moveFiles(albumpath, release, tracks):
|
|||||||
|
|
||||||
temp_f = headphones.DESTINATION_DIR
|
temp_f = headphones.DESTINATION_DIR
|
||||||
for f in folder_list:
|
for f in folder_list:
|
||||||
temp_f = os.path.join(temp_f, f)
|
temp_f = os.path.join(temp_f, f).encode(headphones.SYS_ENCODING)
|
||||||
os.chmod(temp_f, int(headphones.FOLDER_PERMISSIONS, 8))
|
os.chmod(temp_f, int(headphones.FOLDER_PERMISSIONS, 8))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -357,13 +359,17 @@ def correctMetadata(albumid, release, downloaded_track_list):
|
|||||||
logger.info('Writing metadata')
|
logger.info('Writing metadata')
|
||||||
items = []
|
items = []
|
||||||
for downloaded_track in downloaded_track_list:
|
for downloaded_track in downloaded_track_list:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
items.append(beets.library.Item.from_path(downloaded_track))
|
items.append(beets.library.Item.from_path(downloaded_track))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.error("Beets couldn't create an Item from: " + downloaded_track + " - not a media file?" + str(e))
|
logger.error("Beets couldn't create an Item from: " + downloaded_track + " - not a media file?" + str(e))
|
||||||
|
|
||||||
cur_artist, cur_album, out_tuples, rec = autotag.tag_album(items, search_artist=release['ArtistName'], search_album=release['AlbumTitle'])
|
try:
|
||||||
|
cur_artist, cur_album, out_tuples, rec = autotag.tag_album(items, search_artist=helpers.latinToAscii(release['ArtistName']), search_album=helpers.latinToAscii(release['AlbumTitle']))
|
||||||
|
except Exception, e:
|
||||||
|
logger.error('Error getting recommendation: %s. Not writing metadata' % e)
|
||||||
|
return
|
||||||
if rec == 'RECOMMEND_NONE':
|
if rec == 'RECOMMEND_NONE':
|
||||||
logger.warn('No accurate album match found for %s, %s - not writing metadata' % (release['ArtistName'], release['AlbumTitle']))
|
logger.warn('No accurate album match found for %s, %s - not writing metadata' % (release['ArtistName'], release['AlbumTitle']))
|
||||||
return
|
return
|
||||||
@@ -412,7 +418,7 @@ def renameFiles(albumpath, downloaded_track_list, release):
|
|||||||
|
|
||||||
new_file_name = helpers.replace_all(headphones.FILE_FORMAT, values).replace('/','_') + ext
|
new_file_name = helpers.replace_all(headphones.FILE_FORMAT, values).replace('/','_') + ext
|
||||||
|
|
||||||
new_file_name = new_file_name.replace('?','_').replace(':', '_')
|
new_file_name = new_file_name.replace('?','_').replace(':', '_').encode(headphones.SYS_ENCODING)
|
||||||
|
|
||||||
new_file = os.path.join(albumpath, new_file_name)
|
new_file = os.path.join(albumpath, new_file_name)
|
||||||
|
|
||||||
@@ -451,7 +457,7 @@ def updateHave(albumpath):
|
|||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
myDB.action('UPDATE tracks SET Location=?, BitRate=? WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [song, f.bitrate, artist, f.album, f.title])
|
myDB.action('UPDATE tracks SET Location=?, BitRate=? WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [unicode(song, headphones.SYS_ENCODING, errors="replace"), f.bitrate, artist, f.album, f.title])
|
||||||
|
|
||||||
def renameUnprocessedFolder(albumpath):
|
def renameUnprocessedFolder(albumpath):
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
HEADPHONES_VERSION = "master"
|
HEADPHONES_VERSION = "develop"
|
||||||
@@ -62,9 +62,9 @@ class WebInterface(object):
|
|||||||
if len(name) == 0:
|
if len(name) == 0:
|
||||||
raise cherrypy.HTTPRedirect("home")
|
raise cherrypy.HTTPRedirect("home")
|
||||||
if type == 'artist':
|
if type == 'artist':
|
||||||
searchresults = mb.findArtist(name, limit=20)
|
searchresults = mb.findArtist(name, limit=100)
|
||||||
else:
|
else:
|
||||||
searchresults = mb.findRelease(name, limit=20)
|
searchresults = mb.findRelease(name, limit=100)
|
||||||
return serve_template(templatename="searchresults.html", title='Search Results for: "' + name + '"', searchresults=searchresults, type=type)
|
return serve_template(templatename="searchresults.html", title='Search Results for: "' + name + '"', searchresults=searchresults, type=type)
|
||||||
search.exposed = True
|
search.exposed = True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user