pythonmp3eyed3

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


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.


Solution

  • Title and Artists are available through accessor functions of the Tag() return value. The example below shows how to get them using getArtist() and getTitle() methods.

     import eyed3
     tag = eyed3.Tag()
     tag.link("/some/file.mp3")
     print tag.getArtist()
     print tag.getTitle()