mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
only load genre/style/mood from cache if it is empty
This commit is contained in:
parent
10b84c863d
commit
6e3b374dcb
@ -615,40 +615,48 @@ EchonestGenerator::loadStylesMoodsAndGenres()
|
||||
{
|
||||
if( !s_styles.isEmpty() && !s_moods.isEmpty() && !s_genres.isEmpty() )
|
||||
return;
|
||||
|
||||
QVariant styles = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "styles" );
|
||||
if ( styles.isValid() && styles.canConvert< QStringList >() )
|
||||
if ( s_styles.isEmpty() )
|
||||
{
|
||||
s_styles = styles.toStringList();
|
||||
}
|
||||
else
|
||||
{
|
||||
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 styles = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "styles" );
|
||||
if ( styles.isValid() && styles.canConvert< QStringList >() )
|
||||
{
|
||||
s_styles = styles.toStringList();
|
||||
}
|
||||
else
|
||||
{
|
||||
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 ( moods.isValid() && moods.canConvert< QStringList >() ) {
|
||||
s_moods = moods.toStringList();
|
||||
}
|
||||
else
|
||||
if ( s_moods.isEmpty() )
|
||||
{
|
||||
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 moods = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "moods" );
|
||||
if ( moods.isValid() && moods.canConvert< QStringList >() ) {
|
||||
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 ( genres.isValid() && genres.canConvert< QStringList >() )
|
||||
if ( s_genres.isEmpty() )
|
||||
{
|
||||
s_genres = genres.toStringList();
|
||||
}
|
||||
else
|
||||
{
|
||||
tLog() << "Genres not in cache or too old, refetching genres ...";
|
||||
s_genresJob = Echonest::Artist::fetchGenres();
|
||||
connect( s_genresJob, SIGNAL( finished() ), this, SLOT( genresReceived() ) );
|
||||
QVariant genres = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "genres" );
|
||||
if ( genres.isValid() && genres.canConvert< QStringList >() )
|
||||
{
|
||||
s_genres = genres.toStringList();
|
||||
}
|
||||
else
|
||||
{
|
||||
tLog() << "Genres not in cache or too old, refetching genres ...";
|
||||
s_genresJob = Echonest::Artist::fetchGenres();
|
||||
connect( s_genresJob, SIGNAL( finished() ), this, SLOT( genresReceived() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user