0

我正在使用 Python3 eyed3 lib 将一些元数据写入 mp3 文件。现在我尝试使用 eyed3 Python lib 将专辑图像写入 mp3 文件,如下所示:

    @staticmethod
    def set_music_meta_data(music: Music, local_file_path: str):
        try:
            audio_file: AudioFile = eyed3.load(local_file_path, tag_version=ID3_V2_4)
            if audio_file.tag.artist is None:
                artists_str = music.artists
                artists_json: Artist = json.loads(artists_str)
                audio_file.tag.artist = artists_json[0]["name"]
            if audio_file.tag.title is None:
                audio_file.tag.title = music.name
            if audio_file.tag.album is None:
                album_str = music.album
                album_json: Album = json.loads(album_str)
                audio_file.tag.album = album_json["name"]
            if audio_file.tag.images is None:
                album_str = music.album
                album_json: Album = json.loads(album_str)
                album_image_url = album_json["coverImageUrl"]
                http = urllib3.PoolManager()
                image_response = http.request("GET", album_image_url)
                audio_file.tag.images.set(3, image_response.read(), "image/jpeg", u"demo")
            audio_file.tag.save(local_file_path)
        except Exception as e:
            logger.error("set metadata failed", e)

调试器显示图像是受保护的属性,我可以将图像元数据写入 mp3 文件吗?为什么显示图像是受保护的属性?我应该怎么做才能将专辑图像写入 mp3 文件?

4

0 回答 0