quodlibet / mutagen

Python module for handling audio metadata
https://mutagen.readthedocs.io
GNU General Public License v2.0
1.57k stars 158 forks source link

Doing ID3 APIC with mime type '-->' documentation missing #503

Open steveliem opened 4 years ago

steveliem commented 4 years ago

In the code I detected a similar commentary like in the ID3 specs: There is the possibility to put only a link to the image file by using the 'MIME type' "-->" and having a complete URL instead of picture data.

But I can't find anywhere in the documentation how to implement this in my client code. I need a working example how to do

from mutagen.id3 import ID3, APIC

audio = ID3('music.mp3')
with open('cover.png', 'rb') as albumart:
    audio['APIC'] = APIC(
                      encoding=3,
                      mime='-->',
                      type=3, desc=u'Cover',
                      data=?????????
                    )

audio.save()

with a URL reference from an online artwork jpg or png.

Thanks.

lazka commented 4 years ago

good question, that not very commonly used I think. data=myurl.encode("ascii") should work

steveliem commented 4 years ago

good question, that not very commonly used I think. data=myurl.encode("ascii") should work

Thanks for the tip. I've tested the code. There where no error messages from Python but also when I played the resulting MP3 I didn't see any artwork inside. :-)

from mutagen.id3 import ID3, APIC
import logging

logging.basicConfig(level=logging.DEBUG)

myurl = 'http://cdn.imgbin.com/2/9/13/imgbin-phonograph-record-album-cover-mockup-record-sleeve-design-iLirQ5rFK2yjs9Q51GyjTuv2S.jpg'

audio = ID3('music.mp3')
audio['APIC'] = APIC(
                  encoding=3,
                  mime='-->',
                  type=3, desc=u'Cover',
                  data=myurl.encode('ascii')
                )

audio.save()

I also didn't got any debug logs or verbose logs unfortunately.

phw commented 4 years ago

You'd need to test with a player where you know for sure loading APIC with remote URL is supported. Actually I think this might be the bigger issue, this feature in general does neither seem widely known nor used.

steveliem commented 4 years ago

You'd need to test with a player where you know for sure loading APIC with remote URL is supported. Actually I think this might be the bigger issue, this feature in general does neither seem widely known nor used.

Unfortunately there is not much information to find around this. Most vendors from the big players don't seem to expose these type of details. Even here https://id3.org/id3v2.3.0#URL_link_frames_-_details the documentation is not 100% around the use of APIC and "-->".

It is a very handy feature to have if it was supported. You'll have an idea about where MP3 files are located the moment a user is listening for the first time. Like collecting bread crumbs on the internet.

lazka commented 4 years ago

It is a very handy feature to have if it was supported. You'll have an idea about where MP3 files are located the moment a user is listening for the first time. Like collecting bread crumbs on the internet.

That might be one reason why no one implemented this :)