finding missing id3 tags from mp3

307 Views Asked by At
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 using pygn(pigeon) a python client for gracenote to find missing id3 tags form mp3 files. The code i have prints all the music files metadata to the screen but i only want to print the Track-title, Artist and Album ?

2

There are 2 best solutions below

0
On

metadatais a class that is a dictionary containing metadata fields that are available for the queried item.

So this should work (untested):

# run code as before

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

The API returns to you a gnmetadata object which you can use like a dictionary.

>>> 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'

It's interesting that the track title is apparently wrong.