From 5b29974b5df39af70f21422310c2138971fe41ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Smolka?= <30924797+ttimer@users.noreply.github.com> Date: Sat, 26 Dec 2020 17:44:59 +0100 Subject: [PATCH] Update mid3v2.py With mime type '-->' a URL has to be stored in 'data' instead of the embedded picture. --- mutagen/_tools/mid3v2.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/mutagen/_tools/mid3v2.py b/mutagen/_tools/mid3v2.py index db78514c..6520f9ae 100644 --- a/mutagen/_tools/mid3v2.py +++ b/mutagen/_tools/mid3v2.py @@ -258,11 +258,24 @@ def write_files(edits, filenames, escape): encoding = get_frame_encoding(frame, desc) - try: - with open(fn, "rb") as h: - data = h.read() - except IOError as e: - error(str(e)) +# START - J.Smolka (ttimer) - Mime type: --> +# With mime type '-->' a URL has to be stored in 'data' instead of the embedded picture. +# +# try: +# with open(fn, "rb") as h: +# data = h.read() +# except IOError as e: +# error(str(e)) + + if mime == "-->": + data = fn + else: + try: + with open(fn, "rb") as h: + data = h.read() + except IOError as e: + error(text_type(e)) +# END - J.Smolka (ttimer) - Mime type: --> frame = mutagen.id3.APIC(encoding=encoding, mime=mime, desc=desc, type=picture_type, data=data)