Skip to content Skip to sidebar Skip to footer

Retrieve Lyrics From An Mp3 File In Python Using Eyed3

I am currently trying to use Python and its eyeD3 library to extract the lyrics from an mp3 file. The lyrics have been embedded into the mp3 file already (via: MusicBee). I am tryi

Solution 1:

It looks like that is a iterator. Try

tag.lyrics[0]

or

for lyric in tag.lyrics:
  print lyric

last resort print the objects directory and look for useful functions

printdir(tag.lyrics)

Solution 2:

u"".join([i.text for i in tag.lyrics])

Solution 3:

DonJuma, Python tells you:

<iteratorobject at hex_location> 

You can try the following but it fails on strings

hasattr(myObj, '__iter__')

user:mindu explains here that you can write a robust function that checks

try:
    some_object_iterator = iter(some_object)
except TypeError, te:
    print some_object, 'is not iterable'

BUT!!! This is not Pythonic. Python believes in Duck Typing which basically says, "If it looks like a duck and quacks like a duck, it must be a duck." See the link for more info.

Post a Comment for "Retrieve Lyrics From An Mp3 File In Python Using Eyed3"