worldveil / dejavu

Audio fingerprinting and recognition in Python
MIT License
6.41k stars 1.43k forks source link

"TypeError" exception when a song is not recognized #1

Closed pguridi closed 10 years ago

pguridi commented 10 years ago

when checking a song and there is no positive match, using: .. recognizer = Recognizer(dejavu.fingerprinter, config) res = recognizer.read("14622976.wav")

throws the following exception, would be nice if a "NotFound" exception is throwed instead. *EDIT: or return None.

Traceback (most recent call last):
  File "checksong.py", line 14, in <module>
    res = recognizer.read("14622976.wav")
  File "dejavu/dejavu/recognize.py", line 40, in read
        return self.fingerprinter.align_matches(matches, starttime, verbose=verbose)
  File "dejavu/dejavu/fingerprint.py", line 206, in align_matches
    songname = self.db.get_song_by_id(song_id)    [SQLDatabase.FIELD_SONGNAME]
TypeError: 'NoneType' object has no attribute '__getitem__'