Created
September 6, 2013 07:14
-
-
Save scotchi/6460510 to your computer and use it in GitHub Desktop.
Set the recording date for a track using TagLib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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