I am trying to write a Python script to extract metadata tags from some mp3 files. Specifically, I am looking to extract "Album" and "Encoded by", which are available if I right-click on the files and look under details:
I am using currently using the eyeD3 library to parse metadata. I am using this library because I thought it would easily accomplish my task, but I am not married to it.
I am able to extract the "Album" easily enough, but not the "Encoded by" field. If I print out all the song tags, I do not see anything like the "Encoded by" field I need. Any ideas, please?
Here is my code:
import eyed3
def main():
music_file = r'G:\Music Collection\54-40\Sweeter Things A Compilation\01 Miss You - 54-40.mp3'
audiofile = eyed3.load(music_file)
for attribute_name in dir(audiofile.tag):
attribute_value = getattr(audiofile.tag, attribute_name)
print attribute_name, attribute_value
if __name__ == "__main__":
main()
print 'done'
If you're willing to switch away from eyed3, the Mutagen library is worth a shot. It's actively maintained on bitbucket (https://bitbucket.org/lazka/mutagen).
Here's an example of pulling the "Encoded By" field from an id3v2 tag in Mutagen:
Prints:
The "encoded by" tag you're looking for is
TENC
in ID3 2.3/2.4. Is it not popping up?It turns out the "Encoded by" field is buried in a list returned by the
frame_set
object:audiofile.tag.frame_set['TENC'][0].text