comparison runner/main.cpp @ 112:0c2d8c945bbf multiplex

Merge from default branch
author Chris Cannam
date Thu, 02 Oct 2014 15:23:25 +0100
parents de76b2df518f 74f7ad72fee6
children 1c0799754670
comparison
equal deleted inserted replaced
110:ca565b18ba3e 112:0c2d8c945bbf
33 33
34 #include "../version.h" 34 #include "../version.h"
35 35
36 #include "base/Exceptions.h" 36 #include "base/Exceptions.h"
37 #include "base/TempDirectory.h" 37 #include "base/TempDirectory.h"
38 #include "base/ProgressPrinter.h"
38 39
39 #include "data/fileio/AudioFileReaderFactory.h" 40 #include "data/fileio/AudioFileReaderFactory.h"
40 #include "data/fileio/PlaylistFileReader.h" 41 #include "data/fileio/PlaylistFileReader.h"
41 42
42 #include "transform/Transform.h" 43 #include "transform/Transform.h"
344 for (int i = 0; i < subdirs.size(); ++i) { 345 for (int i = 0; i < subdirs.size(); ++i) {
345 findSourcesRecursive(dir.filePath(subdirs[i]), addTo, found); 346 findSourcesRecursive(dir.filePath(subdirs[i]), addTo, found);
346 } 347 }
347 } 348 }
348 349
350 QStringList
351 expandPlaylists(QStringList sources)
352 {
353 QStringList expanded;
354 foreach (QString path, sources) {
355 cerr << "expandPlaylists: looking at " << path << endl;
356 if (QFileInfo(path).suffix().toLower() == "m3u") {
357 ProgressPrinter retrievalProgress("Opening playlist file...");
358 FileSource source(path, &retrievalProgress);
359 if (!source.isAvailable()) {
360 cerr << "ERROR: File or URL \"" << path.toStdString()
361 << "\" could not be located" << endl;
362 throw FileNotFound(path);
363 }
364 source.waitForData();
365 PlaylistFileReader reader(source);
366 if (reader.isOK()) {
367 vector<QString> files = reader.load();
368 for (int i = 0; i < (int)files.size(); ++i) {
369 expanded.push_back(files[i]);
370 }
371 }
372 } else {
373 // not a playlist
374 expanded.push_back(path);
375 }
376 }
377 return expanded;
378 }
349 379
350 int main(int argc, char **argv) 380 int main(int argc, char **argv)
351 { 381 {
352 QCoreApplication application(argc, argv); 382 QCoreApplication application(argc, argv);
353 383
687 sources.push_back(*i); 717 sources.push_back(*i);
688 } 718 }
689 } 719 }
690 } 720 }
691 721
722 sources = expandPlaylists(sources);
723
692 bool good = true; 724 bool good = true;
693 QSet<QString> badSources; 725 QSet<QString> badSources;
694 726
695 for (QStringList::const_iterator i = sources.begin(); 727 for (QStringList::const_iterator i = sources.begin();
696 i != sources.end(); ++i) { 728 i != sources.end(); ++i) {
757 for (QStringList::const_iterator i = goodSources.begin(); 789 for (QStringList::const_iterator i = goodSources.begin();
758 i != goodSources.end(); ++i) { 790 i != goodSources.end(); ++i) {
759 std::cerr << "Extracting features for: \"" << i->toStdString() 791 std::cerr << "Extracting features for: \"" << i->toStdString()
760 << "\"" << std::endl; 792 << "\"" << std::endl;
761 try { 793 try {
762 manager.extractFeatures(*i, force); 794 manager.extractFeatures(*i);
763 } catch (const std::exception &e) { 795 } catch (const std::exception &e) {
764 cerr << "ERROR: Feature extraction failed for \"" 796 cerr << "ERROR: Feature extraction failed for \""
765 << i->toStdString() << "\": " << e.what() << endl; 797 << i->toStdString() << "\": " << e.what() << endl;
766 if (force) { 798 if (force) {
767 // print a note only if we have more files to process 799 // print a note only if we have more files to process