Skip to content
This repository
Browse code

[musicdb] cosmetic: shuffle some code to a place where it makes more …

…sense
  • Loading branch information...
commit 8983723256893dd43568451d72628713d3d07880 1 parent 5704b96
night199uk authored April 09, 2013

Showing 1 changed file with 32 additions and 37 deletions. Show diff stats Hide diff stats

  1. 69  xbmc/music/infoscanner/MusicInfoScanner.cpp
69  xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -996,14 +996,13 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
996 996
     }
997 997
   }
998 998
 
999  
-  CGUIDialogSelect *pDlg=NULL;
  999
+  CGUIDialogSelect *pDlg = NULL;
1000 1000
   int iSelectedAlbum=0;
1001 1001
   if (result == CNfoFile::NO_NFO)
1002 1002
   {
1003 1003
     iSelectedAlbum = -1; // set negative so that we can detect a failure
1004 1004
     if (scraper.Succeeded() && scraper.GetAlbumCount() >= 1)
1005 1005
     {
1006  
-      int bestMatch = -1;
1007 1006
       double bestRelevance = 0;
1008 1007
       double minRelevance = THRESHOLD;
1009 1008
       if (scraper.GetAlbumCount() > 1) // score the matches
@@ -1029,7 +1028,7 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
1029 1028
           if (relevance >= max(minRelevance, bestRelevance))
1030 1029
           { // we auto-select the best of these
1031 1030
             bestRelevance = relevance;
1032  
-            bestMatch = i;
  1031
+            iSelectedAlbum = i;
1033 1032
           }
1034 1033
           if (pDialog)
1035 1034
           {
@@ -1043,6 +1042,35 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
1043 1042
           if (relevance > .99f) // we're so close, no reason to search further
1044 1043
             break;
1045 1044
         }
  1045
+
  1046
+        if (pDialog && bestRelevance < THRESHOLD)
  1047
+        {
  1048
+          pDlg->Sort(false);
  1049
+          pDlg->DoModal();
  1050
+
  1051
+          // and wait till user selects one
  1052
+          if (pDlg->GetSelectedLabel() < 0)
  1053
+          { // none chosen
  1054
+            if (!pDlg->IsButtonPressed())
  1055
+              return false;
  1056
+
  1057
+            // manual button pressed
  1058
+            CStdString strNewAlbum = album.strAlbum;
  1059
+            if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return false;
  1060
+            if (strNewAlbum == "") return false;
  1061
+
  1062
+            CStdString strNewArtist = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator);
  1063
+            if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false;
  1064
+
  1065
+            pDialog->SetLine(0, strNewAlbum);
  1066
+            pDialog->SetLine(1, strNewArtist);
  1067
+            pDialog->Progress();
  1068
+
  1069
+            m_musicDatabase.Close();
  1070
+            return DownloadAlbumInfo(strPath,strNewArtist,strNewAlbum,bCanceled,albumInfo,pDialog);
  1071
+          }
  1072
+          iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth;
  1073
+        }
1046 1074
       }
1047 1075
       else
1048 1076
       {
@@ -1055,40 +1083,7 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
1055 1083
           m_musicDatabase.Close();
1056 1084
           return false;
1057 1085
         }
1058  
-        bestRelevance = relevance;
1059  
-        bestMatch = 0;
1060  
-      }
1061  
-
1062  
-      iSelectedAlbum = bestMatch;
1063  
-      if (pDialog && bestRelevance < THRESHOLD)
1064  
-      {
1065  
-        pDlg->Sort(false);
1066  
-        pDlg->DoModal();
1067  
-
1068  
-        // and wait till user selects one
1069  
-        if (pDlg->GetSelectedLabel() < 0)
1070  
-        { // none chosen
1071  
-          if (!pDlg->IsButtonPressed())
1072  
-          {
1073  
-            bCanceled = true;
1074  
-            return false;
1075  
-          }
1076  
-          // manual button pressed
1077  
-          CStdString strNewAlbum = strAlbum;
1078  
-          if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return false;
1079  
-          if (strNewAlbum == "") return false;
1080  
-
1081  
-          CStdString strNewArtist = strArtist;
1082  
-          if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false;
1083  
-
1084  
-          pDialog->SetLine(0, strNewAlbum);
1085  
-          pDialog->SetLine(1, strNewArtist);
1086  
-          pDialog->Progress();
1087  
-
1088  
-          m_musicDatabase.Close();
1089  
-          return DownloadAlbumInfo(strPath,strNewArtist,strNewAlbum,bCanceled,albumInfo,pDialog);
1090  
-        }
1091  
-        iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth;
  1086
+        iSelectedAlbum = 0;
1092 1087
       }
1093 1088
     }
1094 1089
 

0 notes on commit 8983723

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