mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 22:56:42 +02:00
* Pipeline now runs WebResultHintChecker to validate http urls before accepting them as playable results.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "resolvers/QtScriptResolver.h"
|
#include "resolvers/QtScriptResolver.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
|
#include "utils/WebResultHintChecker.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include "boost/bind.hpp"
|
#include "boost/bind.hpp"
|
||||||
@@ -277,7 +277,6 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
|
|||||||
{
|
{
|
||||||
if ( !m_running )
|
if ( !m_running )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( !m_qids.contains( qid ) )
|
if ( !m_qids.contains( qid ) )
|
||||||
{
|
{
|
||||||
tDebug() << "Result arrived too late for:" << qid;
|
tDebug() << "Result arrived too late for:" << qid;
|
||||||
@@ -290,14 +289,43 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QList< result_ptr > cleanResults;
|
QList< result_ptr > cleanResults;
|
||||||
|
QList< result_ptr > httpResults;
|
||||||
foreach ( const result_ptr& r, results )
|
foreach ( const result_ptr& r, results )
|
||||||
{
|
{
|
||||||
if ( r.isNull() )
|
if ( r.isNull() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float score = q->howSimilar( r );
|
if ( r->url().startsWith( "http" ) && !r->url().startsWith( "http://localhost" ) )
|
||||||
|
httpResults << r;
|
||||||
|
else
|
||||||
|
cleanResults << r;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebResultHintChecker* checker = new WebResultHintChecker( q, httpResults );
|
||||||
|
connect( checker, SIGNAL( done() ), SLOT( onWebResultCheckerDone() ) );
|
||||||
|
|
||||||
|
addResultsToQuery( q, cleanResults );
|
||||||
|
if ( q->solved() && !q->isFullTextQuery() )
|
||||||
|
{
|
||||||
|
setQIDState( q, 0 );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( httpResults.isEmpty() )
|
||||||
|
decQIDState( q );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Pipeline::addResultsToQuery( const query_ptr& query, const QList< result_ptr >& results )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << query->toString() << results.count();
|
||||||
|
QList< result_ptr > cleanResults;
|
||||||
|
foreach ( const result_ptr& r, results )
|
||||||
|
{
|
||||||
|
float score = query->howSimilar( r );
|
||||||
r->setScore( score );
|
r->setScore( score );
|
||||||
if ( !q->isFullTextQuery() && score < MINSCORE )
|
if ( !query->isFullTextQuery() && score < MINSCORE )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
cleanResults << r;
|
cleanResults << r;
|
||||||
@@ -305,22 +333,36 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
|
|||||||
|
|
||||||
if ( !cleanResults.isEmpty() )
|
if ( !cleanResults.isEmpty() )
|
||||||
{
|
{
|
||||||
q->addResults( cleanResults );
|
query->addResults( cleanResults );
|
||||||
|
|
||||||
if ( m_queries_temporary.contains( q ) )
|
if ( m_queries_temporary.contains( query ) )
|
||||||
{
|
{
|
||||||
foreach ( const result_ptr& r, cleanResults )
|
foreach ( const result_ptr& r, cleanResults )
|
||||||
{
|
{
|
||||||
m_rids.insert( r->id(), r );
|
m_rids.insert( r->id(), r );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( q->solved() && !q->isFullTextQuery() )
|
|
||||||
|
void
|
||||||
|
Pipeline::onWebResultCheckerDone()
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
|
WebResultHintChecker* checker = qobject_cast< WebResultHintChecker* >( sender() );
|
||||||
|
if ( !checker )
|
||||||
|
return;
|
||||||
|
|
||||||
|
checker->deleteLater();
|
||||||
|
|
||||||
|
const query_ptr q = checker->query();
|
||||||
|
addResultsToQuery( q, checker->validResults() );
|
||||||
|
if ( q && !q->isFullTextQuery() )
|
||||||
{
|
{
|
||||||
setQIDState( q, 0 );
|
setQIDState( q, 0 );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
decQIDState( q );
|
decQIDState( q );
|
||||||
}
|
}
|
||||||
|
@@ -94,8 +94,10 @@ private slots:
|
|||||||
void shuntNext();
|
void shuntNext();
|
||||||
|
|
||||||
void onTemporaryQueryTimer();
|
void onTemporaryQueryTimer();
|
||||||
|
void onWebResultCheckerDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void addResultsToQuery( const query_ptr& query, const QList< result_ptr >& results );
|
||||||
Tomahawk::Resolver* nextResolver( const Tomahawk::query_ptr& query ) const;
|
Tomahawk::Resolver* nextResolver( const Tomahawk::query_ptr& query ) const;
|
||||||
|
|
||||||
void setQIDState( const Tomahawk::query_ptr& query, int state );
|
void setQIDState( const Tomahawk::query_ptr& query, int state );
|
||||||
|
Reference in New Issue
Block a user