fixes #3, now song_name column in database has the full path

This commit is contained in:
Pedro Guridi 2013-12-17 19:54:04 -03:00
parent 0b36781ccd
commit 6a4d386736
2 changed files with 6 additions and 8 deletions

View file

@ -69,24 +69,22 @@ class Dejavu():
def fingerprint_worker(self, files, sql_connection, output, keep_wav): def fingerprint_worker(self, files, sql_connection, output, keep_wav):
for filename, extension in files: for filename, extension in files:
# if there are already fingerprints in database, don't re-fingerprint or convert # if there are already fingerprints in database, don't re-fingerprint or convert
song_name = os.path.basename(filename).split(".")[0] if filename in self.songnames_set:
if song_name in self.songnames_set:
print "-> Already fingerprinted, continuing..." print "-> Already fingerprinted, continuing..."
continue continue
# convert to WAV # convert to WAV
wavout_path = self.converter.convert(filename, extension, Converter.WAV, output, song_name) wavout_path = self.converter.convert(filename, extension, Converter.WAV, output)
# insert song name into database # insert song name into database
song_id = sql_connection.insert_song(song_name) song_id = sql_connection.insert_song(filename)
# for each channel perform FFT analysis and fingerprinting # for each channel perform FFT analysis and fingerprinting
channels = self.extract_channels(wavout_path) channels = self.extract_channels(wavout_path)
for c in range(len(channels)): for c in range(len(channels)):
channel = channels[c] channel = channels[c]
print "-> Fingerprinting channel %d of song %s..." % (c+1, song_name) print "-> Fingerprinting channel %d of song %s..." % (c+1, filename)
self.fingerprinter.fingerprint(channel, wavout_path, song_id, c+1) self.fingerprinter.fingerprint(channel, wavout_path, song_id, c+1)
# remove wav file if not required # remove wav file if not required

View file

@ -30,8 +30,8 @@ class Converter():
filepaths.append((renamed, extension)) filepaths.append((renamed, extension))
return filepaths return filepaths
def convert(self, orig_path, from_format, to_format, output_folder, song_name): def convert(self, orig_path, from_format, to_format, output_folder):
path, song_name = os.path.split(orig_path)
# start conversion # start conversion
self.ensure_folder(output_folder) self.ensure_folder(output_folder)
print "-> Now converting: %s from %s format to %s format..." % (song_name, from_format, to_format) print "-> Now converting: %s from %s format to %s format..." % (song_name, from_format, to_format)