从mp3中查找缺少的id3标记

2024-05-18 23:07:57 发布

您现在位置:Python中文网/ 问答频道 /正文

import pygn

clientID = '3407104-E4255A7F76297EB4C49C2A9A26112342' # Enter your Client ID here

userID = pygn.register(clientID)

metadata = pygn.search(clientID=clientID, userID=userID, artist='Nelly', album='', track='Hot In Here')

print (metadata)

Im使用pygn(鸽子)为gracenote开发的python客户端来查找mp3文件中缺失的id3标记。我的代码将所有音乐文件元数据打印到屏幕上,但我只想打印曲目标题、艺术家和专辑?在


Tags: importclientregisteridsearchyourhereartist
2条回答

API返回给您一个gnmetadata对象,您可以像使用字典一样使用它。在

>>> type(metadata)
<class 'pygn.gnmetadata'>
>>> metadata.__class__.__bases__
(<type 'dict'>,)
# so it's a dict...

>>> metadata.keys()
['track_title', 'album_artist_name', 'mood', 'artist_bio_url', 'artist_image_url', 'artist_era', 'album_year', 'radio_id', 'tempo', 'track_gnid', 'track_number', 'review_url', 'album_art_url', 'tracks', 'xid', 'album_gnid', 'artist_origin', 'genre', 'album_title', 'track_artist_name', 'artist_type']

>>> metadata['track_title']
'Hot In Herre'
>>> metadata['album_artist_name']
'Nelly'
>>> metadata['album_title']
'Nellyville'

有趣的是,曲目标题显然是错的。在

^{}是一个类,它是一个字典,包含可用于查询项的元数据字段。在

所以这应该有效(未经测试):

# run code as before

print(metadata['track_title'])
print(metadata['track_artist_name'])
print(metadata['album_artist_name'])
print(metadata['album_title'])

相关问题 更多 >

    热门问题