diff --git a/dejavu/control.py b/dejavu/control.py index 9007707..85144be 100644 --- a/dejavu/control.py +++ b/dejavu/control.py @@ -58,8 +58,14 @@ class Dejavu(): processes.append(p) # wait for all processes to complete - for p in processes: - p.join() + try: + for p in processes: + p.join() + except KeyboardInterrupt: + print "-> Exiting.." + for worker in processes: + worker.terminate() + worker.join() # delete orphans # print "Done fingerprinting. Deleting orphaned fingerprints..." @@ -77,11 +83,16 @@ class Dejavu(): # convert to WAV wavout_path = self.converter.convert(filename, extension, Converter.WAV, output) + # for each channel perform FFT analysis and fingerprinting + try: + channels = self.extract_channels(wavout_path) + except AssertionError, e: + print "-> File not supported, skipping." + continue + # insert song name into database song_id = sql_connection.insert_song(filename) - # for each channel perform FFT analysis and fingerprinting - channels = self.extract_channels(wavout_path) for c in range(len(channels)): channel = channels[c] print "-> Fingerprinting channel %d of song %s..." % (c+1, filename) @@ -89,7 +100,6 @@ class Dejavu(): # remove wav file if not required if not keep_wav: - print "removing ", wavout_path os.unlink(wavout_path) # only after done fingerprinting do confirm diff --git a/dejavu/convert.py b/dejavu/convert.py index 34ac0fe..61f673d 100644 --- a/dejavu/convert.py +++ b/dejavu/convert.py @@ -24,7 +24,7 @@ class Converter(): filepaths = [] extensions = [e.replace(".", "") for e in extensions if e.replace(".", "") in Converter.FORMATS] print "Supported formats: %s" % extensions - for dirpath, dirnames, files in os.walk(path) : + for dirpath, dirnames, files in os.walk(path): for extension in extensions: for f in fnmatch.filter(files, "*.%s" % extension): p = os.path.join(dirpath, f) @@ -46,7 +46,7 @@ class Converter(): else: mp3file = AudioSegment.from_mp3(orig_path) if self.max_input_len: - print "Reading input seconds: ", self.max_input_len + print "-> Reading input seconds: ", self.max_input_len mp3file = mp3file[:self.max_input_len * 1000] mp3file.export(newpath, format=Converter.WAV)