void CGUIWindowMusicBase::ShowArtistInfo(const CFileItem *pItem, bool bShowInfo /* = true */)
{
    CQueryParams params;
    CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params);

    ADDON::ScraperPtr scraper;
    if (!m_musicdatabase.GetScraperForPath(pItem->GetPath(), scraper, ADDON::ADDON_SCRAPER_ARTISTS))
        return;

    CArtist artist;
    if (!m_musicdatabase.GetArtist(params.GetArtistId(), artist))
        return;

    m_musicdatabase.GetArtistPath(params.GetArtistId(), artist.strPath);
    while (1)
    {
        // Check if we have the information in the database first
        if (!m_musicdatabase.HasArtistBeenScraped(params.GetArtistId()))
        {
            if (!CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
                break; // should display a dialog saying no permissions

            if (g_application.IsMusicScanning())
            {
                CGUIDialogOK::ShowAndGetInput(CVariant{189}, CVariant{14057});
                break;
            }

            // show dialog box indicating we're searching the album
            if (m_dlgProgress && bShowInfo)
            {
                m_dlgProgress->SetHeading(CVariant{21889});
                m_dlgProgress->SetLine(0, CVariant{pItem->GetMusicInfoTag()->GetArtist()});
                m_dlgProgress->SetLine(1, CVariant{""});
                m_dlgProgress->SetLine(2, CVariant{""});
                m_dlgProgress->Open();
            }

            CMusicInfoScanner scanner;
            if (scanner.UpdateDatabaseArtistInfo(artist, scraper, bShowInfo, m_dlgProgress) != INFO_ADDED)
            {
                CGUIDialogOK::ShowAndGetInput(CVariant{21889}, CVariant{20199});
                break;
            }
        }

        if (m_dlgProgress)
            m_dlgProgress->Close();

        CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
        if (pDlgArtistInfo)
        {
            pDlgArtistInfo->SetArtist(artist, artist.strPath);
            pDlgArtistInfo->Open();

            if (pDlgArtistInfo->NeedRefresh())
            {
                m_musicdatabase.ClearArtistLastScrapedTime(params.GetArtistId());
                continue;
            }
            else if (pDlgArtistInfo->HasUpdatedThumb())
            {
                Update(m_vecItems->GetPath());
            }
        }
        break;
    }
    if (m_dlgProgress)
        m_dlgProgress->Close();
}
Esempio n. 2
0
void CGUIWindowMusicBase::ShowArtistInfo(const CFileItem *pItem, bool bShowInfo /* = true */)
{
  CQueryParams params;
  CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params);
  CMusicArtistInfo artistInfo;
  while (1)
  {
    // Check if we have the information in the database first
    if (!m_musicdatabase.HasArtistInfo(params.GetArtistId()) ||
        !m_musicdatabase.GetArtistInfo(params.GetArtistId(), artistInfo.GetArtist()))
    {
      if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
        break; // should display a dialog saying no permissions

      if (g_application.IsMusicScanning())
      {
        CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
        break;
      }

      // show dialog box indicating we're searching the album
      if (m_dlgProgress && bShowInfo)
      {
        m_dlgProgress->SetHeading(21889);
        m_dlgProgress->SetLine(0, pItem->GetMusicInfoTag()->GetArtist());
        m_dlgProgress->SetLine(1, "");
        m_dlgProgress->SetLine(2, "");
        m_dlgProgress->StartModal();
      }

      CMusicInfoScanner scanner;
      if (scanner.UpdateDatabaseArtistInfo(pItem->GetPath(), artistInfo, bShowInfo) != INFO_ADDED || !artistInfo.Loaded())
      {
        CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0);
        break;
      }
    }

    if (m_dlgProgress)
      m_dlgProgress->Close();

    CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
    if (pDlgArtistInfo)
    {
      CStdString strPath;
      m_musicdatabase.GetArtistPath(params.GetArtistId(), strPath);
      pDlgArtistInfo->SetArtist(artistInfo.GetArtist(), strPath);
      pDlgArtistInfo->DoModal();

      if (pDlgArtistInfo->NeedRefresh())
      {
        m_musicdatabase.DeleteArtistInfo(params.GetArtistId());
        continue;
      } 
      else if (pDlgArtistInfo->HasUpdatedThumb()) 
      {
        Update(m_vecItems->GetPath());
      }
    }
    break;
  }
  if (m_dlgProgress)
    m_dlgProgress->Close();
}