JSON_STATUS CAudioLibrary::GetAlbumDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const Value ¶meterObject, Value &result) { int albumID = parameterObject["albumid"].asInt(); CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; CAlbum album; if (!musicdatabase.GetAlbumInfo(albumID, album, NULL)) { musicdatabase.Close(); return InvalidParams; } Json::Value validFields; MakeFieldsList(parameterObject, validFields); CStdString path; musicdatabase.GetAlbumPath(albumID, path); CFileItemPtr m_albumItem( new CFileItem(path, album) ); m_albumItem->SetLabel(album.strAlbum); CMusicDatabase::SetPropertiesFromAlbum(*m_albumItem, album); m_albumItem->SetMusicThumb(); HandleFileItem("albumid", false, "albumdetails", m_albumItem, parameterObject, validFields, result); musicdatabase.Close(); return OK; }
JSONRPC_STATUS CAudioLibrary::GetAlbumDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { int albumID = (int)parameterObject["albumid"].asInteger(); CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; CAlbum album; if (!musicdatabase.GetAlbumInfo(albumID, album, NULL)) return InvalidParams; CStdString path; if (!musicdatabase.GetAlbumPath(albumID, path)) return InternalError; 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; }
JSON_STATUS CAudioLibrary::GetAlbumDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { int albumID = (int)parameterObject["albumid"].asInteger(); CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; CAlbum album; if (!musicdatabase.GetAlbumInfo(albumID, album, NULL)) { musicdatabase.Close(); return InvalidParams; } CStdString path; musicdatabase.GetAlbumPath(albumID, path); CFileItemPtr m_albumItem; FillAlbumItem(album, path, m_albumItem); HandleFileItem("albumid", false, "albumdetails", m_albumItem, parameterObject, parameterObject["properties"], result, false); musicdatabase.Close(); return OK; }
void CGUIDialogMusicInfo::OnSearch(const CFileItem* pItem) { CMusicDatabase database; database.Open(); if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->GetDatabaseId() > 0) { CAlbum album; if (database.GetAlbum(pItem->GetMusicInfoTag()->GetDatabaseId(), album)) { std::string strPath; database.GetAlbumPath(pItem->GetMusicInfoTag()->GetDatabaseId(), strPath); SetAlbum(album,strPath); Update(); } } }
void CGUIDialogMusicInfo::OnSearch(const CFileItem* pItem) { CMusicDatabase database; database.Open(); long idAlbum = database.GetAlbumByName(pItem->GetLabel(),m_artist.strArtist); if (idAlbum != -1) { CAlbum album; if (database.GetAlbumInfo(idAlbum,album,&album.songs)) { CStdString strPath; database.GetAlbumPath(idAlbum,strPath); SetAlbum(album,strPath); Update(); } } }
// Fetch full album/artist information including art types list bool DoWork() override { CGUIDialogMusicInfo *dialog = CServiceBroker::GetGUI()->GetWindowManager(). GetWindow<CGUIDialogMusicInfo>(WINDOW_DIALOG_MUSIC_INFO); if (!dialog) return false; if (dialog->IsCancelled()) return false; CFileItemPtr m_item = dialog->GetCurrentListItem(); CMusicInfoTag& tag = *m_item->GetMusicInfoTag(); CMusicDatabase database; database.Open(); // May only have partially populated item, so fetch all artist or album data from db if (tag.GetType() == MediaTypeArtist) { int artistId = tag.GetDatabaseId(); CArtist artist; if (!database.GetArtist(artistId, artist)) return false; tag.SetArtist(artist); CMusicDatabase::SetPropertiesFromArtist(*m_item, artist); m_item->SetLabel(artist.strArtist); // Get artist folder where local art could be found // Get the *name* of the folder for this artist within the Artist Info folder (may not exist). // If there is no Artist Info folder specified in settings this will be blank database.GetArtistPath(artist, artist.strPath); // Get the old location for those album artists with a unique folder (local to music files) // If there is no folder for the artist and *only* the artist this will be blank std::string oldartistpath; bool oldpathfound = database.GetOldArtistPath(artist.idArtist, oldartistpath); // Set up path for *item folder when browsing for art, by default this is // in the Artist Info Folder (when it exists), but could end up blank std::string artistItemPath = artist.strPath; if (!CDirectory::Exists(artistItemPath)) { // Fall back local to music files (historic location for those album artists with a unique folder) // although there may not be such a unique folder for the arist if (oldpathfound) artistItemPath = oldartistpath; else // Fall back further to browse the Artist Info Folder itself artistItemPath = CServiceBroker::GetSettings().GetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSFOLDER); } m_item->SetPath(artistItemPath); // Store info as CArtist as well as item properties dialog->SetArtist(artist, oldartistpath); // Fetch artist discography as scraped from online sources, but always // include all the albums in the music library dialog->SetDiscography(database); } else { // tag.GetType == MediaTypeAlbum int albumId = tag.GetDatabaseId(); CAlbum album; if (!database.GetAlbum(albumId, album)) return false; tag.SetAlbum(album); CMusicDatabase::SetPropertiesFromAlbum(*m_item, album); // Get album folder where local art could be found database.GetAlbumPath(albumId, album.strPath); // Set up path for *item folder when browsing for art m_item->SetPath(album.strPath); // Store info as CAlbum as well as item properties dialog->SetAlbum(album, album.strPath); // Set the list of songs and related art dialog->SetSongs(album.songs); } database.Close(); /* Load current art (to CGUIListItem.m_art) For albums this includes related artist(s) art and artist fanart set as fallback album fanart. Clear item art first to ensure fresh not cached/partial art */ m_item->ClearArt(); CMusicThumbLoader loader; loader.LoadItem(m_item.get()); // Fill vector of possible art types with current art, when it exists, // for display on the art type selection dialog CFileItemList artlist; MUSIC_UTILS::FillArtTypesList(*m_item, artlist); dialog->SetArtTypeList(artlist); if (dialog->IsCancelled()) return false; // Tell waiting MusicDialog that job is complete dialog->FetchComplete(); return true; }