I have been attempting to use the eyed3 module for tagging mp3 files, but unfortunately, I find the module documentation difficult to understand and was wondering if someone can help me?.. Documentation can be found at https://eyed3.readthedocs.io
I was trying to use it to remove existing album art image using:
import eyed3
x = eyed3.load('file_path')
x.tag._images.remove()
x.tag.save()
But when I run this code, it gives me the following error:
TypeError: remove() missing 1 required positional argument: 'description'
I am not sure where to find the above mentioned description
to pass as a parameter. I have also looked at the source python file for eyed3 tagging, but based on investigating the code, I can't seem to find out what to pass for this argument description
.
I attempted to pass an empty string as the argument, but although the script ran fine without any errors, it did not remove the album art image.
Please help.
答案 0 :(得分:3)
深入研究之后,description
实际上只是图像的描述。调用x.tag.images
时,您将得到一个ImageAccessor对象,该对象基本上只是一个包含图像的可迭代对象。如果将x.tag.images
强制转换为列表,则可以看到它包含1个ImageFrame对象(在我的测试案例中)。当您调用x.tag.images.remove()
时,eyed3需要知道要删除的图像,并且它会根据图像描述选择要删除的图像。您可以使用类似的方法获取每个图像的描述。
[y.description for y in x.tag.images]
一旦知道了要删除图像的描述,便应该将其传递到删除功能中,该特定图像将被删除。
>>> x.tag.images
<eyed3.id3.tag.ImagesAccessor object at 0x1053c8400>
>>> list(x.tag.images)
[<eyed3.id3.frames.ImageFrame object at 0x1050cc4a8>]
>>> x.tag.images.remove()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jperoutek/test_env/lib/python3.6/site-packages/eyed3/utils/__init__.py", line 170, in wrapped_fn
return fn(*args, **kwargs)
TypeError: remove() missing 1 required positional argument: 'description'
>>> x.tag.images.remove('')
<eyed3.id3.frames.ImageFrame object at 0x1050cc4a8>
>>> x.tag.images
<eyed3.id3.tag.ImagesAccessor object at 0x1053c8400>
>>> list(x.tag.images)
[]