Permalink
Browse files

Nicer error message

  • Loading branch information...
1 parent 64a9f5e commit 03164fdfe1acccac5e5b202c31046d232aed2f69 @tjehan tjehan committed Jun 24, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 examples/lookup.py
View
@@ -23,8 +23,11 @@ def lookup(file):
# The version parameter to song/identify indicates the use of echoprint
result = song.identify(query_obj=fp, version="4.11")
print "Got result:", result
- print "Artist: %s (%s)" % (result[0].artist_name, result[0].artist_id)
- print "Song: %s (%s)" % (result[0].title, result[0].id)
+ if len(result):
+ print "Artist: %s (%s)" % (result[0].artist_name, result[0].artist_id)
+ print "Song: %s (%s)" % (result[0].title, result[0].id)
+ else:
+ print "No match. This track may not be in the database yet."
else:
print "Couldn't decode", file

0 comments on commit 03164fd

Please sign in to comment.