本文整理汇总了C++中CAlbum::SetArtistCredits方法的典型用法代码示例。如果您正苦于以下问题:C++ CAlbum::SetArtistCredits方法的具体用法?C++ CAlbum::SetArtistCredits怎么用?C++ CAlbum::SetArtistCredits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAlbum
的用法示例。
在下文中一共展示了CAlbum::SetArtistCredits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetAlbumDetails
JSONRPC_STATUS CAudioLibrary::SetAlbumDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
int id = (int)parameterObject["albumid"].asInteger();
CMusicDatabase musicdatabase;
if (!musicdatabase.Open())
return InternalError;
CAlbum album;
// Get current album details, but not songs as we do not want to update them here
if (!musicdatabase.GetAlbum(id, album, false) || album.idAlbum <= 0)
return InvalidParams;
if (ParameterNotNull(parameterObject, "title"))
album.strAlbum = parameterObject["title"].asString();
if (ParameterNotNull(parameterObject, "displayartist"))
album.strArtistDesc = parameterObject["displayartist"].asString();
// Set album sort string before processing artist credits
if (ParameterNotNull(parameterObject, "sortartist"))
album.strArtistSort = parameterObject["sortartist"].asString();
// Match up artist names and mbids to make new artist credits
// Mbid values only apply if there are names
if (ParameterNotNull(parameterObject, "artist"))
{
std::vector<std::string> artists;
std::vector<std::string> mbids;
CopyStringArray(parameterObject["artist"], artists);
// Check for Musicbrainz ids
if (ParameterNotNull(parameterObject, "musicbrainzalbumartistid"))
CopyStringArray(parameterObject["musicbrainzalbumartistid"], mbids);
// When display artist is not provided and yet artists is changing make by concatenation
if (!ParameterNotNull(parameterObject, "displayartist"))
album.strArtistDesc = StringUtils::Join(artists, g_advancedSettings.m_musicItemSeparator);
album.SetArtistCredits(artists, std::vector<std::string>(), mbids);
// On updatealbum artists will be changed
album.bArtistSongMerge = true;
}
if (ParameterNotNull(parameterObject, "description"))
album.strReview = parameterObject["description"].asString();
if (ParameterNotNull(parameterObject, "genre"))
CopyStringArray(parameterObject["genre"], album.genre);
if (ParameterNotNull(parameterObject, "theme"))
CopyStringArray(parameterObject["theme"], album.themes);
if (ParameterNotNull(parameterObject, "mood"))
CopyStringArray(parameterObject["mood"], album.moods);
if (ParameterNotNull(parameterObject, "style"))
CopyStringArray(parameterObject["style"], album.styles);
if (ParameterNotNull(parameterObject, "type"))
album.strType = parameterObject["type"].asString();
if (ParameterNotNull(parameterObject, "albumlabel"))
album.strLabel = parameterObject["albumlabel"].asString();
if (ParameterNotNull(parameterObject, "rating"))
album.fRating = parameterObject["rating"].asFloat();
if (ParameterNotNull(parameterObject, "userrating"))
album.iUserrating = parameterObject["userrating"].asInteger();
if (ParameterNotNull(parameterObject, "votes"))
album.iVotes = parameterObject["votes"].asInteger();
if (ParameterNotNull(parameterObject, "year"))
album.iYear = (int)parameterObject["year"].asInteger();
if (ParameterNotNull(parameterObject, "musicbrainzalbumid"))
album.strMusicBrainzAlbumID = parameterObject["musicbrainzalbumid"].asString();
if (ParameterNotNull(parameterObject, "musicbrainzreleasegroupid"))
album.strReleaseGroupMBID = parameterObject["musicbrainzreleasegroupid"].asString();
// Update existing art. Any existing artwork that isn't specified in this request stays as is.
// If the value is null then the existing art with that type is removed.
if (ParameterNotNull(parameterObject, "art"))
{
// Get current artwork
musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, album.art);
std::set<std::string> removedArtwork;
CVariant art = parameterObject["art"];
for (CVariant::const_iterator_map artIt = art.begin_map(); artIt != art.end_map(); artIt++)
{
if (artIt->second.isString() && !artIt->second.asString().empty())
album.art[artIt->first] = CTextureUtils::UnwrapImageURL(artIt->second.asString());
else if (artIt->second.isNull())
{
album.art.erase(artIt->first);
removedArtwork.insert(artIt->first);
}
}
// Remove null art now, as not done by update
if (!musicdatabase.RemoveArtForItem(album.idAlbum, MediaTypeAlbum, removedArtwork))
return InternalError;
}
// Update artist including adding or replacing (but not removing) art
if (!musicdatabase.UpdateAlbum(album))
return InternalError;
CJSONRPCUtils::NotifyItemUpdated();
return ACK;
}
示例2: FillLibraryArt
bool CMusicThumbLoader::FillLibraryArt(CFileItem &item)
{
/* Called for any item with MusicInfoTag and no art.
Items on Genres, Sources and Roles nodes have ID (although items on Years
node do not) so check for song/album/artist specifically.
Non-library songs (file view) can also have MusicInfoTag but no ID or type
*/
bool artfound(false);
std::vector<ArtForThumbLoader> art;
CMusicInfoTag &tag = *item.GetMusicInfoTag();
if (tag.GetDatabaseId() > -1 && (tag.GetType() == MediaTypeSong ||
tag.GetType() == MediaTypeAlbum ||
tag.GetType() == MediaTypeArtist))
{
// Item in music library, fetch the art
m_musicDatabase->Open();
if (tag.GetType() == MediaTypeSong)
artfound = m_musicDatabase->GetArtForItem(tag.GetDatabaseId(), tag.GetAlbumId(), -1, false, art);
else if (tag.GetType() == MediaTypeAlbum)
artfound = m_musicDatabase->GetArtForItem(-1, tag.GetDatabaseId(), -1, false, art);
else //Artist
artfound = m_musicDatabase->GetArtForItem(-1, -1, tag.GetDatabaseId(), true, art);
m_musicDatabase->Close();
}
else if (!tag.GetArtist().empty() &&
(tag.GetType() == MediaTypeNone || tag.GetType() == MediaTypeSong))
{
/*
Could be non-library song - has musictag but no ID or type (may have
thumb already). Try to fetch both song artist(s) and album artist(s) art by
artist name, e.g. "artist.thumb", "artist.fanart", "artist.clearlogo",
"artist.banner", "artist1.thumb", "artist1.fanart", "artist1.clearlogo",
"artist1.banner", "albumartist.thumb", "albumartist.fanart" etc.
Set fanart as fallback.
*/
CSong song;
// Try to split song artist names (various tags) into artist credits
song.SetArtistCredits(tag.GetArtist(), tag.GetMusicBrainzArtistHints(), tag.GetMusicBrainzArtistID());
if (!song.artistCredits.empty())
{
tag.SetType(MediaTypeSong); // Makes "Information" context menu visible
m_musicDatabase->Open();
int iOrder = 0;
// Song artist art
for (const auto& artistCredit : song.artistCredits)
{
int idArtist = m_musicDatabase->GetArtistByName(artistCredit.GetArtist());
if (idArtist > 0)
{
std::vector<ArtForThumbLoader> artistart;
if (m_musicDatabase->GetArtForItem(-1, -1, idArtist, true, artistart))
{
for (auto& artitem : artistart)
{
if (iOrder > 0)
artitem.prefix = StringUtils::Format("artist%i", iOrder);
else
artitem.prefix = "artist";
}
art.insert(art.end(), artistart.begin(), artistart.end());
}
}
++iOrder;
}
// Album artist art
if (!tag.GetAlbumArtist().empty() && tag.GetArtistString().compare(tag.GetAlbumArtistString()) != 0)
{
// Split song artist names correctly into artist credits from various tag
// arrays, inc. fallback to song artist names
CAlbum album;
album.SetArtistCredits(tag.GetAlbumArtist(), tag.GetMusicBrainzAlbumArtistHints(), tag.GetMusicBrainzAlbumArtistID(),
tag.GetArtist(), tag.GetMusicBrainzArtistHints(), tag.GetMusicBrainzArtistID());
iOrder = 0;
for (const auto& artistCredit : album.artistCredits)
{
int idArtist = m_musicDatabase->GetArtistByName(artistCredit.GetArtist());
if (idArtist > 0)
{
std::vector<ArtForThumbLoader> artistart;
if (m_musicDatabase->GetArtForItem(-1, -1, idArtist, true, artistart))
{
for (auto& artitem : artistart)
{
if (iOrder > 0)
artitem.prefix = StringUtils::Format("albumartist%i", iOrder);
else
artitem.prefix = "albumartist";
}
art.insert(art.end(), artistart.begin(), artistart.end());
}
}
++iOrder;
}
}
else
{
// Replicate the artist art as album artist art
std::vector<ArtForThumbLoader> artistart;
//.........这里部分代码省略.........