nicfit / eyeD3

eyeD3 is a Python module and command line program for processing ID3 tags. Information about mp3 files (i.e bit rate, sample frequency, play time, etc.) is also provided. The formats supported are ID3v1 (1.0/1.1) and ID3v2 (2.3/2.4).
http://eyed3.nicfit.net/
GNU General Public License v3.0
547 stars 59 forks source link

Removing comments doesn't work #111

Closed fluidblue closed 6 years ago

fluidblue commented 7 years ago

Hello,

I'd like to remove comments using the python3 interface of eyed3 (v0.8.0):

audiofile = eyed3.load("somefile.mp3")
for comment in audiofile.tag.comments:
    # Show comment
    print(comment.description)
    print(comment.text)
    print(comment.lang)

    # Remove comment. Doesn't work with empty descriptions.
    audiofile.tag.comments.remove(comment.description)

The comment is correctly printed (text & lang). The description is an empty string. But calling remove returns None and doesn't remove the comment.

nicfit commented 7 years ago

Your script does not save the tag. Here's my modified test script:

(eyeD3) travis@bjm:~/devel/eyeD3[master|!?]
└> cat issue111.py 
import eyed3

audiofile = eyed3.load("song.id3")
print(f"# comments: {len(audiofile.tag.comments)}")
for comment in audiofile.tag.comments:
    # Show comment
    print(comment.description)
    print(comment.text)
    print(comment.lang)

# Remove comment. Doesn't work with empty descriptions.
audiofile.tag.comments.remove(comment.description)
print(f"# comments (after remove): {len(audiofile.tag.comments)}")
audiofile.tag.save()

And running it:

(eyeD3) travis@bjm:~/devel/eyeD3[master|!?]
└> eyeD3 song.id3
/home/travis/devel/eyeD3/song.id3                                                             [ 1.00 KB ]
----------------------------------------------------------------------------------------------------------
ID3 v2.3:
title: 
artist: bazz
album: foo
album artist: None
track:      
Comment: [Description: ] [Lang: eng]
FOO
----------------------------------------------------------------------------------------------------------
(eyeD3) travis@bjm:~/devel/eyeD3[master|!?]
└> python issue111.py 
# comments: 1

FOO
b'eng'
# comments (after remove): 0
(eyeD3) travis@bjm:~/devel/eyeD3[master|!?]
└> eyeD3 song.id3
/home/travis/devel/eyeD3/song.id3                                                             [ 1.00 KB ]
----------------------------------------------------------------------------------------------------------
ID3 v2.3:
title: 
artist: bazz
album: foo
album artist: None
track:      
----------------------------------------------------------------------------------------------------------
fluidblue commented 7 years ago

Seems that in your example this works, however with my setup (eyed3 v0.8.0, python 3.6.1, macOS 10.12.6) it doesn't. After calling audiofile.tag.comments.remove the comment is still in audiofile.tag.comments.

nicfit commented 7 years ago

Can you check latest eyeD3 0.8.3. Feel free email me a sample file to reproduce, if needed.

fluidblue commented 7 years ago

It happened on files that were produced originally with CUERipper. I already used mutagen to remove the comments, though.

shillshocked commented 6 years ago

Doesn't work with 0.8.4 either. Not unless I delete ALL comments.

krair commented 1 year ago

I realize this is a very old issue, but I ran into the same problem. Appears that it could be related to the lang field. Trying to remove it as described above doesn't work, unless I include the option lang parameter:

>>> audiofile.tag.comments.remove('')
>>> audiofile.tag.save()
>>> audiofile.tag.comments[0]   
<eyed3.id3.frames.CommentFrame object at 0x7f162d21cd50>
>>> audiofile.tag.comments[0].text
'Comment Here'
>>> audiofile.tag.comments[0].lang
b'   '
>>> audiofile.tag.comments.remove('', b'   ')
<eyed3.id3.frames.CommentFrame object at 0x7f162d22dfd0>
>>> audiofile.tag.comments[0].text
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kit/PythonVenv/rssparser/lib64/python3.11/site-packages/eyed3/id3/tag.py", line 1525, in __getitem__
    raise IndexError("list index out of range")
IndexError: list index out of range