Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1840 from Montellese/jsonrpc_artist_mess

jsonrpc: add "genreid", "artistid", "albumartistid" and "displayartist" to songs and albums and fix "albumartist" for songs
  • Loading branch information...
commit f00ff50ec98445ac922a87662931751eccbd5651 2 parents 9fe57ce + a8c055c
@Montellese Montellese authored
View
182 xbmc/interfaces/json-rpc/AudioLibrary.cpp
@@ -157,6 +157,10 @@ JSONRPC_STATUS CAudioLibrary::GetAlbums(const CStdString &method, ITransportLaye
if (!musicdatabase.GetAlbumsNav(musicUrl.ToString(), items, genreID, artistID, CDatabase::Filter(), sorting))
return InternalError;
+ JSONRPC_STATUS ret = GetAdditionalAlbumDetails(parameterObject, items, musicdatabase);
+ if (ret != OK)
+ return ret;
+
int size = items.Size();
if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size)
size = (int)items.GetProperty("total").asInteger();
@@ -181,9 +185,16 @@ JSONRPC_STATUS CAudioLibrary::GetAlbumDetails(const CStdString &method, ITranspo
if (!musicdatabase.GetAlbumPath(albumID, path))
return InternalError;
- CFileItemPtr m_albumItem;
- FillAlbumItem(album, path, m_albumItem);
- HandleFileItem("albumid", false, "albumdetails", m_albumItem, parameterObject, parameterObject["properties"], result, false);
+ CFileItemPtr albumItem;
+ FillAlbumItem(album, path, albumItem);
+
+ CFileItemList items;
+ items.Add(albumItem);
+ JSONRPC_STATUS ret = GetAdditionalAlbumDetails(parameterObject, items, musicdatabase);
+ if (ret != OK)
+ return ret;
+
+ HandleFileItem("albumid", false, "albumdetails", items[0], parameterObject, parameterObject["properties"], result, false);
return OK;
}
@@ -228,6 +239,10 @@ JSONRPC_STATUS CAudioLibrary::GetSongs(const CStdString &method, ITransportLayer
if (!musicdatabase.GetSongsNav(musicUrl.ToString(), items, genreID, artistID, albumID, sorting))
return InternalError;
+ JSONRPC_STATUS ret = GetAdditionalSongDetails(parameterObject, items, musicdatabase);
+ if (ret != OK)
+ return ret;
+
int size = items.Size();
if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size)
size = (int)items.GetProperty("total").asInteger();
@@ -248,7 +263,13 @@ JSONRPC_STATUS CAudioLibrary::GetSongDetails(const CStdString &method, ITranspor
if (!musicdatabase.GetSongById(idSong, song))
return InvalidParams;
- HandleFileItem("songid", false, "songdetails", CFileItemPtr( new CFileItem(song) ), parameterObject, parameterObject["properties"], result, false);
+ CFileItemList items;
+ items.Add(CFileItemPtr(new CFileItem(song)));
+ JSONRPC_STATUS ret = GetAdditionalSongDetails(parameterObject, items, musicdatabase);
+ if (ret != OK)
+ return ret;
+
+ HandleFileItem("songid", false, "songdetails", items[0], parameterObject, parameterObject["properties"], result, false);
return OK;
}
@@ -273,6 +294,10 @@ JSONRPC_STATUS CAudioLibrary::GetRecentlyAddedAlbums(const CStdString &method, I
items.Add(item);
}
+ JSONRPC_STATUS ret = GetAdditionalAlbumDetails(parameterObject, items, musicdatabase);
+ if (ret != OK)
+ return ret;
+
HandleFileItemList("albumid", false, "albums", items, parameterObject, result);
return OK;
}
@@ -291,6 +316,10 @@ JSONRPC_STATUS CAudioLibrary::GetRecentlyAddedSongs(const CStdString &method, IT
if (!musicdatabase.GetRecentlyAddedAlbumSongs("musicdb://", items, (unsigned int)amount))
return InternalError;
+ JSONRPC_STATUS ret = GetAdditionalSongDetails(parameterObject, items, musicdatabase);
+ if (ret != OK)
+ return ret;
+
HandleFileItemList("songid", true, "songs", items, parameterObject, result);
return OK;
}
@@ -316,6 +345,10 @@ JSONRPC_STATUS CAudioLibrary::GetRecentlyPlayedAlbums(const CStdString &method,
items.Add(item);
}
+ JSONRPC_STATUS ret = GetAdditionalAlbumDetails(parameterObject, items, musicdatabase);
+ if (ret != OK)
+ return ret;
+
HandleFileItemList("albumid", false, "albums", items, parameterObject, result);
return OK;
}
@@ -330,6 +363,10 @@ JSONRPC_STATUS CAudioLibrary::GetRecentlyPlayedSongs(const CStdString &method, I
if (!musicdatabase.GetRecentlyPlayedAlbumSongs("musicdb://", items))
return InternalError;
+ JSONRPC_STATUS ret = GetAdditionalSongDetails(parameterObject, items, musicdatabase);
+ if (ret != OK)
+ return ret;
+
HandleFileItemList("songid", true, "songs", items, parameterObject, result);
return OK;
}
@@ -520,7 +557,7 @@ JSONRPC_STATUS CAudioLibrary::Clean(const CStdString &method, ITransportLayer *t
return ACK;
}
-bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItem &item)
+bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItem &item, const CVariant &parameterObject /* = CVariant(CVariant::VariantTypeArray) */)
{
CMusicDatabase musicdatabase;
if (strFilename.empty() || !musicdatabase.Open())
@@ -534,6 +571,11 @@ bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItem &item)
return false;
item.SetFromAlbum(album);
+
+ CFileItemList items;
+ items.Add(CFileItemPtr(&item));
+ if (GetAdditionalAlbumDetails(parameterObject, items, musicdatabase) != OK)
+ return false;
}
else
{
@@ -542,6 +584,11 @@ bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItem &item)
return false;
item.SetFromSong(song);
+
+ CFileItemList items;
+ items.Add(CFileItemPtr(&item));
+ if (GetAdditionalSongDetails(parameterObject, items, musicdatabase) != OK)
+ return false;
}
return true;
@@ -560,7 +607,7 @@ bool CAudioLibrary::FillFileItemList(const CVariant &parameterObject, CFileItemL
bool success = false;
CFileItem fileItem;
- if (FillFileItem(file, fileItem))
+ if (FillFileItem(file, fileItem, parameterObject))
{
success = true;
list.Add(CFileItemPtr(new CFileItem(fileItem)));
@@ -603,3 +650,126 @@ void CAudioLibrary::FillAlbumItem(const CAlbum &album, const CStdString &path, C
{
item = CFileItemPtr(new CFileItem(path, album));
}
+
+JSONRPC_STATUS CAudioLibrary::GetAdditionalAlbumDetails(const CVariant &parameterObject, CFileItemList &items, CMusicDatabase &musicdatabase)
+{
+ if (!musicdatabase.Open())
+ return InternalError;
+
+ std::set<std::string> checkProperties;
+ checkProperties.insert("genreid");
+ checkProperties.insert("artistid");
+ std::set<std::string> additionalProperties;
+ if (!CheckForAdditionalProperties(parameterObject["properties"], checkProperties, additionalProperties))
+ return OK;
+
+ for (int i = 0; i < items.Size(); i++)
+ {
+ CFileItemPtr item = items[i];
+ if (additionalProperties.find("genreid") != additionalProperties.end())
+ {
+ std::vector<int> genreids;
+ if (musicdatabase.GetGenresByAlbum(item->GetMusicInfoTag()->GetDatabaseId(), genreids))
+ {
+ CVariant genreidObj(CVariant::VariantTypeArray);
+ for (std::vector<int>::const_iterator genreid = genreids.begin(); genreid != genreids.end(); genreid++)
+ genreidObj.push_back(*genreid);
+
+ item->SetProperty("genreid", genreidObj);
+ }
+ }
+ if (additionalProperties.find("artistid") != additionalProperties.end())
+ {
+ std::vector<int> artistids;
+ if (musicdatabase.GetArtistsByAlbum(item->GetMusicInfoTag()->GetDatabaseId(), true, artistids))
+ {
+ CVariant artistidObj(CVariant::VariantTypeArray);
+ for (std::vector<int>::const_iterator artistid = artistids.begin(); artistid != artistids.end(); artistid++)
+ artistidObj.push_back(*artistid);
+
+ item->SetProperty("artistid", artistidObj);
+ }
+ }
+ }
+
+ return OK;
+}
+
+JSONRPC_STATUS CAudioLibrary::GetAdditionalSongDetails(const CVariant &parameterObject, CFileItemList &items, CMusicDatabase &musicdatabase)
+{
+ if (!musicdatabase.Open())
+ return InternalError;
+
+ std::set<std::string> checkProperties;
+ checkProperties.insert("genreid");
+ checkProperties.insert("artistid");
+ checkProperties.insert("albumartistid");
+ std::set<std::string> additionalProperties;
+ if (!CheckForAdditionalProperties(parameterObject["properties"], checkProperties, additionalProperties))
+ return OK;
+
+ for (int i = 0; i < items.Size(); i++)
+ {
+ CFileItemPtr item = items[i];
+ if (additionalProperties.find("genreid") != additionalProperties.end())
+ {
+ std::vector<int> genreids;
+ if (musicdatabase.GetGenresBySong(item->GetMusicInfoTag()->GetDatabaseId(), genreids))
+ {
+ CVariant genreidObj(CVariant::VariantTypeArray);
+ for (std::vector<int>::const_iterator genreid = genreids.begin(); genreid != genreids.end(); genreid++)
+ genreidObj.push_back(*genreid);
+
+ item->SetProperty("genreid", genreidObj);
+ }
+ }
+ if (additionalProperties.find("artistid") != additionalProperties.end())
+ {
+ std::vector<int> artistids;
+ if (musicdatabase.GetArtistsBySong(item->GetMusicInfoTag()->GetDatabaseId(), true, artistids))
+ {
+ CVariant artistidObj(CVariant::VariantTypeArray);
+ for (std::vector<int>::const_iterator artistid = artistids.begin(); artistid != artistids.end(); artistid++)
+ artistidObj.push_back(*artistid);
+
+ item->SetProperty("artistid", artistidObj);
+ }
+ }
+ if (additionalProperties.find("albumartistid") != additionalProperties.end() && item->GetMusicInfoTag()->GetAlbumId() > 0)
+ {
+ std::vector<int> albumartistids;
+ if (musicdatabase.GetArtistsByAlbum(item->GetMusicInfoTag()->GetAlbumId(), true, albumartistids))
+ {
+ CVariant albumartistidObj(CVariant::VariantTypeArray);
+ for (std::vector<int>::const_iterator albumartistid = albumartistids.begin(); albumartistid != albumartistids.end(); albumartistid++)
+ albumartistidObj.push_back(*albumartistid);
+
+ item->SetProperty("albumartistid", albumartistidObj);
+ }
+ }
+ }
+
+ return OK;
+}
+
+bool CAudioLibrary::CheckForAdditionalProperties(const CVariant &properties, const std::set<std::string> &checkProperties, std::set<std::string> &foundProperties)
+{
+ if (!properties.isArray() || properties.empty())
+ return false;
+
+ std::set<std::string> checkingProperties = checkProperties;
+ for (CVariant::const_iterator_array itr = properties.begin_array(); itr != properties.end_array() && !checkingProperties.empty(); itr++)
+ {
+ if (!itr->isString())
+ continue;
+
+ std::string property = itr->asString();
+ if (checkingProperties.find(property) != checkingProperties.end())
+ {
+ checkingProperties.erase(property);
+ foundProperties.insert(property);
+ }
+ }
+
+ return !foundProperties.empty();
+}
View
11 xbmc/interfaces/json-rpc/AudioLibrary.h
@@ -19,10 +19,14 @@
*
*/
+#include <set>
+
#include "utils/StdString.h"
#include "JSONRPC.h"
#include "FileItemHandler.h"
+class CMusicDatabase;
+
namespace JSONRPC
{
class CAudioLibrary : public CFileItemHandler
@@ -49,10 +53,15 @@ namespace JSONRPC
static JSONRPC_STATUS Export(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS Clean(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
- static bool FillFileItem(const CStdString &strFilename, CFileItem &item);
+ static bool FillFileItem(const CStdString &strFilename, CFileItem &item, const CVariant &parameterObject = CVariant(CVariant::VariantTypeArray));
static bool FillFileItemList(const CVariant &parameterObject, CFileItemList &list);
+ static JSONRPC_STATUS GetAdditionalAlbumDetails(const CVariant &parameterObject, CFileItemList &items, CMusicDatabase &musicdatabase);
+ static JSONRPC_STATUS GetAdditionalSongDetails(const CVariant &parameterObject, CFileItemList &items, CMusicDatabase &musicdatabase);
+
private:
static void FillAlbumItem(const CAlbum &album, const CStdString &path, CFileItemPtr &item);
+
+ static bool CheckForAdditionalProperties(const CVariant &properties, const std::set<std::string> &checkProperties, std::set<std::string> &foundProperties);
};
}
View
6 xbmc/interfaces/json-rpc/FileItemHandler.cpp
@@ -164,6 +164,12 @@ bool CFileItemHandler::GetField(const std::string &field, const CVariant &info,
result[field] = item->m_dateTime.GetAsLocalizedDateTime();
return true;
}
+
+ if (item->HasProperty(field))
+ {
+ result[field] = item->GetProperty(field);
+ return true;
+ }
}
return false;
View
10 xbmc/interfaces/json-rpc/FileOperations.cpp
@@ -139,7 +139,7 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
else
{
CFileItem fileItem;
- if (FillFileItem(items[i], fileItem, media))
+ if (FillFileItem(items[i], fileItem, media, parameterObject))
{
if (items[i]->m_bIsFolder)
filteredDirectories.Add(CFileItemPtr(new CFileItem(fileItem)));
@@ -214,7 +214,7 @@ JSONRPC_STATUS CFileOperations::GetFileDetails(const CStdString &method, ITransp
CFileItemPtr item = items.Get(file);
if (!URIUtils::IsUPnP(file))
- FillFileItem(item, *item.get(), parameterObject["media"].asString());
+ FillFileItem(item, *item.get(), parameterObject["media"].asString(), parameterObject);
// Check if the "properties" list exists
// and make sure it contains the "file"
@@ -263,7 +263,7 @@ JSONRPC_STATUS CFileOperations::Download(const CStdString &method, ITransportLay
return transport->Download(parameterObject["path"].asString().c_str(), result) ? OK : InvalidParams;
}
-bool CFileOperations::FillFileItem(const CFileItemPtr &originalItem, CFileItem &item, CStdString media /* = "" */)
+bool CFileOperations::FillFileItem(const CFileItemPtr &originalItem, CFileItem &item, CStdString media /* = "" */, const CVariant &parameterObject /* = CVariant(CVariant::VariantTypeArray) */)
{
if (originalItem.get() == NULL)
return false;
@@ -278,7 +278,7 @@ bool CFileOperations::FillFileItem(const CFileItemPtr &originalItem, CFileItem &
if (media.Equals("video"))
status = CVideoLibrary::FillFileItem(strFilename, item);
else if (media.Equals("music"))
- status = CAudioLibrary::FillFileItem(strFilename, item);
+ status = CAudioLibrary::FillFileItem(strFilename, item, parameterObject);
if (status && item.GetLabel().empty())
{
@@ -364,7 +364,7 @@ bool CFileOperations::FillFileItemList(const CVariant &parameterObject, CFileIte
else
{
CFileItem fileItem;
- if (FillFileItem(items[i], fileItem, media))
+ if (FillFileItem(items[i], fileItem, media, parameterObject))
list.Add(CFileItemPtr(new CFileItem(fileItem)));
else if (media == "files")
list.Add(items[i]);
View
2  xbmc/interfaces/json-rpc/FileOperations.h
@@ -35,7 +35,7 @@ namespace JSONRPC
static JSONRPC_STATUS PrepareDownload(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS Download(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
- static bool FillFileItem(const CFileItemPtr &originalItem, CFileItem &item, CStdString media = "");
+ static bool FillFileItem(const CFileItemPtr &originalItem, CFileItem &item, CStdString media = "", const CVariant &parameterObject = CVariant(CVariant::VariantTypeArray));
static bool FillFileItemList(const CVariant &parameterObject, CFileItemList &list);
};
}
View
18 xbmc/interfaces/json-rpc/PlayerOperations.cpp
@@ -37,6 +37,7 @@
#include "filesystem/File.h"
#include "PartyModeManager.h"
#include "epg/EpgInfoTag.h"
+#include "music/MusicDatabase.h"
#include "pvr/PVRManager.h"
#include "pvr/channels/PVRChannel.h"
#include "pvr/channels/PVRChannelGroupsContainer.h"
@@ -125,7 +126,7 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
}
else
{
- if (!CAudioLibrary::FillFileItem(g_application.CurrentFile(), tmpItem))
+ if (!CAudioLibrary::FillFileItem(g_application.CurrentFile(), tmpItem, parameterObject))
{
tmpItem = CFileItem(*g_infoManager.GetCurrentSongTag());
tmpItem.SetPath(g_application.CurrentFileItem().GetPath());
@@ -137,7 +138,10 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
else
fileItem = CFileItemPtr(new CFileItem(g_application.CurrentFileItem()));
- if (player == Video && !IsPVRChannel())
+ if (IsPVRChannel())
+ break;
+
+ if (player == Video)
{
bool additionalInfo = false;
for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
@@ -176,6 +180,16 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
}
}
}
+ else if (player == Audio)
+ {
+ if (fileItem->IsMusicDb())
+ {
+ CMusicDatabase musicdb;
+ CFileItemList items;
+ items.Add(fileItem);
+ CAudioLibrary::GetAdditionalSongDetails(parameterObject, items, musicdb);
+ }
+ }
break;
}
View
26 xbmc/interfaces/json-rpc/ServiceDescription.h
@@ -419,22 +419,25 @@ namespace JSONRPC
"\"Audio.Fields.Album\": {"
"\"extends\": \"Item.Fields.Base\","
"\"items\": { \"type\": \"string\","
+ "\"description\": \"Requesting the genreid and/or artistid field will result in increased response times\","
"\"enum\": [ \"title\", \"description\", \"artist\", \"genre\","
"\"theme\", \"mood\", \"style\", \"type\", \"albumlabel\","
"\"rating\", \"year\", \"musicbrainzalbumid\","
"\"musicbrainzalbumartistid\", \"fanart\", \"thumbnail\","
- "\"playcount\" ]"
+ "\"playcount\", \"genreid\", \"artistid\", \"displayartist\" ]"
"}"
"}",
"\"Audio.Fields.Song\": {"
"\"extends\": \"Item.Fields.Base\","
"\"items\": { \"type\": \"string\","
+ "\"description\": \"Requesting the genreid, artistid and/or albumartistid field will result in increased response times\","
"\"enum\": [ \"title\", \"artist\", \"albumartist\", \"genre\", \"year\","
"\"rating\", \"album\", \"track\", \"duration\", \"comment\","
"\"lyrics\", \"musicbrainztrackid\", \"musicbrainzartistid\","
"\"musicbrainzalbumid\", \"musicbrainzalbumartistid\","
- "\"playcount\", \"fanart\", \"thumbnail\", \"file\","
- "\"albumid\", \"lastplayed\", \"disc\" ]"
+ "\"playcount\", \"fanart\", \"thumbnail\", \"file\", \"albumid\","
+ "\"lastplayed\", \"disc\", \"genreid\", \"artistid\", \"displayartist\","
+ "\"albumartistid\" ]"
"}"
"}",
"\"Audio.Details.Base\": {"
@@ -451,7 +454,10 @@ namespace JSONRPC
"\"year\": { \"type\": \"integer\" },"
"\"rating\": { \"type\": \"integer\" },"
"\"musicbrainzalbumid\": { \"type\": \"string\" },"
- "\"musicbrainzalbumartistid\": { \"type\": \"string\" }"
+ "\"musicbrainzalbumartistid\": { \"type\": \"string\" },"
+ "\"genreid\": { \"$ref\": \"Array.Integer\" },"
+ "\"artistid\": { \"$ref\": \"Array.Integer\" },"
+ "\"displayartist\": { \"type\" : \"string\" }"
"}"
"}",
"\"Audio.Details.Artist\": {"
@@ -500,7 +506,8 @@ namespace JSONRPC
"\"musicbrainzartistid\": { \"type\": \"string\" },"
"\"albumid\": { \"$ref\": \"Library.Id\" },"
"\"lastplayed\": { \"type\": \"string\" },"
- "\"disc\": { \"type\": \"integer\" }"
+ "\"disc\": { \"type\": \"integer\" },"
+ "\"albumartistid\": { \"$ref\": \"Array.Integer\" }"
"}"
"}",
"\"Video.Fields.Movie\": {"
@@ -1043,7 +1050,8 @@ namespace JSONRPC
"\"tvshowid\": { \"$ref\": \"Library.Id\" },"
"\"watchedepisodes\": { \"type\": \"integer\" },"
"\"disc\": { \"type\": \"integer\" },"
- "\"tag\": { \"$ref\": \"Array.String\" }"
+ "\"tag\": { \"$ref\": \"Array.String\" },"
+ "\"albumartistid\": { \"$ref\": \"Array.Integer\" }"
"}"
"}",
"\"List.Fields.All\": {"
@@ -1059,7 +1067,8 @@ namespace JSONRPC
"\"firstaired\", \"season\", \"episode\", \"showtitle\", \"thumbnail\", \"file\","
"\"resume\", \"artistid\", \"albumid\", \"tvshowid\", \"setid\", \"watchedepisodes\","
"\"disc\", \"tag\", \"art\", \"channel\", \"channeltype\", \"hidden\", \"locked\","
- "\"channelnumber\", \"starttime\", \"endtime\" ]"
+ "\"channelnumber\", \"starttime\", \"endtime\", \"genreid\", \"displayartist\","
+ "\"albumartistid\" ]"
"}"
"}",
"\"List.Item.All\": {"
@@ -1086,7 +1095,8 @@ namespace JSONRPC
"\"runtime\", \"set\", \"showlink\", \"streamdetails\", \"top250\", \"votes\","
"\"firstaired\", \"season\", \"episode\", \"showtitle\", \"thumbnail\", \"file\","
"\"resume\", \"artistid\", \"albumid\", \"tvshowid\", \"setid\", \"watchedepisodes\","
- "\"disc\", \"tag\", \"art\", \"size\", \"lastmodified\", \"mimetype\" ]"
+ "\"disc\", \"tag\", \"art\", \"size\", \"lastmodified\", \"mimetype\", \"genreid\","
+ "\"displayartist\", \"albumartistid\" ]"
"}"
"}",
"\"List.Item.File\": {"
View
26 xbmc/interfaces/json-rpc/types.json
@@ -392,22 +392,25 @@
"Audio.Fields.Album": {
"extends": "Item.Fields.Base",
"items": { "type": "string",
+ "description": "Requesting the genreid and/or artistid field will result in increased response times",
"enum": [ "title", "description", "artist", "genre",
"theme", "mood", "style", "type", "albumlabel",
"rating", "year", "musicbrainzalbumid",
"musicbrainzalbumartistid", "fanart", "thumbnail",
- "playcount" ]
+ "playcount", "genreid", "artistid", "displayartist" ]
}
},
"Audio.Fields.Song": {
"extends": "Item.Fields.Base",
"items": { "type": "string",
+ "description": "Requesting the genreid, artistid and/or albumartistid field will result in increased response times",
"enum": [ "title", "artist", "albumartist", "genre", "year",
"rating", "album", "track", "duration", "comment",
"lyrics", "musicbrainztrackid", "musicbrainzartistid",
"musicbrainzalbumid", "musicbrainzalbumartistid",
- "playcount", "fanart", "thumbnail", "file",
- "albumid", "lastplayed", "disc" ]
+ "playcount", "fanart", "thumbnail", "file", "albumid",
+ "lastplayed", "disc", "genreid", "artistid", "displayartist",
+ "albumartistid" ]
}
},
"Audio.Details.Base": {
@@ -424,7 +427,10 @@
"year": { "type": "integer" },
"rating": { "type": "integer" },
"musicbrainzalbumid": { "type": "string" },
- "musicbrainzalbumartistid": { "type": "string" }
+ "musicbrainzalbumartistid": { "type": "string" },
+ "genreid": { "$ref": "Array.Integer" },
+ "artistid": { "$ref": "Array.Integer" },
+ "displayartist": { "type" : "string" }
}
},
"Audio.Details.Artist": {
@@ -473,7 +479,8 @@
"musicbrainzartistid": { "type": "string" },
"albumid": { "$ref": "Library.Id" },
"lastplayed": { "type": "string" },
- "disc": { "type": "integer" }
+ "disc": { "type": "integer" },
+ "albumartistid": { "$ref": "Array.Integer" }
}
},
"Video.Fields.Movie": {
@@ -1016,7 +1023,8 @@
"tvshowid": { "$ref": "Library.Id" },
"watchedepisodes": { "type": "integer" },
"disc": { "type": "integer" },
- "tag": { "$ref": "Array.String" }
+ "tag": { "$ref": "Array.String" },
+ "albumartistid": { "$ref": "Array.Integer" }
}
},
"List.Fields.All": {
@@ -1032,7 +1040,8 @@
"firstaired", "season", "episode", "showtitle", "thumbnail", "file",
"resume", "artistid", "albumid", "tvshowid", "setid", "watchedepisodes",
"disc", "tag", "art", "channel", "channeltype", "hidden", "locked",
- "channelnumber", "starttime", "endtime" ]
+ "channelnumber", "starttime", "endtime", "genreid", "displayartist",
+ "albumartistid" ]
}
},
"List.Item.All": {
@@ -1059,7 +1068,8 @@
"runtime", "set", "showlink", "streamdetails", "top250", "votes",
"firstaired", "season", "episode", "showtitle", "thumbnail", "file",
"resume", "artistid", "albumid", "tvshowid", "setid", "watchedepisodes",
- "disc", "tag", "art", "size", "lastmodified", "mimetype" ]
+ "disc", "tag", "art", "size", "lastmodified", "mimetype", "genreid",
+ "displayartist", "albumartistid" ]
}
},
"List.Item.File": {
View
75 xbmc/music/MusicDatabase.cpp
@@ -225,7 +225,8 @@ void CMusicDatabase::CreateViews()
" strMusicBrainzTRMID, iTimesPlayed, iStartOffset, iEndOffset, lastplayed,"
" rating, comment, song.idAlbum AS idAlbum, strAlbum, strPath,"
" iKaraNumber, iKaraDelay, strKaraEncoding,"
- " album.bCompilation AS bCompilation "
+ " album.bCompilation AS bCompilation,"
+ " album.strArtists AS strAlbumArtists "
"FROM song"
" JOIN album ON"
" song.idAlbum=album.idAlbum"
@@ -641,7 +642,7 @@ bool CMusicDatabase::AddAlbumGenre(int idGenre, int idAlbum, int iOrder)
return ExecuteQuery(strSQL);
};
-bool CMusicDatabase::GetAlbumsByArtist(int idArtist, bool includeFeatured, std::vector<long> &albums)
+bool CMusicDatabase::GetAlbumsByArtist(int idArtist, bool includeFeatured, std::vector<int> &albums)
{
try
{
@@ -675,7 +676,7 @@ bool CMusicDatabase::GetAlbumsByArtist(int idArtist, bool includeFeatured, std::
return false;
}
-bool CMusicDatabase::GetArtistsByAlbum(int idAlbum, bool includeFeatured, std::vector<long> &artists)
+bool CMusicDatabase::GetArtistsByAlbum(int idAlbum, bool includeFeatured, std::vector<int> &artists)
{
try
{
@@ -709,7 +710,7 @@ bool CMusicDatabase::GetArtistsByAlbum(int idAlbum, bool includeFeatured, std::v
return false;
}
-bool CMusicDatabase::GetSongsByArtist(int idArtist, bool includeFeatured, std::vector<long> &songs)
+bool CMusicDatabase::GetSongsByArtist(int idArtist, bool includeFeatured, std::vector<int> &songs)
{
try
{
@@ -743,7 +744,7 @@ bool CMusicDatabase::GetSongsByArtist(int idArtist, bool includeFeatured, std::v
return false;
};
-bool CMusicDatabase::GetArtistsBySong(int idSong, bool includeFeatured, std::vector<long> &artists)
+bool CMusicDatabase::GetArtistsBySong(int idSong, bool includeFeatured, std::vector<int> &artists)
{
try
{
@@ -775,7 +776,65 @@ bool CMusicDatabase::GetArtistsBySong(int idSong, bool includeFeatured, std::vec
CLog::Log(LOGERROR, "%s(%i) failed", __FUNCTION__, idSong);
}
return false;
-};
+}
+
+bool CMusicDatabase::GetGenresByAlbum(int idAlbum, std::vector<int>& genres)
+{
+ try
+ {
+ CStdString strSQL = PrepareSQL("select idGenre from album_genre where idAlbum = %i ORDER BY iOrder ASC", idAlbum);
+ if (!m_pDS->query(strSQL.c_str()))
+ return false;
+ if (m_pDS->num_rows() == 0)
+ {
+ m_pDS->close();
+ return true;
+ }
+
+ while (!m_pDS->eof())
+ {
+ genres.push_back(m_pDS->fv("idGenre").get_asInt());
+ m_pDS->next();
+ }
+ m_pDS->close();
+
+ return true;
+ }
+ catch (...)
+ {
+ CLog::Log(LOGERROR, "%s(%i) failed", __FUNCTION__, idAlbum);
+ }
+ return false;
+}
+
+bool CMusicDatabase::GetGenresBySong(int idSong, std::vector<int>& genres)
+{
+ try
+ {
+ CStdString strSQL = PrepareSQL("select idGenre from song_genre where idSong = %i ORDER BY iOrder ASC", idSong);
+ if (!m_pDS->query(strSQL.c_str()))
+ return false;
+ if (m_pDS->num_rows() == 0)
+ {
+ m_pDS->close();
+ return true;
+ }
+
+ while (!m_pDS->eof())
+ {
+ genres.push_back(m_pDS->fv("idGenre").get_asInt());
+ m_pDS->next();
+ }
+ m_pDS->close();
+
+ return true;
+ }
+ catch (...)
+ {
+ CLog::Log(LOGERROR, "%s(%i) failed", __FUNCTION__, idSong);
+ }
+ return false;
+}
int CMusicDatabase::AddPath(const CStdString& strPath1)
{
@@ -854,6 +913,7 @@ CSong CMusicDatabase::GetSongFromDataset(bool bWithMusicDbPath/*=false*/)
song.strKaraokeLyrEncoding = m_pDS->fv(song_strKarEncoding).get_asString();
song.iKaraokeDelay = m_pDS->fv(song_iKarDelay).get_asInt();
song.bCompilation = m_pDS->fv(song_bCompilation).get_asInt() == 1;
+ song.albumArtist = StringUtils::Split(m_pDS->fv(song_strAlbumArtists).get_asString(), g_advancedSettings.m_musicItemSeparator);
// Get filename with full path
if (!bWithMusicDbPath)
@@ -905,7 +965,8 @@ void CMusicDatabase::GetFileItemFromDataset(const dbiplus::sql_record* const rec
CStdString strRealPath;
URIUtils::AddFileToFolder(record->at(song_strPath).get_asString(), record->at(song_strFileName).get_asString(), strRealPath);
item->GetMusicInfoTag()->SetURL(strRealPath);
- item->GetMusicInfoTag()->SetCompilation(m_pDS->fv(song_bCompilation).get_asInt() == 1);
+ item->GetMusicInfoTag()->SetCompilation(record->at(song_bCompilation).get_asInt() == 1);
+ item->GetMusicInfoTag()->SetAlbumArtist(record->at(song_strAlbumArtists).get_asString());
item->GetMusicInfoTag()->SetLoaded(true);
// Get filename with full path
if (strMusicDBbasePath.IsEmpty())
View
16 xbmc/music/MusicDatabase.h
@@ -128,10 +128,13 @@ class CMusicDatabase : public CDatabase
bool GetAlbumFromSong(int idSong, CAlbum &album);
bool GetAlbumFromSong(const CSong &song, CAlbum &album);
- bool GetAlbumsByArtist(int idArtist, bool includeFeatured, std::vector<long>& albums);
- bool GetArtistsByAlbum(int idAlbum, bool includeFeatured, std::vector<long>& artists);
- bool GetSongsByArtist(int idArtist, bool includeFeatured, std::vector<long>& songs);
- bool GetArtistsBySong(int idSong, bool includeFeatured, std::vector<long>& artists);
+ bool GetAlbumsByArtist(int idArtist, bool includeFeatured, std::vector<int>& albums);
+ bool GetArtistsByAlbum(int idAlbum, bool includeFeatured, std::vector<int>& artists);
+ bool GetSongsByArtist(int idArtist, bool includeFeatured, std::vector<int>& songs);
+ bool GetArtistsBySong(int idSong, bool includeFeatured, std::vector<int>& artists);
+
+ bool GetGenresByAlbum(int idAlbum, std::vector<int>& genres);
+ bool GetGenresBySong(int idSong, std::vector<int>& genres);
bool GetTop100(const CStdString& strBaseDir, CFileItemList& items);
bool GetTop100Albums(VECALBUMS& albums);
@@ -278,7 +281,7 @@ class CMusicDatabase : public CDatabase
std::map<CStdString, CAlbum> m_albumCache;
virtual bool CreateTables();
- virtual int GetMinVersion() const { return 30; };
+ virtual int GetMinVersion() const { return 31; };
const char *GetBaseDBName() const { return "MyMusic"; };
int AddSong(const CSong& song, bool bCheck = true, int idAlbum = -1);
@@ -350,7 +353,8 @@ class CMusicDatabase : public CDatabase
song_iKarNumber,
song_iKarDelay,
song_strKarEncoding,
- song_bCompilation
+ song_bCompilation,
+ song_strAlbumArtists
} SongFields;
// Fields should be ordered as they
View
12 xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -554,8 +554,8 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
// finally, add these to the database
m_musicDatabase.BeginTransaction();
int numAdded = 0;
- set<long> albumsToScan;
- set<long> artistsToScan;
+ set<int> albumsToScan;
+ set<int> artistsToScan;
for (VECALBUMS::iterator i = albums.begin(); i != albums.end(); ++i)
{
vector<int> songIDs;
@@ -571,11 +571,11 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
albumsToScan.insert(idAlbum);
for (vector<int>::iterator j = songIDs.begin(); j != songIDs.end(); ++j)
{
- vector<long> songArtists;
+ vector<int> songArtists;
m_musicDatabase.GetArtistsBySong(*j, false, songArtists);
artistsToScan.insert(songArtists.begin(), songArtists.end());
}
- std::vector<long> albumArtists;
+ std::vector<int> albumArtists;
m_musicDatabase.GetArtistsByAlbum(idAlbum, false, albumArtists);
artistsToScan.insert(albumArtists.begin(), albumArtists.end());
}
@@ -583,7 +583,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
// Download info & artwork
bool bCanceled;
- for (set<long>::iterator it = artistsToScan.begin(); it != artistsToScan.end(); ++it)
+ for (set<int>::iterator it = artistsToScan.begin(); it != artistsToScan.end(); ++it)
{
bCanceled = false;
if (find(m_artistsScanned.begin(),m_artistsScanned.end(), *it) == m_artistsScanned.end())
@@ -608,7 +608,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
if (m_flags & SCAN_ONLINE)
{
- for (set<long>::iterator it = albumsToScan.begin(); it != albumsToScan.end(); ++it)
+ for (set<int>::iterator it = albumsToScan.begin(); it != albumsToScan.end(); ++it)
{
if (m_bStop)
return songsToAdd.size();
View
1  xbmc/music/tags/MusicInfoTag.cpp
@@ -571,6 +571,7 @@ void CMusicInfoTag::Serialize(CVariant& value) const
value["artist"] = m_artist[0];
else
value["artist"] = m_artist;
+ value["displayartist"] = StringUtils::Join(m_artist, g_advancedSettings.m_musicItemSeparator);
value["album"] = m_strAlbum;
value["albumartist"] = m_albumArtist;
value["genre"] = m_genre;
Please sign in to comment.
Something went wrong with that request. Please try again.