Offset cast to int, return is valid JSON. Fixes #67

This commit is contained in:
Will Drevo 2015-01-14 20:32:49 -05:00
parent 801b692f74
commit dad98961f4

View file

@ -156,7 +156,7 @@ class Dejavu(object):
Dejavu.SONG_ID: song_id, Dejavu.SONG_ID: song_id,
Dejavu.SONG_NAME: songname, Dejavu.SONG_NAME: songname,
Dejavu.CONFIDENCE: largest_count, Dejavu.CONFIDENCE: largest_count,
Dejavu.OFFSET: largest, Dejavu.OFFSET: int(largest),
Dejavu.OFFSET_SECS: nseconds Dejavu.OFFSET_SECS: nseconds
} }
@ -176,14 +176,11 @@ def _fingerprint_worker(filename, limit=None, song_name=None):
pass pass
songname, extension = os.path.splitext(os.path.basename(filename)) songname, extension = os.path.splitext(os.path.basename(filename))
song_name = song_name or songname song_name = song_name or songname
channels, Fs = decoder.read(filename, limit) channels, Fs = decoder.read(filename, limit)
result = set() result = set()
channel_amount = len(channels) channel_amount = len(channels)
for channeln, channel in enumerate(channels): for channeln, channel in enumerate(channels):
# TODO: Remove prints or change them into optional logging. # TODO: Remove prints or change them into optional logging.
print("Fingerprinting channel %d/%d for %s" % (channeln + 1, print("Fingerprinting channel %d/%d for %s" % (channeln + 1,
@ -192,7 +189,6 @@ def _fingerprint_worker(filename, limit=None, song_name=None):
hashes = fingerprint.fingerprint(channel, Fs=Fs) hashes = fingerprint.fingerprint(channel, Fs=Fs)
print("Finished channel %d/%d for %s" % (channeln + 1, channel_amount, print("Finished channel %d/%d for %s" % (channeln + 1, channel_amount,
filename)) filename))
result |= set(hashes) result |= set(hashes)
return song_name, result return song_name, result