def get_finger_print(audio_file): API_KEY = '7821ee9bf9937b7f94af2abecced8ddd' xml = lastfp.gst_match(API_KEY, audio_file) matches = lastfp.parse_metadata(xml) song_artist = matches[0]['artist'] song_title = matches[0]['title'] if isinstance(song_artist,unicode): song_artist = translit(matches[0]['artist']) if isinstance(song_title,unicode): song_title = translit(matches[0]['title']) return song_title,song_artist
def match(path, metadata=None): """Gets the metadata from Last.fm for the indicated track. Returns a dictionary with these keys: rank, artist, artist_mbid, title, track_mbid. May return None if fingerprinting or lookup fails. Caches the result, so multiple calls may be made efficiently. """ if path in _match_cache: return _match_cache[path] # Actually perform fingerprinting and lookup. try: xml = lastfp.gst_match(API_KEY, path, metadata) matches = lastfp.parse_metadata(xml) except lastfp.FingerprintError: # Fail silently and cache the failure. matches = None match = matches[0] if matches else None _match_cache[path] = match return match