3

So, I am using mutagen to get information about uploaded musics in my website. I tried the following code:

import mutagen
mutagen.File(filePath)

it displays the following message:

{'TXXX:compatible_brands': TXXX(encoding=<Encoding.UTF8: 3>, desc='compatible_brands', text=['isommp42']), 'TXXX:minor_version': TXXX(encoding=<Encoding.UTF8: 3>, desc='minor_version', text=['0']), 'TXXX:major_brand': TXXX(encoding=<Encoding.UTF8: 3>, desc='major_brand', text=['mp42']), 'TSSE': TSSE(encoding=<Encoding.UTF8: 3>, text=['Lavf57.56.101'])}

Isn't this code supposed to print artist and title as described in their documentation? I am confused. Is it encoded? if so, how do I decode it?

Found the solution: See answer below

Sphinx
  • 394
  • 3
  • 17
  • whats the file type for the file you are passing? and what actually you are getting in the filePath parameter? – Exprator Mar 11 '19 at 08:08
  • @Exprator filePath = 'musics/a.mp3' – Sphinx Mar 11 '19 at 08:16
  • no you cant send 'musics/a.mp3' to mutagen, you need to do `mutagen.File('a.mp3')` – Exprator Mar 11 '19 at 09:00
  • @Exprator i get the same thing again. and, why can't i send the file path? I don't understand the documentation well. My files are saved in a directory and i want my django view to get the artist and title of the music files. How do i achieve using mutagen? – Sphinx Mar 11 '19 at 14:56

1 Answers1

5

try

mutagen.File(filePath, easy=True)

this should work. Note: if you get {} after trying this code, your music file has no meta data.

Sphinx
  • 394
  • 3
  • 17