How to get detail (Title,Artist) from .mp3 files in python using eyed3

Chanon Deeprasertkul picture Chanon Deeprasertkul · Apr 17, 2015 · Viewed 16.7k times · Source

Here is my code

import eyed3

audiofile = eyed3.load("19 Calvin Harris - Summer.mp3")

print(audiofile.tag.artist)

This is an error

Traceback (most recent call last):
  File "C:\Python34\testmp3.py", line 5, in <module>
    print(audiofile.tag.artist)
AttributeError: 'NoneType' object has no attribute 'artist'

There's attributes shown in Visual Studio. but when i run it.an error occurred

when i write print(audiofile) it works. i don't know why ps. Python 3.4.

Answer

Yugansh Tyagi picture Yugansh Tyagi · Jul 10, 2017

Try this Code , it worked for me

import eyed3

def show_info():
    audio = eyed3.load("[PATH_TO_MP3]")
    print audio.tag.artist
    print audio.tag.album
    print audio.tag.title

show_info()