apollo/services/trackers/aggregate-tracker.js

30 lines
542 B
JavaScript
Raw Permalink Normal View History

2024-12-04 23:18:35 -05:00
class AggregateTracker {
#name = null;
2024-12-05 03:26:31 -05:00
#trackers = []
provider = null;
2024-12-05 03:26:31 -05:00
constructor(name, trackers) {
this.#name = name;
2024-12-05 03:26:31 -05:00
this.#trackers = trackers;
2024-12-04 23:18:35 -05:00
}
get name() {
return this.#name;
}
get scrobblerNames() {
return this.#trackers.map(t => t.scrobblerNames)
.flat()
.filter((v, i, a) => a.indexOf(v) == i);
}
2024-12-05 03:26:31 -05:00
async poll() {
let media = []
for (let tracker of this.#trackers)
media = media.concat(await tracker.poll());
2024-12-04 23:18:35 -05:00
return media;
}
2024-12-05 03:26:31 -05:00
}
module.exports = AggregateTracker;