0

我正在尝试使用枕头下载图像,然后将该图像提供给 eyed3 以用作专辑封面,但出现以下错误:

TypeError: can't concat JpegImageFile to bytes

        response = requests.get(album_art_url)
        img = Image.open(BytesIO(response.content))
            audiofile = eyed3.load(f"{self.current_song_name}-{self.current_song_url}.mp3")
            audiofile.tag.images.set(type_=3, img_data=img,
                                     mime_type="image/jpeg",
                                     description=None, 
                                     img_url=None)
            audiofile.tag.save()
4

1 回答 1

0

根据此处的答案尝试此解决方案如何使用 eyed3 python 模块为 mp3 设置缩略图?

import eyed3
import urllib.request

audiofile = eyed3.load(f"{self.current_song_name}-{self.current_song_url}.mp3")

audiofile.initTag(version=(2, 3, 0))  # version is important
response = urllib.request.urlopen(album_art_url)
imagedata = response.read()
audiofile.tag.images.set(3, imagedata, "image/jpeg", u"cover")
audiofile.tag.save()
于 2021-07-11T16:09:13.507 回答