mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 23:26:40 +02:00
Twisted header fix, stylefix
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
#include <qjson/parser.h>
|
||||
#include <qjson/serializer.h>
|
||||
|
||||
#define CHART_URL "http://charts.stage.tomahawk-player.org/"
|
||||
#define CHART_URL "http://charts.tomahawk-player.org/"
|
||||
//#define CHART_URL "http://localhost:8080/"
|
||||
|
||||
using namespace Tomahawk::InfoSystem;
|
||||
@@ -327,13 +327,19 @@ NewReleasesPlugin::nrSourcesList()
|
||||
m_nrSources.removeAt( i );
|
||||
}
|
||||
}
|
||||
reply->setProperty( "only_source_list", false );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Expiration
|
||||
* Each item has an expiration, on next request for cache, it will be checked
|
||||
*/
|
||||
const QString headerExpiration = reply->rawHeader( QString( source + "Expires" ).toLocal8Bit() );
|
||||
|
||||
/// Twisted backend Uppers first header letter, and lowers the rest
|
||||
QString tmpSource = source + "expires";
|
||||
tmpSource[0] = tmpSource[0].toUpper();
|
||||
const QString headerExpiration = reply->rawHeader( QString( tmpSource ).toLocal8Bit() );
|
||||
|
||||
const qlonglong maxAge = getMaxAge( headerExpiration.toLocal8Bit() );
|
||||
const qlonglong expires = headerExpiration.toLongLong(&ok);
|
||||
Tomahawk::InfoSystem::InfoStringHash source_expire;
|
||||
@@ -360,6 +366,7 @@ NewReleasesPlugin::nrSourcesList()
|
||||
*/
|
||||
TomahawkUtils::Cache::instance()->putData( "NewReleasesPlugin", 172800000 /* 2 days */, "nr_sources", QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > > ( m_nrSources ) );
|
||||
m_nrFetchJobs--;
|
||||
|
||||
if( !reply->property( "only_source_list" ).toBool() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Fetching all sources!";
|
||||
@@ -427,7 +434,11 @@ NewReleasesPlugin::nrList()
|
||||
|
||||
/// Got types, append!
|
||||
const QString source = reply->property( "nr_source" ).toString();
|
||||
const qlonglong expires = QString( reply->rawHeader( QString( "Expires" ).toLocal8Bit() ) ).toLongLong( &ok );
|
||||
|
||||
/// Twisted backend Uppers first header letter, and lowers the rest
|
||||
QString tmpSource = source + "expires";
|
||||
tmpSource[0] = tmpSource[0].toUpper();
|
||||
const qlonglong expires = QString( reply->rawHeader( QString( tmpSource ).toLocal8Bit() ) ).toLongLong( &ok );
|
||||
|
||||
// We'll populate newreleases with the data from the server
|
||||
QVariantMap newreleases;
|
||||
@@ -450,13 +461,14 @@ NewReleasesPlugin::nrList()
|
||||
const QString geo = nrMap.value( "geo" ).toString();
|
||||
const QString name = nrMap.value( "genre" ).toString();
|
||||
const QString type = QString( nrMap.value( "type" ).toString() + "s" );
|
||||
const QString nrExtraType = nrMap.value( "extra" ).toString();
|
||||
const bool isDefault = ( nrMap.contains( "default" ) && nrMap[ "default" ].toInt() == 1 );
|
||||
|
||||
// We only have albums in newReleases
|
||||
if ( type != "Albums" || name.isEmpty() )
|
||||
continue;
|
||||
|
||||
QString extra, nrExtraType;
|
||||
QString extra;
|
||||
if ( !geo.isEmpty() )
|
||||
{
|
||||
if ( !m_cachedCountries.contains( geo ) )
|
||||
@@ -480,13 +492,11 @@ NewReleasesPlugin::nrList()
|
||||
{
|
||||
extra = m_cachedCountries[ geo ];
|
||||
}
|
||||
nrExtraType = nrMap.value( "extra" ).toString() + " " + type;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No geo? Extra is the type, eg. Album
|
||||
extra = type;
|
||||
nrExtraType = nrMap.value( "extra" ).toString();
|
||||
}
|
||||
|
||||
InfoStringHash nr;
|
||||
@@ -497,6 +507,7 @@ NewReleasesPlugin::nrList()
|
||||
* If this item has expired, set it to 0.
|
||||
*/
|
||||
nr[ "expires" ] = ( ok ? QString::number (expires ) : QString::number( 0 ) );
|
||||
|
||||
if ( isDefault )
|
||||
nr[ "default" ] = "true";
|
||||
|
||||
|
Reference in New Issue
Block a user