Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using eyeD3 to embed album art from URL

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.

like image 751
Chris James Avatar asked Oct 19 '25 09:10

Chris James


1 Answers

You can use urllib2 to get image data of the image from URL and then use it in eyed3.

import urllib2
response = urllib2.urlopen(your image url)  
imagedata = response.read()

import eyed3
file = eyed3.load("song.mp3")
file.tag.images.set(3, imagedata , "image/jpeg" ,u"Description")
file.tag.save()
like image 129
rahul john Avatar answered Oct 21 '25 23:10

rahul john



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!