mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-30 17:49:27 +01:00
Added debugging messages to the postprocessor verify function
This commit is contained in:
@@ -22,6 +22,7 @@ def checkFolder():
|
||||
album_path = os.path.join(headphones.DOWNLOAD_DIR, album['FolderName'])
|
||||
|
||||
if os.path.exists(album_path):
|
||||
logger.debug('Found %s. Verifying....' % album['FolderName'])
|
||||
verify(album['AlbumID'], album_path)
|
||||
|
||||
def verify(albumid, albumpath):
|
||||
@@ -118,28 +119,47 @@ def verify(albumid, albumpath):
|
||||
downloaded_track_list.append(os.path.join(r, files))
|
||||
|
||||
# test #1: metadata - usually works
|
||||
logger.debug('Verifying metadata...')
|
||||
|
||||
metaartist = helpers.latinToAscii(f.artist.lower()).encode('UTF-8')
|
||||
dbartist = helpers.latinToAscii(release['ArtistName'].lower()).encode('UTF-8')
|
||||
metaalbum = helpers.latinToAscii(f.album.lower()).encode('UTF-8')
|
||||
dbalbum = helpers.latinToAscii(release['AlbumTitle'].lower()).encode('UTF-8')
|
||||
|
||||
logger.debug('Matching metadata artist: %s with artist name: %s' % (metaartist, dbartist))
|
||||
logger.debug('Matching metadata album: %s with album name: %s' % (metaalbum, dbalbum))
|
||||
|
||||
for downloaded_track in downloaded_track_list:
|
||||
try:
|
||||
f = MediaFile(downloaded_track)
|
||||
except:
|
||||
continue
|
||||
if helpers.latinToAscii(f.artist.lower()).encode('UTF-8') == helpers.latinToAscii(release['ArtistName'].lower()).encode('UTF-8') and helpers.latinToAscii(f.album.lower()).encode('UTF-8') == helpers.latinToAscii(release['AlbumTitle'].lower()).encode('UTF-8'):
|
||||
if metaartist == dbartist and metaalbum == dbalbum:
|
||||
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
return
|
||||
|
||||
# test #2: filenames
|
||||
logger.debug('Metadata check failed. Verifying filenames...')
|
||||
for downloaded_track in downloaded_track_list:
|
||||
track_name = os.path.splitext(downloaded_track)[0]
|
||||
split_track_name = re.sub('[\.\-\_]', ' ', track_name).lower()
|
||||
for track in tracks:
|
||||
if helpers.latinToAscii(track['TrackTitle'].lower()).encode('UTF-8') in helpers.latinToAscii(split_track_name).encode('UTF-8'):
|
||||
|
||||
dbtrack = helpers.latinToAscii(track['TrackTitle'].lower()).encode('UTF-8')
|
||||
filetrack = helpers.latinToAscii(split_track_name).encode('UTF-8')
|
||||
logger.debug('Checking if track title: %s is in file name: %s' % (dbtrack, filetrack))
|
||||
|
||||
if dbtrack in filetrack:
|
||||
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
return
|
||||
|
||||
# test #3: number of songs and duration
|
||||
logger.debug('Filename check failed. Verifying album length...')
|
||||
db_track_duration = 0
|
||||
downloaded_track_duration = 0
|
||||
|
||||
logger.debug('Total music files in %s: %i' % (albumpath, len(downloaded_track_list)))
|
||||
logger.debug('Total tracks for this album in the database: %i' % len(tracks))
|
||||
if len(tracks) == len(downloaded_track_list):
|
||||
|
||||
for track in tracks:
|
||||
@@ -156,8 +176,10 @@ def verify(albumid, albumpath):
|
||||
except:
|
||||
downloaded_track_duration = False
|
||||
break
|
||||
|
||||
|
||||
if downloaded_track_duration and db_track_duration:
|
||||
logger.debug('Downloaded album duration: %i' % downloaded_track_duration)
|
||||
logger.debug('Database track duration: %i' % db_track_duration)
|
||||
delta = abs(downloaded_track_duration - db_track_duration)
|
||||
if delta < 240:
|
||||
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
|
||||
Reference in New Issue
Block a user