37 lines
2.1 KiB
Plaintext
37 lines
2.1 KiB
Plaintext
for (const auto &entry : fs::recursive_directory_iterator(inputDir, fs::directory_options::skip_permission_denied)) {
|
|
auto file = entry.path().string();
|
|
// doesnt need audio properties here
|
|
auto tagFile = TagLib::FileRef(file.c_str(), false);
|
|
if (!tagFile.isNull()) {
|
|
TagLib::MPEG::File f(file.c_str());
|
|
if (f.isValid()) {
|
|
TagLib::ID3v2::Tag *id3v2tag = f.ID3v2Tag();
|
|
if (id3v2tag) {
|
|
auto listOfFrames = id3v2tag->frameListMap()["APIC"];
|
|
if (!listOfFrames.isEmpty()) {
|
|
//hold here for debugger ;)
|
|
auto it = listOfFrames.begin();
|
|
for (; it != listOfFrames.end(); it++) {
|
|
auto *pictureFrame = dynamic_cast<TagLib::ID3v2::AttachedPictureFrame *> (*it);
|
|
/* {
|
|
FILE *jpegFile;
|
|
jpegFile = fopen("/home/versustune/FromId3.jpg", "wb");
|
|
unsigned long Size = pictureFrame->picture().size();
|
|
void *SrcImage = malloc(Size);
|
|
if (SrcImage) {
|
|
memcpy(SrcImage, pictureFrame->picture().data(), Size);
|
|
fwrite(SrcImage, Size, 1, jpegFile);
|
|
fclose(jpegFile);
|
|
free(SrcImage);
|
|
}
|
|
}*/
|
|
}
|
|
}
|
|
} else {
|
|
std::cout << "no ID3v2 \n";
|
|
}
|
|
} else {
|
|
std::cout << "is not Mpeg!" << "\n";
|
|
}
|
|
}
|
|
} |