void CGUIWindowMusicBase::ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bShowInfo /* = true */)
{
  bool saveDb = album.idAlbum != -1;
  if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
    saveDb = false;

  CMusicAlbumInfo albumInfo;
  while (1)
  {
    if (!m_musicdatabase.HasAlbumInfo(album.idAlbum) || 
        !m_musicdatabase.GetAlbumInfo(album.idAlbum, albumInfo.GetAlbum(), &albumInfo.GetAlbum().songs))
    {
      if (g_application.IsMusicScanning())
      {
        CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
        break;
      }

      if (!FindAlbumInfo(album.strAlbum, 
                         StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator),
                         albumInfo,
                         bShowInfo ? SELECTION_ALLOWED : SELECTION_AUTO))
        break;
      
      if (!albumInfo.Loaded())
      {
        CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0);
        break;
      }

      albumInfo.GetAlbum().strAlbum = album.strAlbum;

      if (saveDb)
        m_musicdatabase.SetAlbumInfo(album.idAlbum, albumInfo.GetAlbum(), albumInfo.GetSongs());
    }

    CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
    if (pDlgAlbumInfo)
    {
      pDlgAlbumInfo->SetAlbum(albumInfo.GetAlbum(), path);
      pDlgAlbumInfo->DoModal();

      if (pDlgAlbumInfo->NeedRefresh())
      {
        m_musicdatabase.DeleteAlbumInfo(album.idAlbum);
        continue;
      }
      else if (pDlgAlbumInfo->HasUpdatedThumb())
      {
        UpdateThumb(album, path);
      }
    }
    break;
  }
  if (m_dlgProgress)
    m_dlgProgress->Close();
}
void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bShowInfo /* = true */)
{
  bool saveDb = artist.idArtist != -1;
  if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
    saveDb = false;

  CMusicArtistInfo artistInfo;
  while (1)
  {
    if (!m_musicdatabase.HasArtistInfo(artist.idArtist) ||
        !m_musicdatabase.GetArtistInfo(artist.idArtist, artistInfo.GetArtist()))
    {
      if (g_application.IsMusicScanning())
      {
        CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
        break;
      }

      if (!FindArtistInfo(artist.strArtist, artistInfo, bShowInfo ? SELECTION_ALLOWED : SELECTION_AUTO))
        break;

      if (!artistInfo.Loaded())
      {
        // Failed to download album info
        CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0);
        break;
      }

      if (saveDb)
        m_musicdatabase.SetArtistInfo(artist.idArtist, artistInfo.GetArtist());
    }

    CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
    if (pDlgArtistInfo)
    {
      pDlgArtistInfo->SetArtist(artistInfo.GetArtist(), path);
      pDlgArtistInfo->DoModal();

      if (pDlgArtistInfo->NeedRefresh())
      {
        m_musicdatabase.DeleteArtistInfo(artist.idArtist);
        continue;
      } 
      else if (pDlgArtistInfo->HasUpdatedThumb()) 
      {
        Update(m_vecItems->GetPath());
      }
    }
    break;
  }
  if (m_dlgProgress)
    m_dlgProgress->Close();
}
Exemple #3
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");
        }
      }
    }
  }
}
Exemple #4
0
void CGUIWindowMusicBase::ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bRefresh, bool bShowInfo)
{
  bool saveDb = album.idAlbum != -1;
  if (!g_settings.GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
    saveDb = false;

  // check cache
  CAlbum albumInfo;
  if (!bRefresh && m_musicdatabase.GetAlbumInfo(album.idAlbum, albumInfo, &albumInfo.songs))
  {
    if (!bShowInfo)
      return;

    CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
    if (pDlgAlbumInfo)
    {
      pDlgAlbumInfo->SetAlbum(albumInfo, path);
      if (bShowInfo)
        pDlgAlbumInfo->DoModal();

      if (!pDlgAlbumInfo->NeedRefresh())
      {
        if (pDlgAlbumInfo->HasUpdatedThumb())
          UpdateThumb(albumInfo, path);
        return;
      }
      bRefresh = true;
      m_musicdatabase.DeleteAlbumInfo(albumInfo.idAlbum);
    }
  }

  // If we are scanning for music info in the background,
  // other writing access to the database is prohibited.
  if (g_application.IsMusicScanning())
  {
    CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
    return;
  }

  CMusicAlbumInfo info;
  if (FindAlbumInfo(album.strAlbum, StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator), info, bShowInfo ? (bRefresh ? SELECTION_FORCED : SELECTION_ALLOWED) : SELECTION_AUTO))
  {
    // download the album info
    if ( info.Loaded() )
    {
      // set album title from musicinfotag, not the one we got from allmusic.com
      info.SetTitle(album.strAlbum);

      if (saveDb)
      {
        // save to database
        m_musicdatabase.SetAlbumInfo(album.idAlbum, info.GetAlbum(), info.GetSongs());
      }
      if (m_dlgProgress && bShowInfo)
        m_dlgProgress->Close();

      UpdateThumb(album, path);

      // ok, show album info
      CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
      if (pDlgAlbumInfo)
      {
        pDlgAlbumInfo->SetAlbum(info.GetAlbum(), path);
        if (bShowInfo)
          pDlgAlbumInfo->DoModal();

        CAlbum albumInfo = info.GetAlbum();
        albumInfo.idAlbum = album.idAlbum;
        if (pDlgAlbumInfo->HasUpdatedThumb())
          UpdateThumb(albumInfo, path);

        if (pDlgAlbumInfo->NeedRefresh())
        {
          m_musicdatabase.DeleteAlbumInfo(albumInfo.idAlbum);
          ShowAlbumInfo(album, path, true, bShowInfo);
          return;
        }
      }
    }
    else
    {
      // failed 2 download album info
      CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0);
    }
  }

  if (m_dlgProgress && bShowInfo)
    m_dlgProgress->Close();
}
Exemple #5
0
void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bRefresh, bool bShowInfo)
{
  bool saveDb = artist.idArtist != -1;
  if (!g_settings.GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
    saveDb = false;

  // check cache
  CArtist artistInfo;
  if (!bRefresh && m_musicdatabase.GetArtistInfo(artist.idArtist, artistInfo))
  {
    if (!bShowInfo)
      return;

    CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
    if (pDlgArtistInfo)
    {
      pDlgArtistInfo->SetArtist(artistInfo, path);

      if (bShowInfo)
        pDlgArtistInfo->DoModal();

      if (!pDlgArtistInfo->NeedRefresh())
      {
        if (pDlgArtistInfo->HasUpdatedThumb())
          Update(m_vecItems->GetPath());

        return;
      }
      bRefresh = true;
      m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist);
    }
  }

  // If we are scanning for music info in the background,
  // other writing access to the database is prohibited.
  if (g_application.IsMusicScanning())
  {
    CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
    return;
  }

  CMusicArtistInfo info;
  if (FindArtistInfo(artist.strArtist, info, bShowInfo ? (bRefresh ? SELECTION_FORCED : SELECTION_ALLOWED) : SELECTION_AUTO))
  {
    // download the album info
    if ( info.Loaded() )
    {
      if (saveDb)
      {
        // save to database
        m_musicdatabase.SetArtistInfo(artist.idArtist, info.GetArtist());
      }
      if (m_dlgProgress && bShowInfo)
        m_dlgProgress->Close();

      // ok, show album info
      CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
      if (pDlgArtistInfo)
      {
        pDlgArtistInfo->SetArtist(info.GetArtist(), path);
        if (bShowInfo)
          pDlgArtistInfo->DoModal();

        CArtist artistInfo = info.GetArtist();
        artistInfo.idArtist = artist.idArtist;
/*
        if (pDlgAlbumInfo->HasUpdatedThumb())
          UpdateThumb(artistInfo, path);
*/
        // just update for now
        Update(m_vecItems->GetPath());
        if (pDlgArtistInfo->NeedRefresh())
        {
          m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist);
          ShowArtistInfo(artist, path, true, bShowInfo);
          return;
        }
      }
    }
    else
    {
      // failed 2 download album info
      CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0);
    }
  }

  if (m_dlgProgress && bShowInfo)
    m_dlgProgress->Close();
}
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 #8
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;
}
bool CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /* = true */)
{
  CQueryParams params;
  CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params);
  CMusicAlbumInfo albumInfo;
  while (1)
  {
    if (!m_musicdatabase.HasAlbumInfo(params.GetAlbumId()) || 
        !m_musicdatabase.GetAlbumInfo(params.GetAlbumId(), albumInfo.GetAlbum(), &albumInfo.GetAlbum().songs))
    {
      if (!CProfilesManager::Get().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(189, 14057, 0, 0);
        if (m_dlgProgress)
          m_dlgProgress->Close();
        return false;
      }

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

      CMusicInfoScanner scanner;
      if (scanner.UpdateDatabaseAlbumInfo(pItem->GetPath(), albumInfo, bShowInfo) != INFO_ADDED || !albumInfo.Loaded())
      {
        CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0);
        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)
    {
      CStdString strPath;
      m_musicdatabase.GetAlbumPath(params.GetAlbumId(), strPath);
      pDlgAlbumInfo->SetAlbum(albumInfo.GetAlbum(), strPath);
      pDlgAlbumInfo->DoModal();

      if (pDlgAlbumInfo->NeedRefresh())
      {
        m_musicdatabase.DeleteAlbumInfo(params.GetAlbumId());
        continue;
      }
      else if (pDlgAlbumInfo->HasUpdatedThumb())
      {
        UpdateThumb(albumInfo.GetAlbum(), 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);
  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();
}
Exemple #11
0
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();
}
Exemple #12
0
  // 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;
  }
