0

I have a problem that confused me. I want to get metadata (especially genre, artist) in python and I've tried some way to do this but each of them return null.

I want to get at least one feature (genre, artist) and connect it Spotify or Last.fm api to get information about the raw mp3 file and choose the other file in library for mixing.

Here some code that I tried:

from tinytag import TinyTag

file2 = "/home/orhanors/Desktop/music/yokohama.mp3"
a_tag = TinyTag.get(file2)
print(a_tag)

Result:

{"album": null, "albumartist": null, "artist": null, "audio_offset": 138, "bitrate": 192, "channels": 2, "comment": null, "composer": null, "disc": null, "disc_total": null, "duration": 417.604742145821, "filesize": 10017364, "genre": null, "samplerate": 44100, "title": null, "track": null, "track_total": null, "year": null}

import eyed3

audio = eyed3.load(file2)
print(audio.tag.artist)
print(audio.tag.album)
print(audio.tag.title)

Result:

None
None
None
martineau
  • 119,623
  • 25
  • 170
  • 301
orhanors
  • 9
  • 5
  • 1
    Could it be that the data is simply not encoded in your MP3 file? I mean - the functions works well, and returns some data that looks realistic. Perhaps the encoder did not attach tags. – Amitai Irron May 28 '20 at 20:55
  • I agree with @AmitaiIrron, it could simply be due to the fact that those items are included in the file's metadata. Suggest you use some third-party to verify the information is present in any test file you use for testing your own code. – martineau May 28 '20 at 21:31
  • I tried to download mp3 from other platforms and it worked. Thanks a lot – orhanors May 29 '20 at 16:37

0 Answers0