Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…more sense
  • Loading branch information...
commit d2f6df100e11cde510ec6133e248244f999549b2 1 parent 7ede3d5
night199uk authored July 24, 2012

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
@@ -972,14 +972,13 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
972 972
     }
973 973
   }
974 974
 
975  
-  CGUIDialogSelect *pDlg=NULL;
  975
+  CGUIDialogSelect *pDlg = NULL;
976 976
   int iSelectedAlbum=0;
977 977
   if (result == CNfoFile::NO_NFO)
978 978
   {
979 979
     iSelectedAlbum = -1; // set negative so that we can detect a failure
980 980
     if (scraper.Succeeded() && scraper.GetAlbumCount() >= 1)
981 981
     {
982  
-      int bestMatch = -1;
983 982
       double bestRelevance = 0;
984 983
       double minRelevance = THRESHOLD;
985 984
       if (scraper.GetAlbumCount() > 1) // score the matches
@@ -1005,7 +1004,7 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
1005 1004
           if (relevance >= max(minRelevance, bestRelevance))
1006 1005
           { // we auto-select the best of these
1007 1006
             bestRelevance = relevance;
1008  
-            bestMatch = i;
  1007
+            iSelectedAlbum = i;
1009 1008
           }
1010 1009
           if (pDialog)
1011 1010
           {
@@ -1019,6 +1018,35 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
1019 1018
           if (relevance > .99f) // we're so close, no reason to search further
1020 1019
             break;
1021 1020
         }
  1021
+
  1022
+        if (pDialog && bestRelevance < THRESHOLD)
  1023
+        {
  1024
+          pDlg->Sort(false);
  1025
+          pDlg->DoModal();
  1026
+
  1027
+          // and wait till user selects one
  1028
+          if (pDlg->GetSelectedLabel() < 0)
  1029
+          { // none chosen
  1030
+            if (!pDlg->IsButtonPressed())
  1031
+              return INFO_CANCELLED;
  1032
+
  1033
+            // manual button pressed
  1034
+            CStdString strNewAlbum = album.strAlbum;
  1035
+            if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return false;
  1036
+            if (strNewAlbum == "") return false;
  1037
+
  1038
+            CStdString strNewArtist = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator);
  1039
+            if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false;
  1040
+
  1041
+            pDialog->SetLine(0, strNewAlbum);
  1042
+            pDialog->SetLine(1, strNewArtist);
  1043
+            pDialog->Progress();
  1044
+
  1045
+            m_musicDatabase.Close();
  1046
+            return DownloadAlbumInfo(strPath,strNewArtist,strNewAlbum,bCanceled,albumInfo,pDialog);
  1047
+          }
  1048
+          iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth;
  1049
+        }
1022 1050
       }
1023 1051
       else
1024 1052
       {
@@ -1031,40 +1059,7 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
1031 1059
           m_musicDatabase.Close();
1032 1060
           return false;
1033 1061
         }
1034  
-        bestRelevance = relevance;
1035  
-        bestMatch = 0;
1036  
-      }
1037  
-
1038  
-      iSelectedAlbum = bestMatch;
1039  
-      if (pDialog && bestRelevance < THRESHOLD)
1040  
-      {
1041  
-        pDlg->Sort(false);
1042  
-        pDlg->DoModal();
1043  
-
1044  
-        // and wait till user selects one
1045  
-        if (pDlg->GetSelectedLabel() < 0)
1046  
-        { // none chosen
1047  
-          if (!pDlg->IsButtonPressed())
1048  
-          {
1049  
-            bCanceled = true;
1050  
-            return false;
1051  
-          }
1052  
-          // manual button pressed
1053  
-          CStdString strNewAlbum = strAlbum;
1054  
-          if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return false;
1055  
-          if (strNewAlbum == "") return false;
1056  
-
1057  
-          CStdString strNewArtist = strArtist;
1058  
-          if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false;
1059  
-
1060  
-          pDialog->SetLine(0, strNewAlbum);
1061  
-          pDialog->SetLine(1, strNewArtist);
1062  
-          pDialog->Progress();
1063  
-
1064  
-          m_musicDatabase.Close();
1065  
-          return DownloadAlbumInfo(strPath,strNewArtist,strNewAlbum,bCanceled,albumInfo,pDialog);
1066  
-        }
1067  
-        iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth;
  1062
+        iSelectedAlbum = 0;
1068 1063
       }
1069 1064
     }
1070 1065
 

0 notes on commit d2f6df1

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