Added support for multiple trackers & scrobblers.
This commit is contained in:
parent
7ef6ebb076
commit
2b2cc20a1d
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,4 +4,4 @@ config/*
|
||||
!config/configuration.js
|
||||
!config.schema.js
|
||||
credentials.*
|
||||
config*.yml
|
||||
*.yml
|
15
app.js
15
app.js
@ -10,11 +10,16 @@ const Recorder = require("./services/recorder");
|
||||
const MalojaScrobbler = require("./services/scrobblers/maloja-scrobbler");
|
||||
|
||||
|
||||
const maloja = new MalojaScrobbler(config.maloja, logger);
|
||||
const spotify = new SpotifyTracker(config.spotify);
|
||||
(async () => await spotify.loadCredentials())();
|
||||
const plex = new PlexTracker(config.plex);
|
||||
const recorder = new Recorder(sessions, [plex, spotify], [maloja], config.scrobble, logger);
|
||||
let trackers = []
|
||||
trackers = trackers.concat(config.spotify.map(config => new SpotifyTracker(config)));
|
||||
trackers = trackers.concat(config.plex.map(config => new PlexTracker(config)));
|
||||
|
||||
const uniqueSpotifys = new Set(config.spotify.map(c => c.client_id));
|
||||
for (let spotify of uniqueSpotifys)
|
||||
(async () => await spotify.loadCredentials())();
|
||||
|
||||
const scrobblers = config.maloja.map(config => new MalojaScrobbler(config, logger));
|
||||
const recorder = new Recorder(sessions, trackers, scrobblers, config.scrobble, logger);
|
||||
|
||||
setInterval(() => recorder.record(), 5000);
|
||||
|
||||
|
@ -3,6 +3,8 @@ const schema = {
|
||||
required: [],
|
||||
properties: {
|
||||
maloja: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
required: ['name', 'url', 'token'],
|
||||
properties: {
|
||||
@ -16,8 +18,11 @@ const schema = {
|
||||
type: 'string'
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
plex: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
required: ['name', 'url', 'token', 'scrobblers'],
|
||||
properties: {
|
||||
@ -82,6 +87,7 @@ const schema = {
|
||||
minItems: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
scrobble: {
|
||||
@ -102,6 +108,8 @@ const schema = {
|
||||
},
|
||||
|
||||
spotify: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
required: ['name', 'client_id', 'client_secret', 'redirect_uri', 'scrobblers'],
|
||||
properties: {
|
||||
@ -125,6 +133,7 @@ const schema = {
|
||||
minItems: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
web: {
|
||||
|
Loading…
Reference in New Issue
Block a user