Exemple #13
0
  // Refresh 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();
    CArtist& m_artist = dialog->GetArtist();
    CAlbum& m_album = dialog->GetAlbum();

    CGUIDialogProgress* dlgProgress = GetProgressDialog();
    CMusicDatabase database;
    database.Open();
    if (tag.GetType() == MediaTypeArtist)
    {
      ADDON::ScraperPtr scraper;
      if (!database.GetScraper(m_artist.idArtist, CONTENT_ARTISTS, scraper))
        return false;

      if (dlgProgress->IsCanceled())
        return false;
      database.ClearArtistLastScrapedTime(m_artist.idArtist);

      if (dlgProgress->IsCanceled())
        return false;
      CMusicInfoScanner scanner;
      if (scanner.UpdateArtistInfo(m_artist, scraper, true, dlgProgress) != CInfoScanner::INFO_ADDED)
        return false;
      else
        // Tell info dialog, so can show message
        dialog->SetScrapedInfo(true);

      if (dlgProgress->IsCanceled())
        return false;
      //That changed DB and m_artist, now update dialog item with new info and art
      tag.SetArtist(m_artist);
      CMusicDatabase::SetPropertiesFromArtist(*m_item, m_artist);

      // 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
      ADDON::ScraperPtr scraper;
      if (!database.GetScraper(m_album.idAlbum, CONTENT_ALBUMS, scraper))
        return false;

      if (dlgProgress->IsCanceled())
        return false;
      database.ClearAlbumLastScrapedTime(m_album.idAlbum);

      if (dlgProgress->IsCanceled())
        return false;
      CMusicInfoScanner scanner;
      if (scanner.UpdateAlbumInfo(m_album, scraper, true, GetProgressDialog()) != CInfoScanner::INFO_ADDED)
        return false;
      else
        // Tell info dialog, so can show message
        dialog->SetScrapedInfo(true);

      if (dlgProgress->IsCanceled())
        return false;
      //That changed DB and m_album, now update dialog item with new info and art
      // Album songs are unchanged by refresh (even with Musicbrainz sync?)
      tag.SetAlbum(m_album);
      CMusicDatabase::SetPropertiesFromAlbum(*m_item, m_album);

      // Set the list of songs and related art
      dialog->SetSongs(m_album.songs);
    }
    database.Close();

    if (dlgProgress->IsCanceled())
      return false;
    /*
    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());

    if (dlgProgress->IsCanceled())
      return false;
    // 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
    MarkFinished();
    return true;
  }