void CGUIDialogSongInfo::OnInitWindow() { CMusicDatabase db; db.Open(); // no known db info - check if parent dir is an album if (m_song->GetMusicInfoTag()->GetDatabaseId() == -1) { std::string path = URIUtils::GetDirectory(m_song->GetPath()); m_albumId = db.GetAlbumIdByPath(path); } else { CAlbum album; db.GetAlbumFromSong(m_song->GetMusicInfoTag()->GetDatabaseId(),album); m_albumId = album.idAlbum; } CONTROL_ENABLE_ON_CONDITION(CONTROL_ALBUMINFO, m_albumId > -1); // Disable music user rating button for plugins as they don't have tables to save this if (m_song->IsPlugin()) CONTROL_DISABLE(CONTROL_USERRATING); else CONTROL_ENABLE(CONTROL_USERRATING); SET_CONTROL_HIDDEN(CONTROL_BTN_REFRESH); SET_CONTROL_HIDDEN(CONTROL_LIST); SET_CONTROL_LABEL(CONTROL_USERRATING, 38023); SET_CONTROL_LABEL(CONTROL_BTN_GET_THUMB, 13405); SET_CONTROL_LABEL(CONTROL_ALBUMINFO, 10523); CGUIDialog::OnInitWindow(); }
void CGUIDialogSongInfo::OnInitWindow() { CMusicDatabase db; db.Open(); // no known db info - check if parent dir is an album if (m_song->GetMusicInfoTag()->GetDatabaseId() == -1) { std::string path = URIUtils::GetDirectory(m_song->GetPath()); m_albumId = db.GetAlbumIdByPath(path); } else { CAlbum album; db.GetAlbumFromSong(m_song->GetMusicInfoTag()->GetDatabaseId(),album); m_albumId = album.idAlbum; } CONTROL_ENABLE_ON_CONDITION(CONTROL_ALBUMINFO, m_albumId > -1); CGUIDialog::OnInitWindow(); }
bool CMusicInfoLoader::LoadAdditionalTagInfo(CFileItem* pItem) { if (!pItem || (pItem->m_bIsFolder && !pItem->IsAudio()) || pItem->IsPlayList() || pItem->IsNFO() || pItem->IsInternetStream()) return false; if (pItem->GetProperty("hasfullmusictag") == "true") return false; // already have the information std::string path(pItem->GetPath()); // For songs in library set the (primary) song artist and album properties // Use song Id (not path) as called for items from either library or file view, // but could also be listitem with tag loaded by a script if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->GetType() == MediaTypeSong && pItem->GetMusicInfoTag()->GetDatabaseId() > 0) { CMusicDatabase database; database.Open(); // May already have song artist ids as item property set when data read from // db, but check property is valid array (scripts could set item properties // incorrectly), otherwise fetch artist using song id. CArtist artist; bool artistfound = false; if (pItem->HasProperty("artistid") && pItem->GetProperty("artistid").isArray()) { CVariant::const_iterator_array varid = pItem->GetProperty("artistid").begin_array(); int idArtist = varid->asInteger(); artistfound = database.GetArtist(idArtist, artist, false); } else artistfound = database.GetArtistFromSong(pItem->GetMusicInfoTag()->GetDatabaseId(), artist); if (artistfound) CMusicDatabase::SetPropertiesFromArtist(*pItem, artist); // May already have album id, otherwise fetch album from song id CAlbum album; bool albumfound = false; int idAlbum = pItem->GetMusicInfoTag()->GetAlbumId(); if (idAlbum > 0) albumfound = database.GetAlbum(idAlbum, album, false); else albumfound = database.GetAlbumFromSong(pItem->GetMusicInfoTag()->GetDatabaseId(), album); if (albumfound) CMusicDatabase::SetPropertiesFromAlbum(*pItem, album); path = pItem->GetMusicInfoTag()->GetURL(); } CLog::Log(LOGDEBUG, "Loading additional tag info for file %s", path.c_str()); // we load up the actual tag for this file in order to // fetch the lyrics and add it to the current music info tag CFileItem tempItem(path, false); std::unique_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(tempItem)); if (NULL != pLoader.get()) { CMusicInfoTag tag; pLoader->Load(path, tag); pItem->GetMusicInfoTag()->SetLyrics(tag.GetLyrics()); pItem->SetProperty("hasfullmusictag", "true"); return true; } return false; }