Exemple #1
0
void CGUIDialogMusicInfo::ShowFor(CFileItem* pItem)
{
  if (pItem->IsParentFolder() || URIUtils::IsSpecial(pItem->GetPath()) ||
    StringUtils::StartsWithNoCase(pItem->GetPath(), "musicsearch://"))
    return; // nothing to do

  if (!pItem->m_bIsFolder)
  { // Show Song information dialog
    CGUIDialogSongInfo::ShowFor(pItem);
    return;
  }

  // We have a folder album/artist info dialog only shown for db items
  if (pItem->IsMusicDb())
  {
    if (!pItem->HasMusicInfoTag() || pItem->GetMusicInfoTag()->GetDatabaseId() < 1)
    {
      // Maybe only path is set, then set MusicInfoTag
      CQueryParams params;
      CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params);
      if (params.GetAlbumId() == -1)
        pItem->GetMusicInfoTag()->SetDatabaseId(params.GetArtistId(), MediaTypeArtist);
      else
        pItem->GetMusicInfoTag()->SetDatabaseId(params.GetAlbumId(), MediaTypeAlbum);
    }
    CGUIDialogMusicInfo *pDlgMusicInfo = CServiceBroker::GetGUI()->GetWindowManager().
	  GetWindow<CGUIDialogMusicInfo>(WINDOW_DIALOG_MUSIC_INFO);
    if (pDlgMusicInfo)
    {
      if (pDlgMusicInfo->SetItem(pItem))
      {
        pDlgMusicInfo->Open();
        if (pItem->GetMusicInfoTag()->GetType() == MediaTypeAlbum &&
          pDlgMusicInfo->HasUpdatedUserrating())
        {
          auto window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowMusicBase>(WINDOW_MUSIC_NAV);
          if (window)
            window->RefreshContent("albums");
        }
      }
    }
  }
}
bool CGUIWindowMusicBase::ShowAlbumInfo(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_ALBUMS))
        return false;

    CAlbum album;
    if (!m_musicdatabase.GetAlbum(params.GetAlbumId(), album))
        return false;

    m_musicdatabase.GetAlbumPath(params.GetAlbumId(), album.strPath);
    while (1)
    {
        if (!m_musicdatabase.HasAlbumBeenScraped(params.GetAlbumId()))
        {
            if (!CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
            {
                // TODO: should display a dialog saying no permissions
                if (m_dlgProgress)
                    m_dlgProgress->Close();
                return false;
            }

            if (g_application.IsMusicScanning())
            {
                CGUIDialogOK::ShowAndGetInput(CVariant{189}, CVariant{14057});
                if (m_dlgProgress)
                    m_dlgProgress->Close();
                return false;
            }

            // show dialog box indicating we're searching the album
            if (m_dlgProgress && bShowInfo)
            {
                m_dlgProgress->SetHeading(CVariant{185});
                m_dlgProgress->SetLine(0, CVariant{pItem->GetMusicInfoTag()->GetAlbum()});
                m_dlgProgress->SetLine(1, CVariant{StringUtils::Join(pItem->GetMusicInfoTag()->GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator)});
                m_dlgProgress->SetLine(2, CVariant{""});
                m_dlgProgress->Open();
            }

            CMusicInfoScanner scanner;
            if (scanner.UpdateDatabaseAlbumInfo(album, scraper, bShowInfo, m_dlgProgress) != INFO_ADDED)
            {
                CGUIDialogOK::ShowAndGetInput(CVariant{185}, CVariant{500});
                if (m_dlgProgress)
                    m_dlgProgress->Close();
                return false;
            }
        }

        if (m_dlgProgress)
            m_dlgProgress->Close();

        CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
        if (pDlgAlbumInfo)
        {
            pDlgAlbumInfo->SetAlbum(album, album.strPath);
            pDlgAlbumInfo->Open();

            if (pDlgAlbumInfo->NeedRefresh())
            {
                m_musicdatabase.ClearAlbumLastScrapedTime(params.GetAlbumId());
                continue;
            }
            else if (pDlgAlbumInfo->HasUpdatedThumb())
            {
                UpdateThumb(album, album.strPath);
            }
        }
        break;
    }
    if (m_dlgProgress)
        m_dlgProgress->Close();
    return true;
}
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();
}
Exemple #4
0
bool CGUIWindowMusicBase::ShowAlbumInfo(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_ALBUMS))
    return false;

  CAlbum album;
  if (!m_musicdatabase.GetAlbum(params.GetAlbumId(), album))
    return false;
  album.bScrapedMBID = m_musicdatabase.HasScrapedAlbumMBID(album.idAlbum);
  m_musicdatabase.GetAlbumPath(params.GetAlbumId(), album.strPath);
  bool refresh = false;
  while (1)
  {
    // Check if the entry should be refreshed (Only happens if a user pressed refresh)
    if (refresh)
    {
      if (!CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
      {
        //! @todo should display a dialog saying no permissions
        if (m_dlgProgress)
          m_dlgProgress->Close();
        return false;
      }

      if (g_application.IsMusicScanning())
      {
        CGUIDialogOK::ShowAndGetInput(CVariant{189}, CVariant{14057});
        if (m_dlgProgress)
          m_dlgProgress->Close();
        return false;
      }

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

      CMusicInfoScanner scanner;
      if (scanner.UpdateDatabaseAlbumInfo(album, scraper, bShowInfo, m_dlgProgress) != INFO_ADDED)
      {
        CGUIDialogOK::ShowAndGetInput(CVariant{185}, CVariant{500});
        if (m_dlgProgress)
          m_dlgProgress->Close();
        return false;
      }
    }

    if (m_dlgProgress)
      m_dlgProgress->Close();

    CGUIDialogMusicInfo *pDlgAlbumInfo = g_windowManager.GetWindow<CGUIDialogMusicInfo>(WINDOW_DIALOG_MUSIC_INFO);
    if (pDlgAlbumInfo)
    {
      pDlgAlbumInfo->SetAlbum(album, album.strPath);
      pDlgAlbumInfo->Open();

      if (pDlgAlbumInfo->NeedRefresh())
      {
        m_musicdatabase.ClearAlbumLastScrapedTime(params.GetAlbumId());
        refresh = true;
        continue;
      }
      else if (pDlgAlbumInfo->HasUpdatedThumb())
        UpdateThumb(album, album.strPath);
      else if (pDlgAlbumInfo->NeedsUpdate())
        Refresh(true); // update our file list

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

  ADDON::ScraperPtr scraper;
  if (!m_musicdatabase.GetScraper(params.GetArtistId(), CONTENT_ARTISTS, scraper))
    return;

  CArtist artist;
  if (!m_musicdatabase.GetArtist(params.GetArtistId(), artist))
    return;
  // Get the *name* of the folder for this artist within the Artist Info folder (may not exist).
  // If there is no Artist Info folder specififed in settings this will be blank
  bool artistpathfound = m_musicdatabase.GetArtistPath(artist, artist.strPath);

  // Set up path for *item folder when browsing for art, by default this is in the Artist Info Folder
  std::string artistItemPath = artist.strPath;
  if (!artistpathfound || !CDirectory::Exists(artist.strPath))
    // 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 (!m_musicdatabase.GetOldArtistPath(artist.idArtist, artistItemPath))
      // Fall back further to browse the Artist Info Folder itself
      artistItemPath = CServiceBroker::GetSettings().GetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSFOLDER);

  bool refresh = false;
  while (1)
  {
    // Check if the entry should be refreshed (Only happens if a user pressed refresh)
    if (refresh)
    {
      if (!CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
        break; // should display a dialog saying no permissions

      if (g_application.IsMusicScanning())
      {
        HELPERS::ShowOKDialogText(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.UpdateArtistInfo(artist, scraper, bShowInfo, m_dlgProgress) != INFO_ADDED)
      {
        HELPERS::ShowOKDialogText(CVariant{21889}, CVariant{20199});
        break;
      }
    }

    if (m_dlgProgress)
      m_dlgProgress->Close();

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

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