コード例 #1
0
ファイル: py-new.py プロジェクト: nirster/dotfiles
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
コード例 #2
0
ファイル: lastid.py プロジェクト: navinpai/beets
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
コード例 #3
0
ファイル: lastid.py プロジェクト: mdecker/beets
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
コード例 #4
0
ファイル: lastmatch.py プロジェクト: beetbox/pylastfp
if __name__ == '__main__':
    args = sys.argv[1:]
    if not args:
        print("usage: python lastmatch.py [-m] mysterious_music.mp3 [...]")
        sys.exit(1)
    if args[0] == '-m':
        match_func = lastfp.mad_match
        args.pop(0)
    else:
        match_func = lastfp.gst_match
        
    for path in args:
        path = os.path.abspath(os.path.expanduser(path))

        # Perform match.
        try:
            xml = match_func(API_KEY, path)
        except lastfp.ExtractionError:
            print('fingerprinting failed!')
            sys.exit(1)
        except lastfp.QueryError:
            print('could not match fingerprint!')
            sys.exit(1)

        # Show results.
        matches = lastfp.parse_metadata(xml)
        for track in matches:
            print('%f: %s - %s' % (track['rank'], track['artist'],
                                   track['title']))
コード例 #5
0
if __name__ == '__main__':
    args = sys.argv[1:]
    if not args:
        print "usage: python lastmatch.py [-m] mysterious_music.mp3 [...]"
        sys.exit(1)
    if args[0] == '-m':
        match_func = lastfp.mad_match
        args.pop(0)
    else:
        match_func = lastfp.gst_match

    for path in args:
        path = os.path.abspath(os.path.expanduser(path))

        # Perform match.
        try:
            xml = match_func(API_KEY, path)
        except lastfp.ExtractionError:
            print 'fingerprinting failed!'
            sys.exit(1)
        except lastfp.QueryError:
            print 'could not match fingerprint!'
            sys.exit(1)

        # Show results.
        matches = lastfp.parse_metadata(xml)
        for track in matches:
            print '%f: %s - %s' % (track['rank'], track['artist'],
                                   track['title'])