mutagenwmaasf

"ASFUnicodeAttribute" problem when printing wma song titles with mutagen


Hey guys I recently started working with mutagen and I'm facing a very annoying problem. Let´s say I´m trying to print the title of a wma file with mutagen:

from mutagen.asf import ASF

song=r"C:\Users\j2the\Music\The One and Only\Rammstein\Made In Germany\03 Keine Lust.wma"

song_wma=ASF(song)
print(song_wma["Title"])

The code may work fine, but when printing the title of the wma file, python always adds the extension [ASFUnicodeAttribute...] to the actual filename:

[ASFUnicodeAttribute('Keine Lust')]

Is there any way to have the code return only the actual title of the song? Thanks in advance for your help!


Solution

  • Ok I eventually figured out the solution myself. It's actually very simple. All you have to do is iterate over the title tag and voilà: You´re left with only the title of the song:

    for e in song_wma["Title"]:
        print(e)
    

    Outcome:

    Keine Lust