return METADATA_EDITOR_ERROR_NONE;
}
+static int __ID3v2_setFrameByName(ID3v2::Tag *tag2, const char *frameID, const char *value)
+{
+ metadata_editor_retvm_if(!tag2, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating");
+ metadata_editor_retvm_if(!frameID, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid frameID");
+
+ // If the pointer is NULL or c-string is empty - handle as request for deletion
+ if (!value || (*value == '\0')) {
+ metadata_editor_info("Request for frame %s deletion", frameID);
+ tag2->removeFrames(frameID);
+ return METADATA_EDITOR_ERROR_NONE;
+ }
+
+ // Check if the ID3v2 tag exists
+ if (tag2->frameListMap()[frameID].isEmpty()) {
+ metadata_editor_info("The frame %s does not exist. Creating", frameID);
+ // This is a common frame type for textural frames except comment frame
+ auto fr = new ID3v2::TextIdentificationFrame(frameID);
+
+ fr->setTextEncoding(String::UTF8);
+ fr->setText(String(value, String::UTF8));
+ tag2->addFrame(fr);
+ } else { // if not - just modify the data in the existing frame
+ metadata_editor_info("The frame %s exists. Changing", frameID);
+ tag2->frameListMap()[frameID][0]->setText(String(value, String::UTF8));
+ }
+
+ return METADATA_EDITOR_ERROR_NONE;
+}
+
static int __ID3_setTwixFrameByName(ID3v1::Tag *tag1, ID3v2::Tag *tag2, const char *frameID, const char *value)
{
metadata_editor_retvm_if(!frameID, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid frameID");
return METADATA_EDITOR_ERROR_NONE;
}
-static int __ID3_setFrameByName(ID3v2::Tag *tag2, const char *frameID, const char *value)
-{
- metadata_editor_retvm_if(!frameID, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid frameID");
- metadata_editor_retvm_if(!tag2, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating");
-
- // If the pointer is NULL or c-string is empty - handle as request for deletion
- if (!value || (*value == '\0')) {
- metadata_editor_info("Request for frame %s deletion", frameID);
- tag2->removeFrames(frameID);
- return METADATA_EDITOR_ERROR_NONE;
- }
-
- // Check if the ID3v2 tag exists
- if (tag2->frameListMap()[frameID].isEmpty()) {
- metadata_editor_info("The frame %s does not exist. Creating", frameID);
- // This is a common frame type for textural frames except comment frame
- auto fr = new ID3v2::TextIdentificationFrame(frameID);
-
- fr->setTextEncoding(String::UTF8);
- fr->setText(String(value, String::UTF8));
- tag2->addFrame(fr);
- } else { // if not - just modify the data in the existing frame
- metadata_editor_info("The frame %s exists. Changing", frameID);
- tag2->frameListMap()[frameID][0]->setText(String(value, String::UTF8));
- }
-
- return METADATA_EDITOR_ERROR_NONE;
-}
-
static int __ID3_getNumberOfPictures(ID3v2::Tag *tag2, char **value)
{
metadata_editor_retvm_if(!value, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid value");
case METADATA_EDITOR_ATTR_TITLE: return __ID3_setTwixFrameByName(tag1, tag2, "TIT2", value);
case METADATA_EDITOR_ATTR_ALBUM: return __ID3_setTwixFrameByName(tag1, tag2, "TALB", value);
case METADATA_EDITOR_ATTR_GENRE: return __ID3_setTwixFrameByName(tag1, tag2, "TCON", value);
- case METADATA_EDITOR_ATTR_AUTHOR: return __ID3_setFrameByName(tag2, "TCOM", value);
- case METADATA_EDITOR_ATTR_COPYRIGHT: return __ID3_setFrameByName(tag2, "TCOP", value);
+ case METADATA_EDITOR_ATTR_AUTHOR: return __ID3v2_setFrameByName(tag2, "TCOM", value);
+ case METADATA_EDITOR_ATTR_COPYRIGHT: return __ID3v2_setFrameByName(tag2, "TCOP", value);
case METADATA_EDITOR_ATTR_DATE: return __ID3_setTwixFrameByName(tag1, tag2, "TDRC", value);
- case METADATA_EDITOR_ATTR_DESCRIPTION: return __ID3_setFrameByName(tag2, "TIT3", value);
+ case METADATA_EDITOR_ATTR_DESCRIPTION: return __ID3v2_setFrameByName(tag2, "TIT3", value);
case METADATA_EDITOR_ATTR_TRACK_NUM: return __ID3_setTwixFrameByName(tag1, tag2, "TRCK", value);
- case METADATA_EDITOR_ATTR_CONDUCTOR: return __ID3_setFrameByName(tag2, "TPE3", value);
+ case METADATA_EDITOR_ATTR_CONDUCTOR: return __ID3v2_setFrameByName(tag2, "TPE3", value);
case METADATA_EDITOR_ATTR_COMMENT: return __ID3_setTwixCommentFrame(tag1, tag2, value);
case METADATA_EDITOR_ATTR_UNSYNCLYRICS: return __ID3_setLyricsFrame(tag2, value);
default:
}
switch (attribute) { // Check which one of frame type was given for processing
- case METADATA_EDITOR_ATTR_ARTIST: return __ID3_setFrameByName(tag2, "TPE1", value);
- case METADATA_EDITOR_ATTR_TITLE: return __ID3_setFrameByName(tag2, "TIT2", value);
- case METADATA_EDITOR_ATTR_ALBUM: return __ID3_setFrameByName(tag2, "TALB", value);
- case METADATA_EDITOR_ATTR_GENRE: return __ID3_setFrameByName(tag2, "TCON", value);
- case METADATA_EDITOR_ATTR_AUTHOR: return __ID3_setFrameByName(tag2, "TCOM", value);
- case METADATA_EDITOR_ATTR_COPYRIGHT: return __ID3_setFrameByName(tag2, "TCOP", value);
- case METADATA_EDITOR_ATTR_DATE: return __ID3_setFrameByName(tag2, "TDRC", value);
- case METADATA_EDITOR_ATTR_DESCRIPTION: return __ID3_setFrameByName(tag2, "TIT3", value);
- case METADATA_EDITOR_ATTR_TRACK_NUM: return __ID3_setFrameByName(tag2, "TRCK", value);
- case METADATA_EDITOR_ATTR_CONDUCTOR: return __ID3_setFrameByName(tag2, "TPE3", value);
+ case METADATA_EDITOR_ATTR_ARTIST: return __ID3v2_setFrameByName(tag2, "TPE1", value);
+ case METADATA_EDITOR_ATTR_TITLE: return __ID3v2_setFrameByName(tag2, "TIT2", value);
+ case METADATA_EDITOR_ATTR_ALBUM: return __ID3v2_setFrameByName(tag2, "TALB", value);
+ case METADATA_EDITOR_ATTR_GENRE: return __ID3v2_setFrameByName(tag2, "TCON", value);
+ case METADATA_EDITOR_ATTR_AUTHOR: return __ID3v2_setFrameByName(tag2, "TCOM", value);
+ case METADATA_EDITOR_ATTR_COPYRIGHT: return __ID3v2_setFrameByName(tag2, "TCOP", value);
+ case METADATA_EDITOR_ATTR_DATE: return __ID3v2_setFrameByName(tag2, "TDRC", value);
+ case METADATA_EDITOR_ATTR_DESCRIPTION: return __ID3v2_setFrameByName(tag2, "TIT3", value);
+ case METADATA_EDITOR_ATTR_TRACK_NUM: return __ID3v2_setFrameByName(tag2, "TRCK", value);
+ case METADATA_EDITOR_ATTR_CONDUCTOR: return __ID3v2_setFrameByName(tag2, "TPE3", value);
case METADATA_EDITOR_ATTR_COMMENT: return __ID3_setTwixCommentFrame(NULL, tag2, value);
case METADATA_EDITOR_ATTR_UNSYNCLYRICS: return __ID3_setLyricsFrame(tag2, value);
default: