spotify-now
Version:
spotify, rgb and bob.
28 lines • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getColor = void 0;
const tslib_1 = require("tslib");
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
const color_thief_node_1 = require("color-thief-node");
const getCurrentTrackId_1 = require("./getCurrentTrackId");
const getCurrentTrackImageUrl_1 = require("./getCurrentTrackImageUrl");
function getColor() {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
console.log(chalk_1.default.gray("Updating data..."));
const currentTrackId = yield (0, getCurrentTrackId_1.getCurrentTrackId)();
if (!currentTrackId) {
console.log("Currently not playing.");
return;
}
const imageUrl = yield (0, getCurrentTrackImageUrl_1.getCurrentTrackImageUrl)(currentTrackId);
if (!imageUrl) {
console.log("This track dose not have an image.");
return;
}
const color = yield (0, color_thief_node_1.getColorFromURL)(imageUrl);
console.log(chalk_1.default.gray("Color:"), chalk_1.default.bgRgb(...color)(" "), `(${color.toString()})`);
return color;
});
}
exports.getColor = getColor;
//# sourceMappingURL=getColor.js.map