Skip to content

Instantly share code, notes, and snippets.

@scotchi
Created September 6, 2013 07:14
Show Gist options
  • Save scotchi/6460510 to your computer and use it in GitHub Desktop.
Save scotchi/6460510 to your computer and use it in GitHub Desktop.
Set the recording date for a track using TagLib
#include <tstring.h>
#include <mpegfile.h>
#include <id3v2tag.h>
#include <textidentificationframe.h>
int main(int argc, char *argv[])
{
for(int i = 1; i < argc; i++)
{
TagLib::MPEG::File file(argv[i]);
TagLib::ID3v2::Tag *tag = file.ID3v2Tag(true);
TagLib::ID3v2::FrameList frames = tag->frameList("TDRC");
TagLib::ID3v2::TextIdentificationFrame *frame = 0;
if(frames.isEmpty())
{
frame = new TagLib::ID3v2::TextIdentificationFrame("TDRC", TagLib::String::UTF8);
tag->addFrame(frame);
}
else
{
frame = static_cast<TagLib::ID3v2::TextIdentificationFrame *>(frames.front());
}
frame->setText("2013-01-02");
file.save();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment