Blame SOURCES/0005-Fix-flac-analizer-was-importing-only-one-artist-tag.patch

ee4fba
From f1c837823b6dde8464f46ccb02a2c91eff69bee0 Mon Sep 17 00:00:00 2001
ee4fba
From: Ignacio Serantes <kde@aynoa.net>
ee4fba
Date: Thu, 14 Jun 2012 20:15:10 +0200
ee4fba
Subject: [PATCH 5/8] Fix: flac analizer was importing only one artist tag.
ee4fba
 REVIEW:105208
ee4fba
ee4fba
---
ee4fba
 lib/endanalyzers/flacendanalyzer.cpp |   37 +++++++++++++++++++++-------------
ee4fba
 1 file changed, 23 insertions(+), 14 deletions(-)
ee4fba
ee4fba
diff --git a/lib/endanalyzers/flacendanalyzer.cpp b/lib/endanalyzers/flacendanalyzer.cpp
ee4fba
index 7e34270..0a7d680 100644
ee4fba
--- a/lib/endanalyzers/flacendanalyzer.cpp
ee4fba
+++ b/lib/endanalyzers/flacendanalyzer.cpp
ee4fba
@@ -30,6 +30,7 @@
ee4fba
 #include <iostream>
ee4fba
 #include <cctype>
ee4fba
 #include <cstring>
ee4fba
+#include <list>
ee4fba
 using namespace Strigi;
ee4fba
 using namespace std;
ee4fba
 
ee4fba
@@ -212,7 +213,7 @@ FlacEndAnalyzer::analyze(Strigi::AnalysisResult& indexable, Strigi::InputStream*
ee4fba
         // in Vorbis comments the "artist" field is used for the performer in modern music
ee4fba
         // but for the composer in calssical music. Thus, we cache both and make the decision
ee4fba
         // at the end
ee4fba
-        string artist, performer;
ee4fba
+	list<string> artists, performers;
ee4fba
 
ee4fba
 	// read all the comments
ee4fba
 	p2 += 4;
ee4fba
@@ -252,7 +253,7 @@ FlacEndAnalyzer::analyze(Strigi::AnalysisResult& indexable, Strigi::InputStream*
ee4fba
                     indexable.addValue(iter->second, value);
ee4fba
                 }
ee4fba
 		    } else if(name=="artist") {
ee4fba
-                        artist = value;
ee4fba
+                        artists.push_back(value);
ee4fba
 		    } else if(name=="lyrics") {
ee4fba
                         indexable.addText(value.c_str(),
ee4fba
                                           (int32_t)value.length());
ee4fba
@@ -285,7 +286,7 @@ FlacEndAnalyzer::analyze(Strigi::AnalysisResult& indexable, Strigi::InputStream*
ee4fba
 			indexable.addTriplet(publisherUri, typePropertyName, contactClassName);
ee4fba
 			indexable.addTriplet(publisherUri, fullnamePropertyName, value);
ee4fba
 		    } else if(name=="performer") {
ee4fba
-                        performer = value;
ee4fba
+                        performers.push_back(value);
ee4fba
                     }
ee4fba
 		}
ee4fba
 	    } else {
ee4fba
@@ -298,8 +299,8 @@ FlacEndAnalyzer::analyze(Strigi::AnalysisResult& indexable, Strigi::InputStream*
ee4fba
         // we now decide how to store the artist and performer as suggested by the Vorbis comments spec
ee4fba
         const Strigi::RegisteredField* artistField = 0;
ee4fba
         const Strigi::RegisteredField* performerField = 0;
ee4fba
-        if (!artist.empty()) {
ee4fba
-            if (!performer.empty()) {
ee4fba
+        if (!artists.empty()) {
ee4fba
+            if (!performers.empty()) {
ee4fba
                 artistField = factory->composerField;
ee4fba
                 performerField = factory->performerField;
ee4fba
             }
ee4fba
@@ -307,22 +308,30 @@ FlacEndAnalyzer::analyze(Strigi::AnalysisResult& indexable, Strigi::InputStream*
ee4fba
                 artistField = factory->performerField;
ee4fba
             }
ee4fba
         }
ee4fba
-        else if (!performer.empty()) {
ee4fba
+        else if (!performers.empty()) {
ee4fba
             performerField = factory->performerField;
ee4fba
         }
ee4fba
         if (artistField) {
ee4fba
-            const string artistUri( indexable.newAnonymousUri() );
ee4fba
+	    list<string>::iterator aIt;
ee4fba
 
ee4fba
-            indexable.addValue(artistField, artistUri);
ee4fba
-            indexable.addTriplet(artistUri, typePropertyName, contactClassName);
ee4fba
-            indexable.addTriplet(artistUri, fullnamePropertyName, artist);
ee4fba
+            for(aIt=artists.begin(); aIt != artists.end(); ++aIt) {
ee4fba
+                const string artistUri( indexable.newAnonymousUri() );
ee4fba
+
ee4fba
+                indexable.addValue(artistField, artistUri);
ee4fba
+                indexable.addTriplet(artistUri, typePropertyName, contactClassName);
ee4fba
+                indexable.addTriplet(artistUri, fullnamePropertyName, *aIt);
ee4fba
+            }
ee4fba
         }
ee4fba
         if (performerField) {
ee4fba
-            const string performerUri( indexable.newAnonymousUri() );
ee4fba
+            list<string>::iterator pIt;
ee4fba
 
ee4fba
-            indexable.addValue(performerField, performerUri);
ee4fba
-            indexable.addTriplet(performerUri, typePropertyName, contactClassName);
ee4fba
-            indexable.addTriplet(performerUri, fullnamePropertyName, performer);
ee4fba
+            for(pIt=performers.begin(); pIt != performers.end(); ++pIt) {
ee4fba
+                const string performerUri( indexable.newAnonymousUri() );
ee4fba
+
ee4fba
+                indexable.addValue(performerField, performerUri);
ee4fba
+                indexable.addTriplet(performerUri, typePropertyName, contactClassName);
ee4fba
+                indexable.addTriplet(performerUri, fullnamePropertyName, *pIt);
ee4fba
+            }
ee4fba
         }
ee4fba
 
ee4fba
 	if(!albumUri.empty()) {
ee4fba
-- 
ee4fba
1.7.10.4
ee4fba