Compare commits

...

2 Commits

Author SHA1 Message Date
Tom
2b2cc20a1d Added support for multiple trackers & scrobblers. 2024-12-06 18:19:49 +00:00
Tom
7ef6ebb076 Docker runs the app in production. 2024-12-06 18:18:17 +00:00
5 changed files with 114 additions and 98 deletions

2
.gitignore vendored
View File

@ -4,4 +4,4 @@ config/*
!config/configuration.js
!config.schema.js
credentials.*
config*.yml
*.yml

View File

@ -14,4 +14,4 @@ COPY . .
EXPOSE ${WEB_PORT}
CMD [ "node", "app.js" ]
CMD ["npm", "run", "start"]

15
app.js
View File

@ -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);

View File

@ -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: {

View File

@ -3,6 +3,8 @@
"version": "0.0.0",
"main": "app.js",
"scripts": {
"start": "NODE_ENV=production node app.js",
"dev": "NODE_ENV=development node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",