cc-4105: added naive replay gain with some performance improvements. reading full file for md5

This commit is contained in:
Rudi Grinberg 2012-08-08 11:53:07 -04:00
parent 958e2e2c74
commit ccd0d4e8cf
2 changed files with 6 additions and 5 deletions

View File

@ -13,7 +13,6 @@ from media.monitor.log import Loggable, get_logger
# following classes should be able to handle. TODO : implement all of the # following classes should be able to handle. TODO : implement all of the
# following special cases # following special cases
# #
# - Recursive directories being added to organized dirs are not handled
# properly as they only send a request for the dir and not for every file. Also # properly as they only send a request for the dir and not for every file. Also
# more hacks are needed to check that the directory finished moving/copying? # more hacks are needed to check that the directory finished moving/copying?
# #

View File

@ -4,6 +4,7 @@ import math
import os import os
import copy import copy
import media.update.replaygain as gain
from media.monitor.exceptions import BadSongFile from media.monitor.exceptions import BadSongFile
from media.monitor.log import Loggable from media.monitor.log import Loggable
import media.monitor.pure as mmp import media.monitor.pure as mmp
@ -57,7 +58,8 @@ airtime_special = {
"MDATA_KEY_MIME" : "MDATA_KEY_MIME" :
lambda m: m.mime[0] if len(m.mime) > 0 else u'', lambda m: m.mime[0] if len(m.mime) > 0 else u'',
} }
mutagen2airtime = dict( (v,k) for k,v in airtime2mutagen.iteritems() if isinstance(v, str) ) mutagen2airtime = dict( (v,k) for k,v in airtime2mutagen.iteritems()
if isinstance(v, str) )
truncate_table = { truncate_table = {
'MDATA_KEY_GENRE' : 64, 'MDATA_KEY_GENRE' : 64,
@ -158,9 +160,9 @@ class Metadata(Loggable):
# Finally, we "normalize" all the metadata here: # Finally, we "normalize" all the metadata here:
self.__metadata = mmp.normalized_metadata(self.__metadata, fpath) self.__metadata = mmp.normalized_metadata(self.__metadata, fpath)
# Now we must load the md5: # Now we must load the md5:
self.__metadata['MDATA_KEY_MD5'] = mmp.file_md5(fpath) self.__metadata['MDATA_KEY_MD5'] = mmp.file_md5(fpath,max_length=-1)
#self.__metadata['MDATA_KEY_REPLAYGAIN'] = \ self.__metadata['MDATA_KEY_REPLAYGAIN'] = \
#gain.calculate_replay_gain(fpath) gain.calculate_replay_gain(fpath)
def is_recorded(self): def is_recorded(self):
return mmp.is_airtime_recorded( self.__metadata ) return mmp.is_airtime_recorded( self.__metadata )