mirror of
https://github.com/correl/dejavu.git
synced 2024-11-27 11:09:51 +00:00
fixed multiple issues to prevent refingerprinting songs in same dejavu instance
* fixed code to prevent refingerprinting song if it is already fingerprinted in fingerprint_file() * fixed code to prevent multiple fingerprinting of songs in same dejavu instance
This commit is contained in:
parent
3fe99ac5c3
commit
ea748847ed
1 changed files with 17 additions and 8 deletions
|
@ -22,7 +22,9 @@ class Dejavu(object):
|
||||||
self.limit = self.config.get("fingerprint_limit", None)
|
self.limit = self.config.get("fingerprint_limit", None)
|
||||||
if self.limit == -1: # for JSON compatibility
|
if self.limit == -1: # for JSON compatibility
|
||||||
self.limit = None
|
self.limit = None
|
||||||
|
self.get_fingerprinted_songs()
|
||||||
|
|
||||||
|
def get_fingerprinted_songs(self):
|
||||||
# get songs previously indexed
|
# get songs previously indexed
|
||||||
# TODO: should probably use a checksum of the file instead of filename
|
# TODO: should probably use a checksum of the file instead of filename
|
||||||
self.songs = self.db.get_songs()
|
self.songs = self.db.get_songs()
|
||||||
|
@ -79,22 +81,29 @@ class Dejavu(object):
|
||||||
sid = self.db.insert_song(song_name)
|
sid = self.db.insert_song(song_name)
|
||||||
|
|
||||||
self.db.insert_hashes(sid, hashes)
|
self.db.insert_hashes(sid, hashes)
|
||||||
|
|
||||||
self.db.set_song_fingerprinted(sid)
|
self.db.set_song_fingerprinted(sid)
|
||||||
|
self.get_fingerprinted_songs()
|
||||||
|
|
||||||
pool.close()
|
pool.close()
|
||||||
pool.join()
|
pool.join()
|
||||||
|
|
||||||
def fingerprint_file(self, filepath, song_name=None):
|
def fingerprint_file(self, filepath, song_name=None):
|
||||||
song_name, hashes = _fingerprint_worker(filepath,
|
|
||||||
self.limit,
|
|
||||||
song_name=song_name)
|
|
||||||
|
|
||||||
sid = self.db.insert_song(song_name)
|
songname = decoder.path_to_songname(filepath)
|
||||||
|
song_name = song_name or songname
|
||||||
|
# don't refingerprint already fingerprinted files
|
||||||
|
if song_name in self.songnames_set:
|
||||||
|
print "%s already fingerprinted, continuing..." % song_name
|
||||||
|
else:
|
||||||
|
song_name, hashes = _fingerprint_worker(filepath,
|
||||||
|
self.limit,
|
||||||
|
song_name=song_name)
|
||||||
|
|
||||||
self.db.insert_hashes(sid, hashes)
|
sid = self.db.insert_song(song_name)
|
||||||
|
|
||||||
self.db.set_song_fingerprinted(sid)
|
self.db.insert_hashes(sid, hashes)
|
||||||
|
self.db.set_song_fingerprinted(sid)
|
||||||
|
self.get_fingerprinted_songs()
|
||||||
|
|
||||||
def find_matches(self, samples, Fs=fingerprint.DEFAULT_FS):
|
def find_matches(self, samples, Fs=fingerprint.DEFAULT_FS):
|
||||||
hashes = fingerprint.fingerprint(samples, Fs=Fs)
|
hashes = fingerprint.fingerprint(samples, Fs=Fs)
|
||||||
|
|
Loading…
Reference in a new issue