Loading LastFM artist artwork for all local artists... need to check rate limiting
This commit is contained in:
@ -1545,6 +1545,7 @@ const MopidyMiddleware = (function(){
|
||||
* ======================================================================================
|
||||
**/
|
||||
|
||||
/*
|
||||
case 'MOPIDY_GET_LIBRARY_ARTISTS':
|
||||
instruct(socket, store, 'library.browse', { uri: 'local:directory?type=artist' } )
|
||||
.then(response => {
|
||||
@ -1555,23 +1556,31 @@ const MopidyMiddleware = (function(){
|
||||
store.dispatch({
|
||||
type: 'ARTISTS_LOADED',
|
||||
artists: response
|
||||
})
|
||||
});
|
||||
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
||||
uris: uris
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
// TODO: Load LastFM artwork?
|
||||
console.log(response);
|
||||
|
||||
// Get artwork for first 20
|
||||
for (var i = 0; i < response.length && i < 20; i++){
|
||||
store.dispatch(lastfmActions.getArtist(response[i].uri, response[i].name));
|
||||
}
|
||||
|
||||
});
|
||||
break;
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO: Fetch and process library artists
|
||||
*
|
||||
* We can't get specific artist artwork from Mopidy. Perhaps we fetch additional
|
||||
* artist metadata via LastFM? Their API limits will make this quite slow.
|
||||
*
|
||||
**/
|
||||
case 'MOPIDY_GET_LIBRARY_ARTISTS':
|
||||
|
||||
var last_run = store.getState().ui.processes.MOPIDY_LIBRARY_ARTISTS_PROCESSOR
|
||||
@ -1579,9 +1588,9 @@ const MopidyMiddleware = (function(){
|
||||
if (!last_run){
|
||||
instruct(socket, store, 'library.browse', { uri: 'local:directory?type=artist' } )
|
||||
.then(response => {
|
||||
if (response.length <= 0) return
|
||||
if (response.length <= 0) return;
|
||||
|
||||
var uris = helpers.arrayOf('uri',response)
|
||||
var uris = helpers.arrayOf('uri',response);
|
||||
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
||||
@ -1589,7 +1598,7 @@ const MopidyMiddleware = (function(){
|
||||
});
|
||||
|
||||
// Start our process to load the full album objects
|
||||
store.dispatch(uiActions.startProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR','Loading '+uris.length+' local artists', {uris: uris}))
|
||||
store.dispatch(uiActions.startProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR','Loading '+uris.length+' local artists', {uris: uris}));
|
||||
})
|
||||
|
||||
} else if (last_run.status == 'cancelled'){
|
||||
@ -1602,11 +1611,11 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
case 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR':
|
||||
if (store.getState().ui.processes['MOPIDY_LIBRARY_ARTISTS_PROCESSOR'] !== undefined){
|
||||
var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ARTISTS_PROCESSOR']
|
||||
var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ARTISTS_PROCESSOR'];
|
||||
|
||||
if (processor.status == 'cancelling'){
|
||||
store.dispatch(uiActions.processCancelled('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'))
|
||||
return false
|
||||
store.dispatch(uiActions.processCancelled('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1614,15 +1623,13 @@ const MopidyMiddleware = (function(){
|
||||
var uris_to_load = uris.splice(0,50)
|
||||
|
||||
if (uris_to_load.length > 0){
|
||||
store.dispatch(uiActions.updateProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR', 'Loading '+uris.length+' local artists', {uris: uris}))
|
||||
store.dispatch(mopidyActions.getArtists(uris_to_load, {name: 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR', data: {uris: uris}}))
|
||||
store.dispatch(uiActions.updateProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR', 'Loading '+uris.length+' local artists', {uris: uris}));
|
||||
store.dispatch(mopidyActions.getArtists(uris_to_load, {name: 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR', data: {uris: uris}}));
|
||||
} else {
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'))
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'));
|
||||
}
|
||||
|
||||
break
|
||||
|
||||
*/
|
||||
break;
|
||||
|
||||
case 'MOPIDY_GET_ARTIST':
|
||||
instruct(socket, store, 'library.lookup', action.data )
|
||||
@ -1698,8 +1705,12 @@ const MopidyMiddleware = (function(){
|
||||
{
|
||||
is_mopidy: true
|
||||
}
|
||||
)
|
||||
artists.push(artist)
|
||||
);
|
||||
artists.push(artist);
|
||||
|
||||
if (!artist.images){
|
||||
store.dispatch(lastfmActions.getArtist(artist.uri, artist.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user