Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_repr(self):
frame = APIC(encoding=0, mime=u"m", type=3, desc=u"d", data=b"\x42")
expected = (
"APIC(encoding=, mime='m', "
"type=, desc='d', data=b'B')")
self.assertEqual(repr(frame), expected)
new_frame = APIC()
new_frame._readData(_24, frame._writeData())
self.assertEqual(repr(new_frame), expected)
files_in_cd = os.listdir(os.getcwd())
for i in files_in_cd:
if i.endswith(".mp3"):
file = os.getcwd() + "\\" + i
try:
print ("Tagging \\" + file.split("\\")[-1])
except:
print ("Tagging (Special charaters in name)")
audio = MP3(file, ID3=ID3)
try:
audio.add_tags()
except error:
pass
urllib.request.urlretrieve(song_data[song]['ablum_art'], (os.getcwd() + "/TempAArtImage.jpg"))
audio.tags.add(APIC(encoding=3, mime='image/jpeg', type=3, desc=u'cover', data=open(os.getcwd() + "/TempAArtImage.jpg", 'rb').read()))
audio.save()
os.remove(os.getcwd() + "/TempAArtImage.jpg")
audio = EasyID3(file)
audio["tracknumber"] = song_data[song]['track']
audio["title"] = song_data[song]['title']
audio["album"] = song_data[song]['album']
audio["artist"] = song_data[song]['artist']
audio.save()
if not os.path.exists(os.getcwd() + "/output/"):
os.makedirs(os.getcwd() + "/output/")
title = stripString(song_data[song]['title'])
artist = stripString(song_data[song]['artist'])
album = stripString(song_data[song]['album'])
try:
with translate_errors():
audio = self.Kind(self["~filename"])
if audio.tags is None:
audio.add_tags()
tag = audio.tags
try:
data = image.read()
except EnvironmentError as e:
raise AudioFileError(e)
tag.delall("APIC")
frame = mutagen.id3.APIC(
encoding=3, mime=image.mime_type, type=APICType.COVER_FRONT,
desc=u"", data=data)
tag.add(frame)
with translate_errors():
audio.save()
self.has_images = True
def __set__(self, media_file, artwork):
apic = ID3.APIC(data=artwork.data, mime=artwork.mime)
media_file.mg_file["APIC"] = apic
def embed_image():
audio.tags.add(
id3.APIC(
encoding=3,
mime='image/jpeg',
type=3,
desc='Front Cover',
data=image.data
)
if a.__class__ == mutagen.flac.FLAC:
a['description'] = track['description']
elif a.__class__ == mutagen.mp3.MP3:
a['COMM'] = mutagen.id3.COMM(
encoding=3, lang=u'ENG', text=track['description']
)
if artwork_url:
if a.__class__ == mutagen.flac.FLAC:
p = mutagen.flac.Picture()
p.data = out_file.read()
p.width = 500
p.height = 500
p.type = mutagen.id3.PictureType.COVER_FRONT
a.add_picture(p)
elif a.__class__ == mutagen.mp3.MP3:
a['APIC'] = mutagen.id3.APIC(
encoding=3, mime='image/jpeg', type=3,
desc='Cover', data=out_file.read()
)
a.save()
def mp3_coverart(config):
print("Adding " + config.coverart_mime + " cover art to " + config.mp3_file)
imgdata = open(config.coverart,'rb').read()
audio=MP3(config.mp3_file, ID3=ID3);
audio.tags.add(APIC(encoding=3,
mime=config.coverart_mime,
type=3,
desc='Cover',
data=imgdata))
audio.save()
try:
img = urlopen(albumart) # Gets album art from url
except Exception:
log.log_error("* Could not add album art", indented=True)
return None
audio = EasyMP3(song_title, ID3=ID3)
try:
audio.add_tags()
except _util.error:
pass
audio.tags.add(
APIC(
encoding=3, # UTF-8
mime='image/png',
type=3, # 3 is for album art
desc='Cover',
data=img.read() # Reads and adds album art
)
)
audio.save()
log.log("> Added album art")
if '.png' in artwork_url:
mime = 'image/png'
if '-large' in artwork_url:
new_artwork_url = artwork_url.replace('-large', '-t500x500')
try:
image_data = requests.get(new_artwork_url).content
except Exception as e:
# No very large image available.
image_data = requests.get(artwork_url).content
else:
image_data = requests.get(artwork_url).content
audio = MP3(filename, ID3=OldID3)
audio.tags.add(
APIC(
encoding=3, # 3 is for utf-8
mime=mime,
type=3, # 3 is for the cover image
desc='Cover',
data=image_data
)
)
audio.save()
# because there is software that doesn't seem to use WOAR we save url tag again as WXXX
if url:
audio = MP3(filename, ID3=OldID3)
audio.tags.add( WXXX( encoding=3, url=url ) )
audio.save()
return True