comparison 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
comparison
equal deleted inserted replaced
46:4d07f61dba3f 47:91d20795a109
455 455
456 m_readyReaders[audioSource] = reader; 456 m_readyReaders[audioSource] = reader;
457 } 457 }
458 } 458 }
459 459
460 void FeatureExtractionManager::extractFeatures(QString audioSource) 460 void FeatureExtractionManager::extractFeatures(QString audioSource, bool force)
461 { 461 {
462 if (m_plugins.empty()) return; 462 if (m_plugins.empty()) return;
463
464 if (QFileInfo(audioSource).suffix().toLower() == "m3u") {
465 FileSource source(audioSource);
466 PlaylistFileReader reader(source);
467 if (reader.isOK()) {
468 vector<QString> files = reader.load();
469 for (int i = 0; i < (int)files.size(); ++i) {
470 try {
471 extractFeatures(files[i], force);
472 } catch (const std::exception &e) {
473 if (!force) throw;
474 cerr << "ERROR: Feature extraction failed for playlist entry \""
475 << files[i].toStdString()
476 << "\": " << e.what() << endl;
477 // print a note only if we have more files to process
478 if (++i != files.size()) {
479 cerr << "NOTE: \"--force\" option was provided, continuing (more errors may occur)" << endl;
480 }
481 }
482 }
483 return;
484 } else {
485 cerr << "ERROR: Playlist \"" << audioSource.toStdString()
486 << "\" could not be opened" << endl;
487 throw FileNotFound(audioSource);
488 }
489 }
463 490
464 testOutputFiles(audioSource); 491 testOutputFiles(audioSource);
465 492
466 if (m_sampleRate == 0) { 493 if (m_sampleRate == 0) {
467 throw FileOperationFailed 494 throw FileOperationFailed