i am working on a python script that downloads a music file from a server and then adds an album image to it from a URL, for this i am using the eyeD3 python library my original code below.
import eyed3
mySong = eyed3.load('C:\Users\PC\Music\Test.mp3')
mySong.tag.album_artist = u'Artist-Name'
mySong.tag.images.remove(u'')
mySong.tag.images.set(3, 'None', 'https://upload.wikimedia.org/wikipedia/en/6/60/Recovery_Album_Cover.jpg')
mySong.tag.save()
I have tried different versions of this command and it either returns no errors but does not embed the image as the above code does or returns an error message stating "ValueError: img_url MUST not be none when no image data".
Anyone had any success with this part of eyeD3 before my other alternative is download image direct from URL store in a folder and embed from there then delete obviously my other solution would be better.
Use
mySong.tag.images.set(type_=3, img_data=None, mime_type=None, description=u"you can put a description here", img_url=u"https://upload.wikimedia.org/wikipedia/en/6/60/Recovery_Album_Cover.jpg")
Explanation:
mySong.tag.images.set
is calling the set
function of the class ImagesAccessor
defined in src/eyed3/id3/tag.py
.
The signature is as follows:
def set(self, type_, img_data, mime_type, description=u"", img_url=None):
"""Add an image of ``type_`` (a type constant from ImageFrame).
The ``img_data`` is either bytes or ``None``. In the latter case
``img_url`` MUST be the URL to the image. In this case ``mime_type``
is ignored and "-->" is used to signal this as a link and not data
(per the ID3 spec)."""