Ability for Navidrome to have custom client app per mime type, so can have custom transcoders per audio file type. Change stream to stream rather than buffer response in byte array

This commit is contained in:
simojenki
2021-04-19 10:36:40 +10:00
parent 9458da74ed
commit 759592767f
8 changed files with 485 additions and 265 deletions

View File

@@ -1,7 +1,7 @@
import sonos, { bonobService } from "./sonos";
import server from "./server";
import logger from "./logger";
import { Navidrome } from "./navidrome";
import { DEFAULT, Navidrome, appendMimeTypeToClientFor } from "./navidrome";
import encryption from "./encryption";
import { InMemoryAccessTokens, sha256 } from "./access_tokens";
import { InMemoryLinkCodes } from "./link_codes";
@@ -23,21 +23,28 @@ const bonob = bonobService(
const secret = process.env["BONOB_SECRET"] || "bonob";
const sonosSystem = sonos(SONOS_DEVICE_DISCOVERY, SONOS_SEED_HOST);
if(process.env["BONOB_SONOS_AUTO_REGISTER"] == "true") {
sonosSystem.register(bonob).then(success => {
if(success) {
logger.info(`Successfully registered ${bonob.name}(SID:${bonob.sid}) with sonos`)
if (process.env["BONOB_SONOS_AUTO_REGISTER"] == "true") {
sonosSystem.register(bonob).then((success) => {
if (success) {
logger.info(
`Successfully registered ${bonob.name}(SID:${bonob.sid}) with sonos`
);
}
})
});
}
const customClientsFor = process.env["BONOB_STREAM_CUSTOM_CLIENTS"] || "none";
const streamUserAgent =
customClientsFor == "none" ? DEFAULT : appendMimeTypeToClientFor(customClientsFor.split(","));
const app = server(
sonosSystem,
bonob,
WEB_ADDRESS,
new Navidrome(
process.env["BONOB_NAVIDROME_URL"] || "http://localhost:4533",
encryption(secret)
encryption(secret),
streamUserAgent
),
new InMemoryLinkCodes(),
new InMemoryAccessTokens(sha256(secret))