如何使用eyed3模块从Mp3中删除现有的专辑封面图像

时间:2023-01-24 14:52:40

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

我一直试图使用eyed3模块标记mp3文件,但不幸的是,我发现模块文档很难理解,并且想知道是否有人可以帮助我?..文档可以在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.

我不知道在哪里可以找到上述描述作为参数传递。我还查看了eyed3标记的源python文件,但是基于对代码的调查,我似乎无法找到为此参数描述传递的内容。

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.

1 个解决方案

#1


3  

After digging around a bit, description is literally just the description of the image. When you call x.tag.images you get an ImageAccessor object, which is basically just an iterable containing your images. If you cast x.tag.images to a list, you can see it contains 1 ImageFrame object (in my test case). When you call x.tag.images.remove(), eyed3 needs to know which image to remove, and it selects the image to remove based on the image description. You can get the descriptions of each image using something like this.

在挖掘了一下之后,描述实际上只是图像的描述。当你调用x.tag.images时,你得到一个ImageAccessor对象,它基本上只是一个包含你的图像的迭代。如果将x.tag.images转换为列表,则可以看到它包含1个ImageFrame对象(在我的测试用例中)。当你调用x.tag.images.remove()时,eyed3需要知道要删除哪个图像,并根据图像描述选择要删除的图像。您可以使用类似的方式获取每个图像的描述。

[y.description for y in x.tag.images]

Once you know the description of the image you want to remove, you should be able to pass it into the remove function, and that specific image will be removed.

一旦知道要删除的图像的描述,就应该能够将其传递给删除功能,并且该特定图像将被删除。

>>> 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)
[]

#1


3  

After digging around a bit, description is literally just the description of the image. When you call x.tag.images you get an ImageAccessor object, which is basically just an iterable containing your images. If you cast x.tag.images to a list, you can see it contains 1 ImageFrame object (in my test case). When you call x.tag.images.remove(), eyed3 needs to know which image to remove, and it selects the image to remove based on the image description. You can get the descriptions of each image using something like this.

在挖掘了一下之后,描述实际上只是图像的描述。当你调用x.tag.images时,你得到一个ImageAccessor对象,它基本上只是一个包含你的图像的迭代。如果将x.tag.images转换为列表,则可以看到它包含1个ImageFrame对象(在我的测试用例中)。当你调用x.tag.images.remove()时,eyed3需要知道要删除哪个图像,并根据图像描述选择要删除的图像。您可以使用类似的方式获取每个图像的描述。

[y.description for y in x.tag.images]

Once you know the description of the image you want to remove, you should be able to pass it into the remove function, and that specific image will be removed.

一旦知道要删除的图像的描述,就应该能够将其传递给删除功能,并且该特定图像将被删除。

>>> 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)
[]