Skip to content
This repository
Browse code

Merge pull request #2906 from arnova/music_db_fixes

Music info/db (regression) fixes
  • Loading branch information...
commit ec3589ef31952355113d514342e5ae399a3a7243 2 parents bc7b563 + 4026ea3
arnova authored June 26, 2013
2  xbmc/music/Album.cpp
@@ -50,7 +50,7 @@ CStdString CAlbum::GetArtistString() const
50 50
 
51 51
 CStdString CAlbum::GetGenreString() const
52 52
 {
53  
-  return StringUtils::Join(artist, g_advancedSettings.m_musicItemSeparator);
  53
+  return StringUtils::Join(genre, g_advancedSettings.m_musicItemSeparator);
54 54
 }
55 55
 
56 56
 bool CAlbum::operator<(const CAlbum &a) const
18  xbmc/music/MusicDatabase.cpp
@@ -440,13 +440,13 @@ int CMusicDatabase::AddSong(const int idAlbum,
440 440
   return idSong;
441 441
 }
442 442
 
443  
-  int CMusicDatabase::UpdateSong(int idSong,
444  
-                                 const CStdString& strTitle, const CStdString& strMusicBrainzTrackID,
445  
-                                 const CStdString& strPathAndFileName, const CStdString& strComment, const CStdString& strThumb,
446  
-                                 const std::vector<std::string>& artists, const std::vector<std::string>& genres,
447  
-                                 int iTrack, int iDuration, int iYear,
448  
-                                 int iTimesPlayed, int iStartOffset, int iEndOffset,
449  
-                                 const CDateTime& dtLastPlayed, char rating, int iKaraokeNumber)
  443
+int CMusicDatabase::UpdateSong(int idSong,
  444
+                               const CStdString& strTitle, const CStdString& strMusicBrainzTrackID,
  445
+                               const CStdString& strPathAndFileName, const CStdString& strComment, const CStdString& strThumb,
  446
+                               const std::vector<std::string>& artists, const std::vector<std::string>& genres,
  447
+                               int iTrack, int iDuration, int iYear,
  448
+                               int iTimesPlayed, int iStartOffset, int iEndOffset,
  449
+                               const CDateTime& dtLastPlayed, char rating, int iKaraokeNumber)
450 450
 {
451 451
   CStdString sql;
452 452
   if (idSong < 0)
@@ -3902,9 +3902,9 @@ bool CMusicDatabase::SaveAlbumThumb(int idAlbum, const CStdString& strThumb)
3902 3902
   SetArtForItem(idAlbum, "album", "thumb", strThumb);
3903 3903
   // TODO: We should prompt the user to update the art for songs
3904 3904
   CStdString sql = PrepareSQL("UPDATE art"
3905  
-                              " SET art_url='-'"
  3905
+                              " SET url='-'"
3906 3906
                               " WHERE media_type='song'"
3907  
-                              " AND art_type='thumb'"
  3907
+                              " AND type='thumb'"
3908 3908
                               " AND media_id IN"
3909 3909
                               " (SELECT idSong FROM song WHERE idAlbum=%ld)", idAlbum);
3910 3910
   ExecuteQuery(sql);
25  xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -618,7 +618,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
618 618
       // No - download the information
619 619
       CMusicAlbumInfo albumInfo;
620 620
       INFO_RET albumDownloadStatus = INFO_NOT_FOUND;
621  
-      if (m_flags & SCAN_ONLINE)
  621
+      if ((m_flags & SCAN_ONLINE) && albumScraper)
622 622
         albumDownloadStatus = DownloadAlbumInfo(*album, albumScraper, albumInfo);
623 623
 
624 624
       if (albumDownloadStatus == INFO_ADDED || albumDownloadStatus == INFO_HAVE_ALREADY)
@@ -640,14 +640,18 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
640 640
       }
641 641
       else if (albumDownloadStatus == INFO_CANCELLED)
