stripping tags from FLAC

Jeff Mitchell mitchell at kde.org
Mon Mar 15 19:01:16 CET 2010


On 3/13/2010 1:28 PM, Новичков А.А. wrote:
> TagLib::FLAC::File *f=new TagLib::FLAC::File(FILE_NAME(file));
>         {TagLib::Ogg::XiphComment *tag=f->xiphComment(false);
>         if (tag) {
>             TagLib::Ogg::FieldListMap map=tag->fieldListMap();
>             TagLib::StringList list;
>             for (TagLib::Ogg::FieldListMap::ConstIterator it =
> map.begin(); it != map.end(); ++it)
>                 list.append((*it).first);
>             for (TagLib::StringList::ConstIterator it=list.begin(); it!
> =list.end(); ++it)
>                 tag->removeField((*it));
>         } }
>         {TagLib::ID3v1::Tag *tag=f->ID3v1Tag(false);
>          if (tag) {
>             tag->setAlbum("");
>             tag->setArtist("");
>             tag->setComment("");
>             tag->setGenre("");
>             tag->setTitle("");
>             tag->setTrack(0);
>             tag->setYear(0);
>         } }
>        {TagLib::ID3v2::Tag *tag=f->ID3v2Tag(false);
>         if (tag) {
>             tag->setAlbum("");
>             tag->setArtist("");
>             tag->setComment("");
>             tag->setGenre("");
>             tag->setTitle("");
>             tag->setTrack(0);
>             tag->setYear(0);
>             TagLib::ID3v2::FrameListMap map =tag->frameListMap();
>             TagLib::List<TagLib::ByteVector> list;
>             for (TagLib::ID3v2::FrameListMap::ConstIterator it =
> map.begin(); it != map.end(); ++it)
>                 list.append((*it).first);
>             for (TagLib::List<TagLib::ByteVector>::ConstIterator
> it=list.begin(); it!=list.end(); ++it)
>                 tag->removeFrames((*it));
>         } }
>         f->save();
>         delete f;

Setting the album/artist/genre/etc to an empty string doesn't strip the
tag, it just makes it empty.

Just use the various functions to go through the item maps or attribute
maps and remove each item you find. You already do this for two of the
formats above, but with a lot of needless code in front.

--Jeff

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: OpenPGP digital signature
Url : http://mail.kde.org/pipermail/taglib-devel/attachments/20100315/88f89f12/attachment.sig 


More information about the taglib-devel mailing list