mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-19 10:05:30 +01:00
Updated post processor to update have tracks on download
This commit is contained in:
@@ -168,4 +168,4 @@ def libraryScan():
|
||||
headphones.NEW_ARTISTS = artist_list
|
||||
|
||||
if headphones.DETECT_BITRATE:
|
||||
headphones.PREFERRED_BITRATE = float(sum(bitrates))/len(bitrates)/1000
|
||||
headphones.PREFERRED_BITRATE = round(sum(bitrates))/len(bitrates)/1000
|
||||
@@ -240,6 +240,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
myDB.action('UPDATE artists SET HaveTracks=? WHERE ArtistID=?', [new_track_count, release['ArtistID']])
|
||||
myDB.action('UPDATE albums SET status = "Downloaded" WHERE AlbumID=?', [albumid])
|
||||
myDB.action('UPDATE snatched SET status = "Processed" WHERE AlbumID=?', [albumid])
|
||||
updateHave(albumpath)
|
||||
|
||||
logger.info('Post-processing for %s - %s complete' % (release['ArtistName'], release['AlbumTitle']))
|
||||
|
||||
@@ -420,6 +421,36 @@ def renameFiles(albumpath, downloaded_track_list, release):
|
||||
except Exception, e:
|
||||
logger.error('Error renaming file: %s. Error: %s' % (downloaded_track, e))
|
||||
continue
|
||||
|
||||
def updateHave(albumpath):
|
||||
|
||||
results = []
|
||||
|
||||
for r,d,f in os.walk(albumpath):
|
||||
for files in f:
|
||||
if any(files.endswith('.' + x) for x in headphones.MEDIA_FORMATS):
|
||||
results.append(os.path.join(r, files))
|
||||
|
||||
if results:
|
||||
|
||||
myDB = db.DBConnection()
|
||||
|
||||
for song in results:
|
||||
try:
|
||||
f = MediaFile(song)
|
||||
#logger.debug('Reading: %s' % song.decode('UTF-8'))
|
||||
except:
|
||||
logger.warn('Could not read file: %s' % song)
|
||||
continue
|
||||
else:
|
||||
if f.albumartist:
|
||||
artist = f.albumartist
|
||||
elif f.artist:
|
||||
artist = f.artist
|
||||
else:
|
||||
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])
|
||||
|
||||
def renameUnprocessedFolder(albumpath):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user