1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 21:57:41 +02:00

only load genre/style/mood from cache if it is empty

This commit is contained in:
Stefan Derkits
2013-02-19 16:45:58 +01:00
parent 10b84c863d
commit 6e3b374dcb

View File

@@ -615,40 +615,48 @@ EchonestGenerator::loadStylesMoodsAndGenres()
{ {
if( !s_styles.isEmpty() && !s_moods.isEmpty() && !s_genres.isEmpty() ) if( !s_styles.isEmpty() && !s_moods.isEmpty() && !s_genres.isEmpty() )
return; return;
if ( s_styles.isEmpty() )
QVariant styles = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "styles" );
if ( styles.isValid() && styles.canConvert< QStringList >() )
{ {
s_styles = styles.toStringList(); QVariant styles = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "styles" );
} if ( styles.isValid() && styles.canConvert< QStringList >() )
else {
{ s_styles = styles.toStringList();
tLog() << "Styles not in cache or too old, refetching styles ..."; }
s_stylesJob = Echonest::Artist::listTerms( "style" ); else
connect( s_stylesJob, SIGNAL( finished() ), this, SLOT( stylesReceived() ) ); {
tLog() << "Styles not in cache or too old, refetching styles ...";
s_stylesJob = Echonest::Artist::listTerms( "style" );
connect( s_stylesJob, SIGNAL( finished() ), this, SLOT( stylesReceived() ) );
}
} }
QVariant moods = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "moods" ); if ( s_moods.isEmpty() )
if ( moods.isValid() && moods.canConvert< QStringList >() ) {
s_moods = moods.toStringList();
}
else
{ {
tLog() << "Moods not in cache or too old, refetching moods ..."; QVariant moods = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "moods" );
s_moodsJob = Echonest::Artist::listTerms( "mood" ); if ( moods.isValid() && moods.canConvert< QStringList >() ) {
connect( s_moodsJob, SIGNAL( finished() ), this, SLOT( moodsReceived() ) ); s_moods = moods.toStringList();
}
else
{
tLog() << "Moods not in cache or too old, refetching moods ...";
s_moodsJob = Echonest::Artist::listTerms( "mood" );
connect( s_moodsJob, SIGNAL( finished() ), this, SLOT( moodsReceived() ) );
}
} }
QVariant genres = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "genres" ); if ( s_genres.isEmpty() )
if ( genres.isValid() && genres.canConvert< QStringList >() )
{ {
s_genres = genres.toStringList(); QVariant genres = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "genres" );
} if ( genres.isValid() && genres.canConvert< QStringList >() )
else {
{ s_genres = genres.toStringList();
tLog() << "Genres not in cache or too old, refetching genres ..."; }
s_genresJob = Echonest::Artist::fetchGenres(); else
connect( s_genresJob, SIGNAL( finished() ), this, SLOT( genresReceived() ) ); {
tLog() << "Genres not in cache or too old, refetching genres ...";
s_genresJob = Echonest::Artist::fetchGenres();
connect( s_genresJob, SIGNAL( finished() ), this, SLOT( genresReceived() ) );
}
} }
} }