Commit 270da229 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Metadata: Remove multiple pass parsing code.

We now fallback to starting a playback early, no need for the old
complicated and full of special case code
parent 84ba019c
......@@ -164,25 +164,8 @@ parser::Task::Status MetadataParser::run( parser::Task& task )
const auto& tracks = task.vlcMedia.tracks();
// If we failed to extract any tracks, don't make any assumption and forward to the
// thumbnailer. Since it starts an actual playback, it will have more information.
// Since the metadata steps won't be marked, it will run again once the thumbnailer has completed.
if ( tracks.empty() == true )
{
// However, if the file is not unknown anymore, it means the thumbnailer has already processed it
if ( task.media->type() == Media::Type::Unknown )
{
// In case the thumbnailer ran before, but the application exited, we would skip the
// thumbnailer execution, coming back here, and delegating again to the thumbnailer
// over and over again. We need to ensure the thumbnailer will run, even partially, up to
// the point the playback started.
task.markStepUncompleted( parser::Task::ParserStep::Thumbnailer );
LOG_INFO( "Skipping metadata parsing for file with unknown type: ", task.file->mrl() );
return parser::Task::Status::Success;
}
// In that case, stop trying to do something with this file.
return parser::Task::Status::Fatal;
}
bool isAudio = true;
{
......
......@@ -117,24 +117,6 @@ parser::Task::Status VLCThumbnailer::run( parser::Task& task )
task.markStepCompleted( parser::Task::ParserStep::Thumbnailer );
task.saveParserStep();
}
else if ( task.media->type() == Media::Type::Unknown )
{
task.media->setType( Media::Type::Audio );
task.media->save();
LOG_INFO( file->mrl(), " type has changed to Audio. Skipping thumbnail generation" );
}
return parser::Task::Status::Success;
}
// Yet another special case:
// We could have run the thumbnailer already as a fallback for some weird video with no
// preparse detected tracks. If so, we don't want to spend more time computing a thumbnail, but
// we do need to run the metadata extraction again.
if ( media->type() == Media::Type::Unknown && media->thumbnail().empty() == false )
{
task.markStepCompleted( parser::Task::ParserStep::Thumbnailer );
// startPlayback will return an error in case the media is an audio file
media->setType( IMedia::Type::Video );
// And now let the metadata extraction run again
return parser::Task::Status::Success;
}
......
......@@ -161,12 +161,7 @@ void Parser::done( std::shared_ptr<parser::Task> t, parser::Task::Status status
}
// If some services declined to parse the file, start over again.
if ( serviceIdx == m_services.size() )
{
t->currentService = serviceIdx = 0;
m_opToDo += m_services.size();
LOG_INFO("Running parser chain again for ", t->mrl);
}
assert( serviceIdx < m_services.size() );
updateStats();
m_services[serviceIdx]->parse( std::move( t ) );
}
......
......@@ -84,12 +84,6 @@ void Task::markStepCompleted( ParserStep stepCompleted )
static_cast<uint8_t>( stepCompleted ) );
}
void Task::markStepUncompleted( ParserStep stepUncompleted )
{
m_step = static_cast<ParserStep>( static_cast<uint8_t>( m_step ) &
( ~ static_cast<uint8_t>( stepUncompleted ) ) );
}
bool Task::saveParserStep()
{
static const std::string req = "UPDATE " + policy::TaskTable::Name + " SET step = ?, "
......
......@@ -110,7 +110,6 @@ public:
* extract the same information again
*/
void markStepCompleted( ParserStep stepCompleted );
void markStepUncompleted( ParserStep stepUncompleted );
bool saveParserStep();
bool isCompleted() const;
bool isStepCompleted( ParserStep step ) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment