Playlist loader; Logging; Mopidy search

This commit is contained in:
James Barnsley
2016-11-07 18:09:42 +13:00
parent 5aec62a296
commit 757f11a6dd
12 changed files with 334 additions and 204 deletions

View File

@ -167,14 +167,16 @@ export function getAlbums(){
* Other general actions
**/
export function getSearchResults(query, fields = ['any'], backends = null){
export function getSearchResults(query, backends = null, fields = ['any']){
var queryObj = {};
for( var i = 0; i < fields.length; i++ ){
queryObj[fields[i]] = [query];
}
return {
type: 'MOPIDY_INSTRUCT',
call: 'library.search',
value: { query: queryObj, uris: backends }
}
}

View File

@ -143,6 +143,25 @@ const MopidyMiddleware = (function(){
instruct( socket, store, action.call, action.value )
break;
// send an instruction to the websocket
case 'MOPIDY_URISCHEMES':
var uri_schemes = action.data
var remove = ['http','https','mms','rtmp','rtmps','rtsp','sc','yt','spotify']
// remove all our ignored types
for( var i = 0; i < remove.length; i++ ){
var index = uri_schemes.indexOf(remove[i])
if( index > -1 ) uri_schemes.splice(index, 1);
}
// append with ':' to make them a mopidy URI
for( var i = 0; i < uri_schemes.length; i++ ){
uri_schemes[i] = uri_schemes[i] +':'
}
store.dispatch({ type: 'MOPIDY_URISCHEMES_FILTERED', data: uri_schemes });
break;
case 'MOPIDY_PLAY_TRACKS':
// add our first track

View File

@ -23,7 +23,7 @@ export default function reducer(mopidy = {}, action){
tlid: action.tlid
});
case 'MOPIDY_URISCHEMES':
case 'MOPIDY_URISCHEMES_FILTERED':
return Object.assign({}, mopidy, {
uri_schemes: action.data
});
@ -124,7 +124,7 @@ export default function reducer(mopidy = {}, action){
case 'MOPIDY_SEARCH':
var results = []
for( var i = 0; i < action.data.length; i++ ){
results = [...results, ...action.data[i].tracks]
if( action.data[i].tracks ) results = [...results, ...action.data[i].tracks]
}
return Object.assign({}, mopidy, {
search_results_tracks: results