apollo/services/scrobblers/scrobbler.js

31 lines
660 B
JavaScript
Raw Normal View History

2024-12-05 17:34:00 -05:00
const { Queue } = require("async-await-queue");
class Scrobbler {
#queue = null;
#logger = null;
constructor(logger) {
this.#queue = new Queue(1, 300);
this.#logger = logger;
}
async queue(media, duration, start) {
const id = Symbol();
try {
await this.#queue.wait(id, 0);
await this.scrobble(media, duration, start);
} catch (ex) {
this.#logger.console.error(media, "Failed to scrobble: " + ex.message);
} finally {
this.#queue.end(id, duration, start);
}
}
async scrobble(media, duration, start) {
console.log("This should not be running, ever.");
}
}
module.exports = Scrobbler;