642 642
         break;
643  
-      else // Cache the lookup failure so we don't retry
  643
+      else
644 644
       {
  645
+        // No download info, fallback to already gathered (eg. local) information/art (if any)
645 646
         album->idAlbum = m_musicDatabase.AddAlbum(album->strAlbum,
646 647
                                                   album->strMusicBrainzAlbumID,
647 648
                                                   album->GetArtistString(),
648 649
                                                   album->GetGenreString(),
649 650
                                                   album->iYear,
650 651
                                                   album->bCompilation);
  652
+        if (!album->art.empty())
  653
+          m_musicDatabase.SetArtForItem(album->idAlbum,
  654
+                                        "album", album->art);
651 655
         m_albumCache.insert(make_pair(*album, *album));
652 656
       }
653 657
 
@@ -676,7 +680,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
676 680
         // No - download the information
677 681
         CMusicArtistInfo artistInfo;
678 682
         INFO_RET artistDownloadStatus = INFO_NOT_FOUND;
679  
-        if (m_flags & SCAN_ONLINE)
  683
+        if ((m_flags & SCAN_ONLINE) && artistScraper)
680 684
           artistDownloadStatus = DownloadArtistInfo(artistTmp, artistScraper, artistInfo);
681 685
 
682 686
         if (artistDownloadStatus == INFO_ADDED || artistDownloadStatus == INFO_HAVE_ALREADY)
@@ -747,7 +751,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
747 751
           // No - download the information
748 752
           CMusicArtistInfo artistInfo;
749 753
           INFO_RET artistDownloadStatus = INFO_NOT_FOUND;
750  
-          if (m_flags & SCAN_ONLINE)
  754
+          if ((m_flags & SCAN_ONLINE) && artistScraper)
751 755
             artistDownloadStatus = DownloadArtistInfo(artistTmp, artistScraper, artistInfo);
752 756
 
753 757
           if (artistDownloadStatus == INFO_ADDED || artistDownloadStatus == INFO_HAVE_ALREADY)
@@ -1009,8 +1013,10 @@ void CMusicInfoScanner::FindArtForAlbums(VECALBUMS &albums, const CStdString &pa
1009 1013
     }
1010 1014
   }
1011 1015
   if (albums.size() == 1 && !albumArt.empty())
1012  
-  { // assign to folder thumb as well
1013  
-    CMusicThumbLoader::SetCachedImage(path, "thumb", albumArt);
  1016
+  {
  1017
+    // assign to folder thumb as well
  1018
+    CFileItem albumItem(path, true);
  1019
+    CMusicThumbLoader::SetCachedImage(albumItem, "thumb", albumArt);
1014 1020
   }
1015 1021
 }
1016 1022
 
@@ -1048,10 +1054,13 @@ INFO_RET CMusicInfoScanner::UpdateDatabaseAlbumInfo(const CStdString& strPath, C
1048 1054
 
1049 1055
   // find album info
1050 1056
   ADDON::ScraperPtr scraper;
1051  
-  if (!m_musicDatabase.GetScraperForPath(strPath, scraper, ADDON::ADDON_SCRAPER_ALBUMS) || !scraper)
1052  
-    return INFO_ERROR;
  1057
+  bool result = m_musicDatabase.GetScraperForPath(strPath, scraper, ADDON::ADDON_SCRAPER_ALBUMS);
  1058
+
1053 1059
   m_musicDatabase.Close();
1054 1060
 
  1061
+  if (!result || !scraper)
  1062
+    return INFO_ERROR;
  1063
+
1055 1064
 loop:
1056 1065
   CLog::Log(LOGDEBUG, "%s downloading info for: %s", __FUNCTION__, album.strAlbum.c_str());
1057 1066
   INFO_RET albumDownloadStatus = DownloadAlbumInfo(album, scraper, albumInfo, pDialog);
26  xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -339,7 +339,7 @@ void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo)
339 339
     }
