Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion volusonic/UIConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
"doc": "TRANSLATE.METAS",
"label": "Metadatas",
"element": "switch",
"value": true
"value": false
},
{
"id": "path",
Expand Down
101 changes: 68 additions & 33 deletions volusonic/index.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var backend = require('./backend');
var fs = require('fs');
var myUri = "";
var semver = require('semver');
const { url } = require('inspector');

libQ.longStackSupport = true;

Expand Down Expand Up @@ -1070,15 +1071,15 @@ ControllerVolusonic.prototype._formatAlbum = function(album, curUri) {
var tit = album.name || album.title;

var item = {
service: 'volusonic',
type: 'playlist',
title: tit + ' (' + new Date(album.created).getFullYear() + ')',
artist: album.artist,
album: "",
albumart: self.config.get('server') + '/rest/getCoverArt.view?id=' + self._getArtId(album.coverArt) + '&' + self.getSetting('artSize') + '&' + self.config.get('auth'),
icon: "",
uri: curUri + '/' + album.id
}
service: 'volusonic',
type: 'folder',
title: tit,
artist: album.artist,
album: tit,
albumart: self.config.get('server') + '/rest/getCoverArt.view?id=' + self._getArtId(album.coverArt) + '&' + self.getSetting('artSize') + '&' + self.config.get('auth'),
icon: "",
uri: curUri + '/' + album.id
}
return item;
}

Expand All @@ -1087,7 +1088,7 @@ ControllerVolusonic.prototype._formatPlaylist = function(playlist, curUri) {
var item = {
service: 'volusonic',
type: 'folder',
title: playlist.name + ' (' + new Date(playlist.created).getFullYear() + ')',
title: playlist.name,
albumart: self.config.get('server') + '/rest/getCoverArt.view?id=' + self._getArtId(playlist.coverArt) + '&' + self.getSetting('artSize') + '&' + self.config.get('auth'),
icon: "",
uri: curUri + '/' + playlist.id
Expand Down Expand Up @@ -1218,10 +1219,10 @@ ControllerVolusonic.prototype.listFavorites = function(uriParts, curUri) {
var defer = libQ.defer();

var getFavorites = "getStarred";
//if (self.config.get('ID3')) getFavorites = "getStarred2";
if (self.config.get('ID3')) getFavorites = "getStarred2";

var container = "starred";
//if (self.config.get('ID3')) container = "starred2";
if (self.config.get('ID3')) container = "starred2";

var result = self.backend.get(getFavorites, 'Favorites', '')
.then(function(result) {
Expand Down Expand Up @@ -1428,7 +1429,27 @@ ControllerVolusonic.prototype.explodeUri = function(uri) {
var items = [];
var song;

if (uri.startsWith('volusonic/track')) {
if (uri.startsWith('http')) {
command = 'getSong';

let paramsString = uri.split('?')[1]
let searchParams = new URLSearchParams(paramsString);
if (searchParams.has('id')) {
id = searchParams.get('id');
params = 'id=' + id;
}
self.backend.get(command, id, params)
.then(function(result) {
song = result['subsonic-response']['song'];
let playable = self._getPlayable(song[0] || song);
items.push(playable)
defer.resolve(items);
})
.fail(function(error) {
defer.reject(new Error('explodeUri volusonic/track'));
});

} else if (uri.startsWith('volusonic/track')) {
command = 'getSong';
//get the podcast ChannelId if needed
if (id.includes("C")) {
Expand All @@ -1438,7 +1459,7 @@ ControllerVolusonic.prototype.explodeUri = function(uri) {
} else {
params = 'id=' + id;
}
var result = self.backend.get(command, id, params)
self.backend.get(command, id, params)
.then(function(result) {
if (result['subsonic-response']['song']['0'] !== undefined) { //ampache hack
song = result['subsonic-response']['song']['0'];
Expand All @@ -1449,9 +1470,10 @@ ControllerVolusonic.prototype.explodeUri = function(uri) {
if (channelId !== undefined) {
playable.channelId = channelId;
}
defer.resolve(playable);
items.push(playable)
defer.resolve(items);
})
.fail(function(result) {
.fail(function(error) {
defer.reject(new Error('explodeUri volusonic/track'));
});
} else if (uri.startsWith('volusonic/playlists')) {
Expand Down Expand Up @@ -1631,20 +1653,38 @@ ControllerVolusonic.prototype._getPlayable = function(song) {
return track;
}

function track_id(uri) {
if (uri.startsWith('volusonic/track')) {
return url.split('/')[2];
}
if (uri.startsWith('http')) {
var paramsString = param.uri.split('?')[1]
var searchParams = new URLSearchParams(paramsString);
if (searchParams.has('id')) {
return searchParams.get('id');
}
}
throw 'invalid uri : ' + uri;
}

ControllerVolusonic.prototype.getTrackInfo = function(uri) {
var self = this;
var deferred = libQ.defer();
var uriParts = uri.split('/');

if (uri.startsWith('volusonic/track')) {
var result = self.backend.get('getSong', uriParts[2], 'id=' + uriParts[2])
.then(function(result) {
var song = result['subsonic-response']['song'];
defer.resolve(self._getPlayable(song));
})
.fail(function(result) {
defer.reject(new Error('getTrackInfo'));
});
var defer = libQ.defer();
try {
var id = track_id(uri);

if (uri.startsWith('volusonic/track')) {
var result = self.backend.get('getSong', id, 'id=' + id)
.then(function(result) {
var song = result['subsonic-response']['song'];
defer.resolve(self._getPlayable(song));
})
.fail(function(result) {
defer.reject(new Error('getTrackInfo'));
});
}
} catch(error) {
defer.reject(new Error(error));
}
return defer.promise;
}
Expand Down Expand Up @@ -1901,11 +1941,6 @@ ControllerVolusonic.prototype.pushState = function(state) {
return self.commandRouter.servicePushState(state, 'volusonic');
};

ControllerVolusonic.prototype.addToFavourites = function(param) {
var self = this;
//self.commandRouter.pushConsoleMessage("volusonic.addToFavourites: " + JSON.stringify(param));
};

ControllerVolusonic.prototype.goto = function(data) {
var self = this;
var defer = libQ.defer();
Expand Down
2 changes: 1 addition & 1 deletion volusonic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "volusonic",
"version": "2.3.0",
"version": "3.4.0",
"description": "Volumio client for subsonic's API servers (subsonic / navidrome / airsonic / ampache / owncloud / nextcloud / etc..)",
"main": "index.js",
"scripts": {
Expand Down