-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsonos-service.js
41 lines (38 loc) · 1.53 KB
/
sonos-service.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { getMetadataResult, getMediaURI } = require("./utils");
const logger = require("./logger");
var sonosService = {
Sonos: {
SonosSoap: {
getMetadata: function (args) {
logger.debug("getMetadata sonos-service called with args", args)
let type = args["id"]; // "root" or abs library item id "li_laksjdfklasdj"
switch (type) {
case "root": // first request after selecting "audiobookshelf" in the app. Returns the list of books in the library
return getMetadataResult(type);
default: // request after selecting a specific book
return getMetadataResult(type); // this needs to be the same method due to SOAP doing SOAP things for the XML with the function name
}
},
getMediaMetadata: function (args) {
logger.debug("getMediaMetadata sonos-service called with args", args)
},
// get the actual URI of the audiobook / audiobook track we want to play
getMediaURI: function (args) {
logger.debug("getMediaURI sonos-service called with args", args)
return getMediaURI(args["id"]);
},
getLastUpdate: function (args) {
// accompanies most calls to see if sonos needs to update it's content
return {
getLastUpdateResult: {
catalog: `${Date.now()}`, // just force update every single time :D
autoRefreshEnabled: true,
favorites: `${Date.now()}`,
pollInterval: 10,
},
};
},
},
},
};
module.exports = sonosService;