Made handling of bar changing nicer, high quality images
This commit is contained in:
parent
62285d572b
commit
1b0cf7c2b3
16
main.js
16
main.js
|
@ -3,10 +3,13 @@ const sharp = require('sharp');
|
|||
const rp = require('request-promise');
|
||||
const fs = require('fs');
|
||||
const { exec } = require('child_process');
|
||||
const crypto = require('crypto');
|
||||
|
||||
const config = JSON.parse(fs.readFileSync("config.json"));
|
||||
const updateInterval = 5000;
|
||||
|
||||
let previousHash = null;
|
||||
|
||||
async function processAlbumCover(url) {
|
||||
try {
|
||||
console.log(`Processing album cover from URL: ${url}`);
|
||||
|
@ -114,8 +117,21 @@ async function fetchCurrentScrobble(user) {
|
|||
}
|
||||
}
|
||||
|
||||
if (coverURL && coverURL.includes('300x300')) {
|
||||
coverURL = coverURL.replace('300x300', '1000x1000');
|
||||
}
|
||||
|
||||
if (coverURL) {
|
||||
const { outputBuffer, dominantColor } = await processAlbumCover(coverURL);
|
||||
|
||||
const hash = crypto.createHash('sha256').update(outputBuffer).digest('hex');
|
||||
if (hash === previousHash) {
|
||||
console.log("Image is the same as before. Skipping updates.");
|
||||
return;
|
||||
}
|
||||
|
||||
previousHash = hash;
|
||||
|
||||
await setAsWallpaper(outputBuffer, dominantColor);
|
||||
console.log("Successfully fetched current scrobble.");
|
||||
return { outputBuffer, dominantColor };
|
||||
|
|
Loading…
Reference in New Issue