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

后端 未结 5 1089
不思量自难忘°
不思量自难忘° 2021-01-15 15:57

Here is my code

import eyed3

audiofile = eyed3.load(\"19 Calvin Harris - Summer.mp3\")

print(audiofile.tag.artist)

This is an error

5条回答
  •  不要未来只要你来
    2021-01-15 16:16

    I think the problem lies within the module.

    I did some debugging using this code:

    from eyed3 import id3
    
    tag = id3.Tag()
    tag.parse("myfile.mp3")
    print(tag.artist)
    

    In the parse function, the file is opened and then passed to _loadV2Tag(fileobject). Then, the module reads the first few lines of the file header and checks if it begins with ID3.

    if f.read(3) != "ID3":
        return False
    

    And here it returns false and I think this is where the error lies, because if I try to read the header myself, it is most definitely ID3.

    >>> f = open("myfile.mp3", "rb")
    >>> print(f.read(3))
    b'ID3'
    

    But full python3 support is not to be expected until version 0.8 according to https://bitbucket.org/nicfit/eyed3/issues/25/python-3-compatibilty which is available here: https://bitbucket.org/nicfit/eyed3/branch/py3

提交回复
热议问题