diff runner/FeatureExtractionManager.cpp @ 47:91d20795a109

* Make --force work correctly for playlists
author Chris Cannam
date Wed, 02 Mar 2011 15:27:21 +0000
parents 4d07f61dba3f
children c30b9720bde0
line wrap: on
line diff
--- a/runner/FeatureExtractionManager.cpp	Mon Oct 18 14:19:11 2010 +0100
+++ b/runner/FeatureExtractionManager.cpp	Wed Mar 02 15:27:21 2011 +0000
@@ -457,10 +457,37 @@
     }
 }
 
-void FeatureExtractionManager::extractFeatures(QString audioSource)
+void FeatureExtractionManager::extractFeatures(QString audioSource, bool force)
 {
     if (m_plugins.empty()) return;
 
+    if (QFileInfo(audioSource).suffix().toLower() == "m3u") {
+        FileSource source(audioSource);
+        PlaylistFileReader reader(source);
+        if (reader.isOK()) {
+            vector<QString> files = reader.load();
+            for (int i = 0; i < (int)files.size(); ++i) {
+                try {
+                    extractFeatures(files[i], force);
+                } catch (const std::exception &e) {
+                    if (!force) throw;
+                    cerr << "ERROR: Feature extraction failed for playlist entry \""
+                         << files[i].toStdString()
+                         << "\": " << e.what() << endl;
+                    // print a note only if we have more files to process
+                    if (++i != files.size()) {
+                        cerr << "NOTE: \"--force\" option was provided, continuing (more errors may occur)" << endl;
+                    }
+                }
+            }
+            return;
+        } else {
+            cerr << "ERROR: Playlist \"" << audioSource.toStdString()
+                 << "\" could not be opened" << endl;
+            throw FileNotFound(audioSource);
+        }
+    }
+
     testOutputFiles(audioSource);
 
     if (m_sampleRate == 0) {