340 340
   }
341 341
 
342  
-  // check the first song we find in the folder, and grab it's album info
  342
+  // check the first song we find in the folder, and grab its album info
343 343
   for (int i = 0; i < items.Size(); i++)
344 344
   {
345 345
     CFileItemPtr pItem = items[i];
@@ -347,9 +347,13 @@ void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo)
347 347
     if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded() &&
348 348
        !pItem->GetMusicInfoTag()->GetAlbum().IsEmpty())
349 349
     {
350  
-      ShowAlbumInfo(pItem.get());
  350
+      bool result = ShowAlbumInfo(pItem.get());
  351
+
351 352
       if (m_dlgProgress && bShowInfo)
352 353
         m_dlgProgress->Close();
  354
+
  355
+      if (!result) // Something went wrong, so bail for the rest
  356
+        break;
353 357
     }
354 358
   }
355 359
 
@@ -420,7 +424,7 @@ void CGUIWindowMusicBase::ShowArtistInfo(const CFileItem *pItem, bool bShowInfo
420 424
     m_dlgProgress->Close();
421 425
 }
422 426
 
423  
-void CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /* = true */)
  427
+bool CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /* = true */)
424 428
 {
425 429
   CQueryParams params;
426 430
   CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params);
@@ -431,12 +435,19 @@ void CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /
431 435
         !m_musicdatabase.GetAlbumInfo(params.GetAlbumId(), albumInfo.GetAlbum(), &albumInfo.GetAlbum().songs))
432 436
     {
433 437
       if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
434  
-        break; // should display a dialog saying no permissions
  438
+      {
  439
+        // TODO: should display a dialog saying no permissions
  440
+        if (m_dlgProgress)
  441
+          m_dlgProgress->Close();
  442
+        return false;
  443
+      }
435 444
 
436 445
       if (g_application.IsMusicScanning())
437 446
       {
438 447
         CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
439  
-        break;
  448
+        if (m_dlgProgress)
  449
+          m_dlgProgress->Close();
  450
+        return false;
440 451
       }
441 452
 
442 453
       // show dialog box indicating we're searching the album
@@ -453,7 +464,9 @@ void CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /
453 464
       if (scanner.UpdateDatabaseAlbumInfo(pItem->GetPath(), albumInfo, bShowInfo) != INFO_ADDED || !albumInfo.Loaded())
454 465
       {
455 466
         CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0);
456  
-        break;
  467
+        if (m_dlgProgress)
  468
+          m_dlgProgress->Close();
  469
+        return false;
457 470
       }
458 471
     }
459 472
 
@@ -479,6 +492,7 @@ void CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /
479 492
   }
480 493
   if (m_dlgProgress)
481 494
     m_dlgProgress->Close();
  495
+  return true;
482 496
 }
483 497
 
484 498
 void CGUIWindowMusicBase::ShowSongInfo(CFileItem* pItem)
2  xbmc/music/windows/GUIWindowMusicBase.h
@@ -88,7 +88,7 @@ class CGUIWindowMusicBase : public CGUIMediaWindow
88 88
   bool FindAlbumInfo(const CFileItem* album, MUSIC_GRABBER::CMusicAlbumInfo& albumInfo, ALLOW_SELECTION allowSelection);
89 89
   bool FindArtistInfo(const CFileItem* artist, MUSIC_GRABBER::CMusicArtistInfo& artistInfo, ALLOW_SELECTION allowSelection);
90 90
 
91  
-  void ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo = true);
  91
+  bool ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo = true);
92 92
   void ShowArtistInfo(const CFileItem *pItem, bool bShowInfo = true);
93 93
   void ShowSongInfo(CFileItem* pItem);
94 94
   void UpdateThumb(const CAlbum &album, const CStdString &path);

0 notes on commit ec3589e

Please sign in to comment.
Something went wrong with that request. Please try again.