void CTagLoaderTagLib::AddArtistRole(CMusicInfoTag &tag, const std::string& strRole, const std::vector<std::string> &values) { if (values.size() == 1) tag.AddArtistRole(strRole, values[0]); else tag.AddArtistRole(strRole, values); }
void CTagLoaderTagLib::AddArtistRole(CMusicInfoTag &tag, const std::vector<std::string> &values) { // Values contains role, name pairs (as in ID3 standard for TIPL or TMCL tags) // Every odd entry is a function (e.g. Producer, Arranger etc.) or instrument (e.g. Orchestra, Vocal, Piano) // and every even is an artist or a comma delimited list of artists. if (values.size() % 2 != 0) // Must contain an even number of entries return; for (size_t i = 0; i + 1 < values.size(); i += 2) tag.AddArtistRole(values[i], StringUtils::Split(values[i + 1], ",")); }
void CTagLoaderTagLib::AddArtistInstrument(CMusicInfoTag &tag, const std::vector<std::string> &values) { // Values is a musician credits list, each entry is artist name followed by instrument (or function) // e.g. violin, drums, background vocals, solo, orchestra etc. in brackets. This is how Picard uses PERFORMER tag. // If there is not a pair of brackets then role is "performer" by default, and the whole entry is // taken as artist name. for (size_t i = 0; i < values.size(); ++i) { std::string strRole = "Performer"; std::string strArtist = values[i]; size_t firstLim = values[i].find_first_of("("); size_t lastLim = values[i].find_last_of(")"); if (lastLim != std::string::npos && firstLim != std::string::npos && firstLim < lastLim - 1) { //Pair of brackets with something between them strRole = values[i].substr(firstLim + 1, lastLim - firstLim - 1); StringUtils::Trim(strRole); strArtist.erase(firstLim, lastLim - firstLim + 1); } StringUtils::Trim(strArtist); tag.AddArtistRole(strRole, strArtist); } }