How to access MP3 metadata in Python

In this tutorial, I will show you how to get the metadata of an Audio file or MP3 file using eyed3 in Python.

Here we are going to see how to access MP3 metadata in Python in a simple way. We will use the eyeD3 tool.

The best alternative is: access metadata of a file in Python using tinytag

eyeD3:

  • It is a Python module that is used to work with audio files.
  • It is a command-line program to process ID3 tags.
  • Using this, we can extract the metadata like the title of the song, artist, album, composer, release date, publisher, etc.
  • Installation: Type the following command in the command prompt.
    pip install eyed3

At first, we have imported the eyed3 library. Then we used eyed3.load() to load the mp3 file.

  • Syntax: eyed3.load(filename)

To access the meta tag information of an MP3 you have to use the tag object. View the content of the tag using the following.

  • audio.tag.title– used to get the title of the song.
  • audio.tag.artist– used to get the artist’s name of the song.
  • audio.tag.album– used to get the album name of the song.
  • audio.tag.album_artist– used to get the album artist’s name.
  • audio.tag.composer– used for getting the composer of the song.
  • audio.tag.publisher– used for getting the publisher of the song.
  • audio.tag.genre– used for getting the genre of a particular song.
  • audio.tag.release_date– used for getting the release date of the song.

Now, we have a look at the program.

import eyed3
audio=eyed3.load("Maacho.mp3")
print("Title:",audio.tag.title)
print("Artist:",audio.tag.artist)
print("Album:",audio.tag.album)
print("Album artist:",audio.tag.album_artist)
print("Composer:",audio.tag.composer)
print("Publisher:",audio.tag.publisher)

Output:

Title: Maacho - SenSongsMp3.Co
Artist: Shweta Mohan, Sid Sriram, A.R. Rahman
Album: Mersal (2017)
Album artist: Vijay, Kajal Agarwal, Samantha, Nithya Menon
Composer: A.R.Rahman
Publisher: SenSongsMp3.Co

I hope that you have learned something new from this post.

Leave a Reply

Your email address will not be published. Required fields are marked *