Compare commits

..

No commits in common. "2b2cc20a1d2c07bc14099e9733bc5c268dde4b27" and "748d9de02ac37646ec5618d9d47ecd509ca7d377" have entirely different histories.

5 changed files with 93 additions and 109 deletions

2
.gitignore vendored
View File

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

View File

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

15
app.js
View File

@ -10,16 +10,11 @@ const Recorder = require("./services/recorder");
const MalojaScrobbler = require("./services/scrobblers/maloja-scrobbler"); const MalojaScrobbler = require("./services/scrobblers/maloja-scrobbler");
let trackers = [] const maloja = new MalojaScrobbler(config.maloja, logger);
trackers = trackers.concat(config.spotify.map(config => new SpotifyTracker(config))); const spotify = new SpotifyTracker(config.spotify);
trackers = trackers.concat(config.plex.map(config => new PlexTracker(config))); (async () => await spotify.loadCredentials())();
const plex = new PlexTracker(config.plex);
const uniqueSpotifys = new Set(config.spotify.map(c => c.client_id)); const recorder = new Recorder(sessions, [plex, spotify], [maloja], config.scrobble, logger);
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); setInterval(() => recorder.record(), 5000);

View File

@ -3,89 +3,83 @@ const schema = {
required: [], required: [],
properties: { properties: {
maloja: { maloja: {
type: 'array', type: 'object',
items: { required: ['name', 'url', 'token'],
type: 'object', properties: {
required: ['name', 'url', 'token'], name: {
properties: { type: 'string'
name: { },
type: 'string' url: {
}, type: 'string'
url: { },
type: 'string' token: {
}, type: 'string'
token: { },
type: 'string'
},
}
} }
}, },
plex: { plex: {
type: 'array', type: 'object',
items: { required: ['name', 'url', 'token', 'scrobblers'],
type: 'object', properties: {
required: ['name', 'url', 'token', 'scrobblers'], name: {
properties: { type: 'string'
name: { },
type: 'string' url: {
}, type: 'string'
url: { },
type: 'string' token: {
}, type: 'string'
token: { },
type: 'string' filters: {
}, type: 'array',
filters: { minItems: 0,
type: 'array', items: {
minItems: 0, type: 'object',
items: { properties: {
type: 'object', library: {
properties: { type: 'array',
library: { items: {
type: 'array', type: 'string'
items: {
type: 'string'
},
minItems: 0,
}, },
ip: { minItems: 0,
type: 'array', },
items: { ip: {
type: 'string' type: 'array',
}, items: {
minItems: 0, type: 'string'
}, },
deviceId: { minItems: 0,
type: 'array', },
items: { deviceId: {
type: 'string' type: 'array',
}, items: {
minItems: 0, type: 'string'
}, },
platform: { minItems: 0,
type: 'array', },
items: { platform: {
type: 'string' type: 'array',
}, items: {
minItems: 0, type: 'string'
}, },
product: { minItems: 0,
type: 'array', },
items: { product: {
type: 'string' type: 'array',
}, items: {
minItems: 0, type: 'string'
}, },
} minItems: 0,
},
} }
},
scrobblers: {
type: 'array',
items: {
type: 'string'
},
minItems: 1
} }
},
scrobblers: {
type: 'array',
items: {
type: 'string'
},
minItems: 1
} }
} }
}, },
@ -108,30 +102,27 @@ const schema = {
}, },
spotify: { spotify: {
type: 'array', type: 'object',
items: { required: ['name', 'client_id', 'client_secret', 'redirect_uri', 'scrobblers'],
type: 'object', properties: {
required: ['name', 'client_id', 'client_secret', 'redirect_uri', 'scrobblers'], name: {
properties: { type: 'string'
name: { },
client_id: {
type: 'string'
},
client_secret: {
type: 'string'
},
redirect_uri: {
type: 'string'
},
scrobblers: {
type: 'array',
items: {
type: 'string' type: 'string'
}, },
client_id: { minItems: 1
type: 'string'
},
client_secret: {
type: 'string'
},
redirect_uri: {
type: 'string'
},
scrobblers: {
type: 'array',
items: {
type: 'string'
},
minItems: 1
}
} }
} }
}, },

View File

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