Repository: xbmc/xbmc
File: xbmc/interfaces/json-rpc/AudioLibrary.cpp (C++)

Code before:
  std::string mediaType;
  int mediaID = -1;
  if (parameterObject["item"].isMember("albumid"))
  {
    mediaType = MediaTypeAlbum;
    mediaID = parameterObject["item"]["albumid"].asInteger32();
  }
  if (parameterObject["item"].isMember("artistid"))
  {
    mediaType = MediaTypeArtist;
    mediaID = parameterObject["item"]["artistid"].asInteger32();
  }
  if (mediaID == -1)
    return InternalError;

  std::string artType = parameterObject["arttype"].asString();
  StringUtils::ToLower(artType);

  CMusicDatabase musicdatabase;
  if (!musicdatabase.Open())
    return InternalError;

  CVariant availableart = CVariant(CVariant::VariantTypeArray);
  for (const auto& artentry : musicdatabase.GetAvailableArtForItem(mediaID, mediaType, artType))
  {
    CVariant item = CVariant(CVariant::VariantTypeObject);
    item["url"] = CTextureUtils::GetWrappedImageURL(artentry.m_url);
    if (!artentry.m_preview.empty())
      item["previewurl"] = CTextureUtils::GetWrappedImageURL(artentry.m_preview);
    availableart.append(item);
  }
  result = CVariant(CVariant::VariantTypeObject);
  result["availableart"] = availableart;

  return OK;
}

JSONRPC_STATUS CAudioLibrary::SetArtistDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  int id = (int)parameterObject["artistid"].asInteger();

  CMusicDatabase musicdatabase;
  if (!musicdatabase.Open())
    return InternalError;

  CArtist artist;
  if (!musicdatabase.GetArtist(id, artist) || artist.idArtist <= 0)
    return InvalidParams;

  if (ParameterNotNull(parameterObject, "artist"))
    artist.strArtist = parameterObject["artist"].asString();

Review comment (suggestion):
`item["arttype"] = artentry.m_aspect;`
May also want to handle empty => "thumb" here, or in `CMusicDatabase::GetAvailableArtForItem`

Code after:
  std::string mediaType;
  int mediaID = -1;
  if (parameterObject["item"].isMember("albumid"))
  {
    mediaType = MediaTypeAlbum;
    mediaID = parameterObject["item"]["albumid"].asInteger32();
  }
  if (parameterObject["item"].isMember("artistid"))
  {
    mediaType = MediaTypeArtist;
    mediaID = parameterObject["item"]["artistid"].asInteger32();
  }
  if (mediaID == -1)
    return InternalError;

  std::string artType = parameterObject["arttype"].asString();
  StringUtils::ToLower(artType);

  CMusicDatabase musicdatabase;
  if (!musicdatabase.Open())
    return InternalError;

  CVariant availableart = CVariant(CVariant::VariantTypeArray);
  for (const auto& artentry : musicdatabase.GetAvailableArtForItem(mediaID, mediaType, artType))
  {
    CVariant item = CVariant(CVariant::VariantTypeObject);
    item["url"] = CTextureUtils::GetWrappedImageURL(artentry.m_url);
    item["arttype"] = artentry.m_aspect;
    if (!artentry.m_preview.empty())
      item["previewurl"] = CTextureUtils::GetWrappedImageURL(artentry.m_preview);
    availableart.append(item);
  }
  result = CVariant(CVariant::VariantTypeObject);
  result["availableart"] = availableart;

  return OK;
}

JSONRPC_STATUS CAudioLibrary::SetArtistDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  int id = (int)parameterObject["artistid"].asInteger();

  CMusicDatabase musicdatabase;
  if (!musicdatabase.Open())
    return InternalError;

  CArtist artist;
  if (!musicdatabase.GetArtist(id, artist) || artist.idArtist <= 0)
    return InvalidParams;

  if (ParameterNotNull(parameterObject, "artist"))