2019-10-30 23:42:08 +01:00
|
|
|
const statuses = require("./../constants/statuses");
|
|
|
|
|
2019-10-30 22:49:04 +01:00
|
|
|
const mediaInfo = {
|
|
|
|
title: "",
|
|
|
|
artist: "",
|
|
|
|
icon: "",
|
2019-10-30 23:42:08 +01:00
|
|
|
status: statuses.paused,
|
2021-04-19 20:43:25 +02:00
|
|
|
url: ""
|
2019-10-30 22:49:04 +01:00
|
|
|
};
|
|
|
|
const mediaInfoModule = {
|
|
|
|
mediaInfo,
|
|
|
|
};
|
|
|
|
|
2019-10-30 23:42:08 +01:00
|
|
|
/**
|
|
|
|
* Update artist and song info in the mediaInfo constant
|
|
|
|
*/
|
2019-10-30 22:49:04 +01:00
|
|
|
mediaInfoModule.update = function(arg) {
|
|
|
|
mediaInfo.title = propOrDefault(arg.title);
|
|
|
|
mediaInfo.artist = propOrDefault(arg.message);
|
|
|
|
mediaInfo.icon = propOrDefault(arg.icon);
|
2021-04-19 20:43:25 +02:00
|
|
|
mediaInfo.url = propOrDefault(arg.url);
|
2019-10-30 22:49:04 +01:00
|
|
|
};
|
|
|
|
|
2019-10-30 23:42:08 +01:00
|
|
|
/**
|
|
|
|
* Update tidal's status in the mediaInfo constant
|
|
|
|
*/
|
|
|
|
mediaInfoModule.updateStatus = function(status) {
|
|
|
|
if (Object.values(statuses).includes(status)) {
|
|
|
|
mediaInfo.status = status;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-10-30 22:49:04 +01:00
|
|
|
/**
|
|
|
|
* Return the property or a default value
|
|
|
|
* @param {*} prop property to check
|
|
|
|
* @param {*} defaultValue defaults to ""
|
|
|
|
*/
|
|
|
|
function propOrDefault(prop, defaultValue = "") {
|
|
|
|
return prop ? prop : defaultValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = mediaInfoModule;
|