myers/id3v2 — pull request #1 by aforemny (2012-10-07 20:56:07+00:00)
Title: Add option --delete-frame (-x)

This patch adds the --delete-frame (-x) option to the id3v2 program. Searching the documentation and inspecting the source code I couldn't find a possibility to only delete a specific ID3v2 frame from a file.

This patch adds the --delete-frame (-x) option that, given a required argument of a ID3v2 frame as string, does just that.

If that feature already exists I'd like to apologize, but ask for better documentation instead. In case the feature exists and is documented properly I'd like to apologize and ask just to ignore this patch, although a comment would be appreciated in that case.

Not being an experienced CPP coder I'd appreciate a careful review of this patch before applying it to master.

Only deletion of ID3v2 frames is implemented and this is documented in the help. If multiple frames are found, only the first occurence is deleted. If no frame is given in the ID3v2 tag or no such frame exists no error occurs.

Here are some examples.

$ touch id3v2
$ id3v2 -l mp3
mp3: No ID3 tag
$ id3v2 --COMM "Some comment." mp3
$ id3v2 --COMM "Second comment." mp3
$ id3v2 -l mp3 | grep COMM
COMM (Comments): (ID3v1 Comment)[XXX]: Some comment.
COMM (Comments): ()[]: Second comment.
$ id3v2 --delete-frame COMM mp3
Deleting id3v2 frame "COMM" in "mp3"...deleted.
$ id3v2 -l mp3 | grep COMM
COMM (Comments): ()[]: Second comment.
$ id3v2 -x COMM mp3 > /dev/null
$ id3v2 -l mp3 | grep COMM; echo $?
1
$ id3v2 -x COMM mp3
Deleting id3v2 frame "COMM" in "mp3"...deleted.
$ id3v2 -x NO_SUCH_FRAME mp3
Deleting id3v2 frame "NO_SUCH_FRAME" in "mp3"...deleted.