Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

jsonrpc: make sure to return artist details even if there's no entry …

…for that artist in the artistinfo table
  • Loading branch information...
commit 2e75130efa69624c7b75488a3eace9f58f8b0ee7 1 parent 261fc93
@Montellese Montellese authored
View
13 xbmc/interfaces/json-rpc/AudioLibrary.cpp
@@ -72,19 +72,16 @@ JSONRPC_STATUS CAudioLibrary::GetArtistDetails(const CStdString &method, ITransp
if (!musicdatabase.Open())
return InternalError;
- CArtist artist;
- if (!musicdatabase.GetArtistInfo(artistID, artist))
+ CFileItemList items;
+ CStdString where;
+ where.Format("idArtist = %d", artistID);
+ if (!musicdatabase.GetArtistsByWhere("musicdb://2/", where, items) || items.Size() != 1)
{
musicdatabase.Close();
return InvalidParams;
}
- CFileItemPtr m_artistItem(new CFileItem(artist));
- m_artistItem->GetMusicInfoTag()->SetArtist(m_artistItem->GetLabel());
- m_artistItem->GetMusicInfoTag()->SetDatabaseId(artistID);
- CMusicDatabase::SetPropertiesFromArtist(*m_artistItem, artist);
- m_artistItem->SetCachedArtistThumb();
- HandleFileItem("artistid", false, "artistdetails", m_artistItem, parameterObject, parameterObject["properties"], result, false);
+ HandleFileItem("artistid", false, "artistdetails", items[0], parameterObject, parameterObject["properties"], result, false);
musicdatabase.Close();
return OK;
View
30 xbmc/music/MusicDatabase.cpp
@@ -2767,12 +2767,9 @@ bool CMusicDatabase::GetArtistsNav(const CStdString& strBaseDir, CFileItemList&
if (NULL == m_pDS.get()) return false;
try
{
- if (NULL == m_pDB.get()) return false;
- if (NULL == m_pDS.get()) return false;
-
unsigned int time = XbmcThreads::SystemClockMillis();
- CStdString strSQL = "select * from artist where (idArtist IN ";
+ CStdString strSQL = "(idArtist IN ";
if (idGenre==-1)
{
@@ -2865,6 +2862,30 @@ bool CMusicDatabase::GetArtistsNav(const CStdString& strBaseDir, CFileItemList&
strSQL+=PrepareSQL(" and artist.idArtist<>%i", idVariousArtists);
}
+ bool result = GetArtistsByWhere(strBaseDir, strSQL, items);
+ CLog::Log(LOGDEBUG,"Time to retrieve artists from dataset = %i", XbmcThreads::SystemClockMillis() - time);
+
+ return result;
+ }
+ catch (...)
+ {
+ m_pDS->close();
+ CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
+ }
+ return false;
+}
+
+bool CMusicDatabase::GetArtistsByWhere(const CStdString& strBaseDir, const CStdString &where, CFileItemList& items)
+{
+ if (NULL == m_pDB.get()) return false;
+ if (NULL == m_pDS.get()) return false;
+
+ try
+ {
+ CStdString strSQL = "select * from artist";
+ if (!where.empty())
+ strSQL += " WHERE " + where;
+
// run query
CLog::Log(LOGDEBUG, "%s query: %s", __FUNCTION__, strSQL.c_str());
if (!m_pDS->query(strSQL.c_str())) return false;
@@ -2900,7 +2921,6 @@ bool CMusicDatabase::GetArtistsNav(const CStdString& strBaseDir, CFileItemList&
m_pDS->next();
}
- CLog::Log(LOGDEBUG,"Time to retrieve artists from dataset = %i", XbmcThreads::SystemClockMillis() - time);
// cleanup
m_pDS->close();
View
1  xbmc/music/MusicDatabase.h
@@ -165,6 +165,7 @@ class CMusicDatabase : public CDatabase
bool GetSongsByYear(const CStdString& baseDir, CFileItemList& items, int year);
bool GetSongsByWhere(const CStdString &baseDir, const CStdString &whereClause, CFileItemList& items);
bool GetAlbumsByWhere(const CStdString &baseDir, const CStdString &where, const CStdString &order, CFileItemList &items);
+ bool GetArtistsByWhere(const CStdString& strBaseDir, const CStdString &where, CFileItemList& items);
bool GetRandomSong(CFileItem* item, int& idSong, const CStdString& strWhere);
int GetKaraokeSongsCount();
int GetSongsCount(const CStdString& strWhere = "");
Please sign in to comment.
Something went wrong with that request. Please try again.