Ability to disable album art for playlists (#159)

This commit is contained in:
Simon J
2023-04-22 10:54:38 +10:00
committed by GitHub
parent 8111041551
commit f6fc7ab920
6 changed files with 57 additions and 26 deletions

View File

@@ -3,6 +3,7 @@ FROM node:16-bullseye
LABEL maintainer=simojenki LABEL maintainer=simojenki
ENV JEST_TIMEOUT=60000 ENV JEST_TIMEOUT=60000
EXPOSE 4534
RUN apt-get update && \ RUN apt-get update && \
apt-get -y upgrade && \ apt-get -y upgrade && \

View File

@@ -3,6 +3,12 @@
"build": { "build": {
"dockerfile": "Dockerfile" "dockerfile": "Dockerfile"
}, },
"containerEnv": {
// these env vars need to be configured appropriately for your local dev env
"BNB_DEV_SONOS_DEVICE_IP": "${localEnv:BNB_DEV_SONOS_DEVICE_IP}",
"BNB_DEV_HOST_IP": "${localEnv:BNB_DEV_HOST_IP}",
"BNB_DEV_SUBSONIC_URL": "${localEnv:BNB_DEV_SUBSONIC_URL}"
},
"remoteUser": "node", "remoteUser": "node",
"features": { "features": {
"ghcr.io/devcontainers/features/docker-in-docker:1": { "ghcr.io/devcontainers/features/docker-in-docker:1": {

View File

@@ -163,6 +163,7 @@ BNB_URL | http://$(hostname):4534 | URL (including path) for bonob so that sonos
BNB_SECRET | bonob | secret used for encrypting credentials BNB_SECRET | bonob | secret used for encrypting credentials
BNB_AUTH_TIMEOUT | 1h | Timeout for the sonos auth token, described in the format [ms](https://github.com/vercel/ms), ie. '5s' == 5 seconds, '11h' == 11 hours. In the case of using Navidrome this should be less than the value for ND_SESSIONTIMEOUT BNB_AUTH_TIMEOUT | 1h | Timeout for the sonos auth token, described in the format [ms](https://github.com/vercel/ms), ie. '5s' == 5 seconds, '11h' == 11 hours. In the case of using Navidrome this should be less than the value for ND_SESSIONTIMEOUT
BNB_LOG_LEVEL | info | Log level. One of ['debug', 'info', 'warn', 'error'] BNB_LOG_LEVEL | info | Log level. One of ['debug', 'info', 'warn', 'error']
BNB_DISABLE_PLAYLIST_ART | undefined | Disables playlist art generation, ie. when there are many playlists and art generation takes too long
BNB_SERVER_LOG_REQUESTS | false | Whether or not to log http requests BNB_SERVER_LOG_REQUESTS | false | Whether or not to log http requests
BNB_SONOS_AUTO_REGISTER | false | Whether or not to try and auto-register on startup BNB_SONOS_AUTO_REGISTER | false | Whether or not to try and auto-register on startup
BNB_SONOS_DEVICE_DISCOVERY | true | Enable/Disable sonos device discovery entirely. Setting this to 'false' will disable sonos device search, regardless of whether a seed host is specified. BNB_SONOS_DEVICE_DISCOVERY | true | Enable/Disable sonos device discovery entirely. Setting this to 'false' will disable sonos device search, regardless of whether a seed host is specified.

View File

@@ -62,9 +62,9 @@
"scripts": { "scripts": {
"clean": "rm -Rf build node_modules", "clean": "rm -Rf build node_modules",
"build": "tsc", "build": "tsc",
"dev": "BNB_LOG_LEVEL=debug BNB_DEBUG=true BNB_SCROBBLE_TRACKS=false BNB_REPORT_NOW_PLAYING=false BNB_ICON_FOREGROUND_COLOR=white BNB_ICON_BACKGROUND_COLOR=darkgrey BNB_SONOS_SERVICE_NAME=bonobDev BNB_SONOS_DEVICE_DISCOVERY=true nodemon -V ./src/app.ts", "dev": "BNB_LOG_LEVEL=debug BNB_DEBUG=true BNB_SCROBBLE_TRACKS=false BNB_REPORT_NOW_PLAYING=false BNB_ICON_FOREGROUND_COLOR=white BNB_ICON_BACKGROUND_COLOR=darkgrey BNB_SONOS_SEED_HOST=$BNB_DEV_SONOS_DEVICE_IP BNB_SONOS_SERVICE_NAME=z_bonobDev BNB_SONOS_DEVICE_DISCOVERY=true BNB_URL=\"http://${BNB_DEV_HOST_IP}:4534\" BNB_SUBSONIC_URL=\"${BNB_DEV_SUBSONIC_URL}\" nodemon -V ./src/app.ts",
"devr": "BNB_LOG_LEVEL=debug BNB_DEBUG=true BNB_SCROBBLE_TRACKS=false BNB_REPORT_NOW_PLAYING=false BNB_ICON_FOREGROUND_COLOR=white BNB_ICON_BACKGROUND_COLOR=darkgrey BNB_SONOS_SERVICE_NAME=bonobDev BNB_SONOS_DEVICE_DISCOVERY=true BNB_SONOS_AUTO_REGISTER=true nodemon -V ./src/app.ts", "devr": "BNB_DISABLE_PLAYLIST_ART=true BNB_LOG_LEVEL=debug BNB_DEBUG=true BNB_SCROBBLE_TRACKS=false BNB_REPORT_NOW_PLAYING=false BNB_ICON_FOREGROUND_COLOR=white BNB_ICON_BACKGROUND_COLOR=darkgrey BNB_SONOS_SEED_HOST=$BNB_DEV_SONOS_DEVICE_IP BNB_SONOS_SERVICE_NAME=z_bonobDev BNB_SONOS_DEVICE_DISCOVERY=true BNB_SONOS_AUTO_REGISTER=true BNB_URL=\"http://${BNB_DEV_HOST_IP}:4534\" BNB_SUBSONIC_URL=\"${BNB_DEV_SUBSONIC_URL}\" nodemon -V ./src/app.ts",
"register-dev": "ts-node ./src/register.ts http://$(hostname):4534", "register-dev": "ts-node ./src/register.ts http://${BNB_DEV_HOST_IP}:4534",
"test": "jest", "test": "jest",
"gitinfo": "git describe --tags > .gitinfo" "gitinfo": "git describe --tags > .gitinfo"
}, },

View File

@@ -266,6 +266,9 @@ export const playlistAlbumArtURL = (
bonobUrl: URLBuilder, bonobUrl: URLBuilder,
playlist: Playlist playlist: Playlist
) => { ) => {
// todo: this should be put into config, or even just removed for the ND music source
if(process.env["BNB_DISABLE_PLAYLIST_ART"]) return iconArtURI(bonobUrl, "music");
const burns: BUrn[] = uniq( const burns: BUrn[] = uniq(
playlist.entries.filter((it) => it.coverArt != undefined), playlist.entries.filter((it) => it.coverArt != undefined),
(it) => it.album.id (it) => it.album.id

View File

@@ -519,30 +519,30 @@ describe("playlistAlbumArtURL", () => {
}); });
describe("when the playlist has external ids", () => { describe("when the playlist has external ids", () => {
const bonobUrl = url("http://localhost:1234/context-path?search=yes");
const externalArt1 = {
system: "external",
resource: "http://example.com/image1.jpg",
};
const externalArt2 = {
system: "external",
resource: "http://example.com/image2.jpg",
};
const playlist = aPlaylist({
entries: [
aTrack({
coverArt: externalArt1,
album: anAlbumSummary({ id: "album1" }),
}),
aTrack({
coverArt: externalArt2,
album: anAlbumSummary({ id: "album2" }),
}),
],
});
it("should format the url with encrypted urn", () => { it("should format the url with encrypted urn", () => {
const bonobUrl = url("http://localhost:1234/context-path?search=yes");
const externalArt1 = {
system: "external",
resource: "http://example.com/image1.jpg",
};
const externalArt2 = {
system: "external",
resource: "http://example.com/image2.jpg",
};
const playlist = aPlaylist({
entries: [
aTrack({
coverArt: externalArt1,
album: anAlbumSummary({ id: "album1" }),
}),
aTrack({
coverArt: externalArt2,
album: anAlbumSummary({ id: "album2" }),
}),
],
});
expect(playlistAlbumArtURL(bonobUrl, playlist).href()).toEqual( expect(playlistAlbumArtURL(bonobUrl, playlist).href()).toEqual(
`http://localhost:1234/context-path/art/${encodeURIComponent( `http://localhost:1234/context-path/art/${encodeURIComponent(
formatForURL(externalArt1) formatForURL(externalArt1)
@@ -550,6 +550,26 @@ describe("playlistAlbumArtURL", () => {
formatForURL(externalArt2) formatForURL(externalArt2)
)}/size/180?search=yes` )}/size/180?search=yes`
); );
});
describe("when BNB_NO_PLAYLIST_ART is set", () => {
const OLD_ENV = process.env;
beforeEach(() => {
process.env = { ...OLD_ENV };
process.env["BNB_DISABLE_PLAYLIST_ART"] = "true";
});
afterEach(() => {
process.env = OLD_ENV;
});
it("should return an icon", () => {
expect(playlistAlbumArtURL(bonobUrl, playlist).href()).toEqual(
`http://localhost:1234/context-path/icon/music/size/legacy?search=yes`
);
});
}); });
}); });