Compare commits

...

37 Commits

Author SHA1 Message Date
Simon J
f6fc7ab920 Ability to disable album art for playlists (#159) 2023-04-22 10:54:38 +10:00
simojenki
8111041551 Additional documentation around where to pull image from 2023-03-18 08:47:16 +11:00
simojenki
df2ef9b152 Add some labels to docker image 2023-03-17 10:37:42 +11:00
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs
33473cd387 ci: Push image to GHCR (#153)
* ci: Push image to GHCR

* ci: Update build actions
2023-03-17 10:26:43 +11:00
Simon J
7f743aaa7e Change some messages from info to debug, route all soap info to debug (#151) 2023-03-13 08:47:32 +11:00
simojenki
d4bed77c54 Set default log level to info 2023-03-12 07:52:43 +00:00
Simon J
29531a6e01 Ability to configure log level, default to 'warn' (#150) 2023-03-12 13:52:38 +11:00
Simon J
e78b6c4fbc Ability to configure whether to log http requests (#149) 2023-03-12 09:21:49 +11:00
Simon J
2941f6f595 Add wget to image 2023-03-09 06:55:58 +11:00
Daniel Hammer
2c48d08b0e Expanded BNB_SUBSONIC_ARTIST_IMAGE_CACHE description to reflect maintainer insights. (#146)
@see https://github.com/simojenki/bonob/issues/138#issuecomment-1455001557

Co-authored-by: Daniel Hammer <daniel.hammer+oss@gmail.com>
2023-03-08 16:16:03 +11:00
Daniel Hammer
de48ee0fca Added initial da-DK i18n. (#140) 2023-03-06 18:40:08 +11:00
Simon J
cefdf5e2d5 Switch to node:16-bullsys-slim images to reduce final image size (#144) 2023-03-06 18:39:40 +11:00
Daniel Hammer
f86a78b338 Added initial documentation for multiple registrations. (#141)
@see https://github.com/simojenki/bonob/issues/139

Co-authored-by: Daniel Hammer <daniel.hammer+oss@gmail.com>
2023-03-06 10:41:55 +11:00
dependabot[bot]
4d23885d7c Bump @xmldom/xmldom from 0.7.6 to 0.7.9 (#143)
Bumps [@xmldom/xmldom](https://github.com/xmldom/xmldom) from 0.7.6 to 0.7.9.
- [Release notes](https://github.com/xmldom/xmldom/releases)
- [Changelog](https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md)
- [Commits](https://github.com/xmldom/xmldom/compare/0.7.6...0.7.9)

---
updated-dependencies:
- dependency-name: "@xmldom/xmldom"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 10:41:19 +11:00
dependabot[bot]
8c80c00089 Bump qs from 6.10.1 to 6.11.0 (#142)
Bumps [qs](https://github.com/ljharb/qs) from 6.10.1 to 6.11.0.
- [Release notes](https://github.com/ljharb/qs/releases)
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.10.1...v6.11.0)

---
updated-dependencies:
- dependency-name: qs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 10:41:08 +11:00
dependabot[bot]
ebf385e918 Bump http-cache-semantics from 4.1.0 to 4.1.1 (#133)
Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/kornelski/http-cache-semantics/releases)
- [Commits](https://github.com/kornelski/http-cache-semantics/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: http-cache-semantics
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 10:40:52 +11:00
dependabot[bot]
a20fdcbc5f Bump eta from 1.12.3 to 2.0.0 (#131)
Bumps [eta](https://github.com/eta-dev/eta) from 1.12.3 to 2.0.0.
- [Release notes](https://github.com/eta-dev/eta/releases)
- [Commits](https://github.com/eta-dev/eta/compare/v1.12.3...v2.0.0)

---
updated-dependencies:
- dependency-name: eta
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 10:40:40 +11:00
dependabot[bot]
f763dbd8b9 Bump cookiejar from 2.1.2 to 2.1.4 (#130)
Bumps [cookiejar](https://github.com/bmeck/node-cookiejar) from 2.1.2 to 2.1.4.
- [Release notes](https://github.com/bmeck/node-cookiejar/releases)
- [Commits](https://github.com/bmeck/node-cookiejar/commits)

---
updated-dependencies:
- dependency-name: cookiejar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 10:40:25 +11:00
dependabot[bot]
2d3e5dc635 Bump json5 from 2.2.0 to 2.2.3 (#126) 2023-03-06 08:10:21 +11:00
dependabot[bot]
6091308266 Bump jsonwebtoken from 8.5.1 to 9.0.0 (#125) 2023-03-06 08:10:14 +11:00
dependabot[bot]
fed6e9663d Bump express from 4.17.1 to 4.17.3 (#124) 2023-03-06 08:10:01 +11:00
dependabot[bot]
03b5b04c73 Bump minimatch from 3.0.4 to 3.1.2 (#120) 2023-03-06 07:54:15 +11:00
simojenki
4a529b46e1 Fix incorrect boolean usage with docker-compose, had to quote the "true" 2022-11-14 00:34:04 +00:00
simojenki
5c9fbede7a Add devcontainer for building bonob 2022-11-14 00:33:35 +00:00
dependabot[bot]
94e25e03ea Bump follow-redirects from 1.14.3 to 1.15.2 (#119)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.3 to 1.15.2.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.3...v1.15.2)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-20 19:34:27 +11:00
dependabot[bot]
d9c3a3edcb Bump jpeg-js from 0.4.3 to 0.4.4 (#118)
Bumps [jpeg-js](https://github.com/eugeneware/jpeg-js) from 0.4.3 to 0.4.4.
- [Release notes](https://github.com/eugeneware/jpeg-js/releases)
- [Commits](https://github.com/eugeneware/jpeg-js/compare/v0.4.3...v0.4.4)

---
updated-dependencies:
- dependency-name: jpeg-js
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-20 19:34:17 +11:00
dependabot[bot]
f22b094d83 Bump minimist from 1.2.5 to 1.2.7 (#117)
Bumps [minimist](https://github.com/minimistjs/minimist) from 1.2.5 to 1.2.7.
- [Release notes](https://github.com/minimistjs/minimist/releases)
- [Changelog](https://github.com/minimistjs/minimist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/minimistjs/minimist/compare/v1.2.5...v1.2.7)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-20 19:34:06 +11:00
dependabot[bot]
4ae71675e8 Bump async from 3.2.0 to 3.2.4 (#116)
Bumps [async](https://github.com/caolan/async) from 3.2.0 to 3.2.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/master/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v3.2.0...v3.2.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-20 19:33:53 +11:00
simojenki
84866dfd60 Trying to make server tests more stable 2022-10-20 16:35:18 +11:00
simojenki
719fd998b1 Set jest timeout globally for all tests as tests break in GH actions due to timeout 2022-10-20 13:29:37 +11:00
dependabot[bot]
91995678a4 Bump tar from 6.1.8 to 6.1.11 (#115) 2022-10-18 09:06:15 +11:00
dependabot[bot]
67d6c4a730 Bump node-fetch from 2.6.1 to 2.6.7 (#114) 2022-10-18 09:05:58 +11:00
dependabot[bot]
3df4f4daa7 Bump nth-check from 2.0.0 to 2.1.1 (#113) 2022-10-18 09:05:19 +11:00
dependabot[bot]
bd63408ec3 Bump tmpl from 1.0.4 to 1.0.5 (#112) 2022-10-18 09:04:50 +11:00
dependabot[bot]
da5491b474 Bump sharp from 0.29.1 to 0.30.5 (#106) 2022-10-18 09:04:27 +11:00
dependabot[bot]
bbd676b5b8 Bump @xmldom/xmldom from 0.7.4 to 0.7.6 (#111)
Bumps [@xmldom/xmldom](https://github.com/xmldom/xmldom) from 0.7.4 to 0.7.6.
- [Release notes](https://github.com/xmldom/xmldom/releases)
- [Changelog](https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md)
- [Commits](https://github.com/xmldom/xmldom/compare/0.7.4...0.7.6)

---
updated-dependencies:
- dependency-name: "@xmldom/xmldom"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-18 08:03:05 +11:00
simojenki
d01c747c96 handling SIGTERM 2022-07-30 17:28:30 +10:00
25 changed files with 152379 additions and 8361 deletions

16
.devcontainer/Dockerfile Normal file
View File

@@ -0,0 +1,16 @@
FROM node:16-bullseye
LABEL maintainer=simojenki
ENV JEST_TIMEOUT=60000
EXPOSE 4534
RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install --no-install-recommends \
libvips-dev \
python3 \
make \
git \
g++ \
vim

View File

@@ -0,0 +1,19 @@
{
"name": "bonob",
"build": {
"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",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:1": {
"version": "latest",
"moby": true
}
}
}

6
.dockerignore Normal file
View File

@@ -0,0 +1,6 @@
.devcontainer
.github
.yarn/cache
.yarn/install-state.gz
build
node_modules

View File

@@ -17,9 +17,9 @@ jobs:
steps: steps:
- -
name: Check out the repo name: Check out the repo
uses: actions/checkout@v2 uses: actions/checkout@v3
- -
uses: actions/setup-node@v1 uses: actions/setup-node@v3
with: with:
node-version: '16' node-version: '16'
- -
@@ -29,37 +29,47 @@ jobs:
push_to_registry: push_to_registry:
name: Push Docker image to Docker Hub name: Push Docker image to Docker registries
needs: build_and_test needs: build_and_test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- -
name: Check out the repo name: Check out the repo
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v2
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v2
- -
name: Docker meta name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v3 uses: docker/metadata-action@v4
with: with:
images: simojenki/bonob images: |
simojenki/bonob
ghcr.io/simojenki/bonob
- -
name: Login to DockerHub name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v1 uses: docker/login-action@v2
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Push to Docker Hub name: Log in to GitHub Container registry
uses: docker/build-push-action@v2 if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Push image
uses: docker/build-push-action@v4
with: with:
context: . context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64 platforms: linux/amd64,linux/arm/v7,linux/arm64

147529
.yarn/releases/yarn-1.22.19.cjs vendored Executable file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,3 @@
nodeLinker: node-modules nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-berry.cjs yarnPath: .yarn/releases/yarn-1.22.19.cjs

View File

@@ -1,4 +1,4 @@
FROM node:16-bullseye as build FROM node:16-bullseye-slim as build
WORKDIR /bonob WORKDIR /bonob
@@ -16,7 +16,7 @@ COPY yarn.lock .
COPY .yarnrc.yml . COPY .yarnrc.yml .
COPY .yarn/releases ./.yarn/releases COPY .yarn/releases ./.yarn/releases
ENV JEST_TIMEOUT=30000 ENV JEST_TIMEOUT=60000
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \ RUN apt-get update && \
@@ -29,13 +29,29 @@ RUN apt-get update && \
g++ && \ g++ && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \
yarn install --immutable && \ yarn config set network-timeout 600000 -g && \
yarn gitinfo && \ yarn install \
--prefer-offline \
--frozen-lockfile \
--non-interactive \
--production=false && \
yarn test --no-cache && \ yarn test --no-cache && \
yarn build yarn gitinfo && \
yarn build && \
rm -Rf node_modules && \
NODE_ENV=production yarn install \
--prefer-offline \
--pure-lockfile \
--non-interactive \
--production=true
FROM node:16-bullseye FROM node:16-bullseye-slim
LABEL maintainer="simojenki" \
org.opencontainers.image.source="https://github.com/simojenki/bonob" \
org.opencontainers.image.description="bonob SONOS SMAPI implementation" \
org.opencontainers.image.licenses="GPLv3"
ENV BNB_PORT=4534 ENV BNB_PORT=4534
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
@@ -56,7 +72,10 @@ COPY src/Sonoswsdl-1.19.4-20190411.142401-3.wsdl ./src/Sonoswsdl-1.19.4-20190411
RUN apt-get update && \ RUN apt-get update && \
apt-get -y upgrade && \ apt-get -y upgrade && \
apt-get -y install --no-install-recommends libvips tzdata && \ apt-get -y install --no-install-recommends \
libvips \
tzdata \
wget && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*

View File

@@ -16,7 +16,7 @@ Support for Subsonic API clones (tested against Navidrome and Gonic).
- Search by Album, Artist, Track - Search by Album, Artist, Track
- Playlist editing through sonos app. - Playlist editing through sonos app.
- Marking of songs as favourites and with ratings through the sonos app. - Marking of songs as favourites and with ratings through the sonos app.
- Localization (only en-US & nl-NL supported currently, require translations for other languages). [Sonos localization and supported languages](https://developer.sonos.com/build/content-service-add-features/strings-and-localization/) - Localization (only en-US, da-DK & nl-NL supported currently, require translations for other languages). [Sonos localization and supported languages](https://developer.sonos.com/build/content-service-add-features/strings-and-localization/)
- Auto discovery of sonos devices - Auto discovery of sonos devices
- Discovery of sonos devices using seed IP address - Discovery of sonos devices using seed IP address
- Auto registration with sonos on start - Auto registration with sonos on start
@@ -25,7 +25,23 @@ Support for Subsonic API clones (tested against Navidrome and Gonic).
## Running ## Running
bonob is distributed via docker and can be run in a number of ways bonob is packaged as an OCI image to both the docker hub registry and github registry.
ie.
```bash
docker pull docker.io/simojenki/bonob
```
or
```bash
docker pull ghcr.io/simojenki/bonob
```
tag | description
--- | ---
latest | Latest release, intended to be stable
master | Laster build from master, probably works, however is currently under test in
vX.Y.Z | Fixed release versions from tags, for those that want to pin to specific release
### Full sonos device auto-discovery and auto-registration using docker --network host ### Full sonos device auto-discovery and auto-registration using docker --network host
@@ -126,8 +142,8 @@ services:
# ip address of your machine running bonob # ip address of your machine running bonob
BNB_URL: http://192.168.1.111:4534 BNB_URL: http://192.168.1.111:4534
BNB_SECRET: changeme BNB_SECRET: changeme
BNB_SONOS_AUTO_REGISTER: true BNB_SONOS_AUTO_REGISTER: "true"
BNB_SONOS_DEVICE_DISCOVERY: true BNB_SONOS_DEVICE_DISCOVERY: "true"
BNB_SONOS_SERVICE_ID: 246 BNB_SONOS_SERVICE_ID: 246
# ip address of one of your sonos devices # ip address of one of your sonos devices
BNB_SONOS_SEED_HOST: 192.168.1.121 BNB_SONOS_SEED_HOST: 192.168.1.121
@@ -146,6 +162,9 @@ BNB_PORT | 4534 | Default http port for bonob to listen on
BNB_URL | http://$(hostname):4534 | URL (including path) for bonob so that sonos devices can communicate. **This must be either the public IP or DNS entry of the bonob instance so that the sonos devices can communicate with it.** BNB_URL | http://$(hostname):4534 | URL (including path) for bonob so that sonos devices can communicate. **This must be either the public IP or DNS entry of the bonob instance so that the sonos devices can communicate with it.**
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_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_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.
BNB_SONOS_SEED_HOST | undefined | sonos device seed host for discovery, or ommitted for for auto-discovery BNB_SONOS_SEED_HOST | undefined | sonos device seed host for discovery, or ommitted for for auto-discovery
@@ -153,7 +172,7 @@ BNB_SONOS_SERVICE_NAME | bonob | service name for sonos
BNB_SONOS_SERVICE_ID | 246 | service id for sonos BNB_SONOS_SERVICE_ID | 246 | service id for sonos
BNB_SUBSONIC_URL | http://$(hostname):4533 | URL for subsonic clone BNB_SUBSONIC_URL | http://$(hostname):4533 | URL for subsonic clone
BNB_SUBSONIC_CUSTOM_CLIENTS | undefined | Comma delimeted mime types for custom subsonic clients when streaming. ie. "audio/flac,audio/ogg" would use client = 'bonob+audio/flac' for flacs, and 'bonob+audio/ogg' for oggs. BNB_SUBSONIC_CUSTOM_CLIENTS | undefined | Comma delimeted mime types for custom subsonic clients when streaming. ie. "audio/flac,audio/ogg" would use client = 'bonob+audio/flac' for flacs, and 'bonob+audio/ogg' for oggs.
BNB_SUBSONIC_ARTIST_IMAGE_CACHE | undefined | Path for caching of artist images as are sourced externally. ie. Navidrome provides spotify URLs BNB_SUBSONIC_ARTIST_IMAGE_CACHE | undefined | Path for caching of artist images that are sourced externally. ie. Navidrome provides spotify URLs. Remember to provide a volume-mapping for Docker, when enabling this cache.
BNB_SCROBBLE_TRACKS | true | Whether to scrobble the playing of a track if it has been played for >30s BNB_SCROBBLE_TRACKS | true | Whether to scrobble the playing of a track if it has been played for >30s
BNB_REPORT_NOW_PLAYING | true | Whether to report a track as now playing BNB_REPORT_NOW_PLAYING | true | Whether to report a track as now playing
BNB_ICON_FOREGROUND_COLOR | undefined | Icon foreground color in sonos app, must be a valid [svg color](https://www.december.com/html/spec/colorsvg.html) BNB_ICON_FOREGROUND_COLOR | undefined | Icon foreground color in sonos app, must be a valid [svg color](https://www.december.com/html/spec/colorsvg.html)
@@ -188,6 +207,12 @@ Generally speaking you will not need to do this very often. However on occassio
Service should now be registered and everything should work as expected. Service should now be registered and everything should work as expected.
## Multiple registrations within a single household.
It's possible to register multiple Subsonic clone users for the bonob service in Sonos.
Basically this consist of repeating the Sonos app ["Add a service"](#initialising-service-within-sonos-app) steps for each additional user.
Afterwards the Sonos app displays a dropdown underneath the service, allowing to switch between users.
## Implementing a different music source other than a subsonic clone ## Implementing a different music source other than a subsonic clone
- Implement the MusicService/MusicLibrary interface - Implement the MusicService/MusicLibrary interface

View File

@@ -27,8 +27,8 @@ services:
BNB_URL: http://192.168.1.111:4534 BNB_URL: http://192.168.1.111:4534
BNB_SECRET: changeme BNB_SECRET: changeme
BNB_SONOS_SERVICE_ID: 246 BNB_SONOS_SERVICE_ID: 246
BNB_SONOS_AUTO_REGISTER: true BNB_SONOS_AUTO_REGISTER: "true"
BNB_SONOS_DEVICE_DISCOVERY: true BNB_SONOS_DEVICE_DISCOVERY: "true"
# ip address of one of your sonos devices # ip address of one of your sonos devices
BNB_SONOS_SEED_HOST: 192.168.1.121 BNB_SONOS_SEED_HOST: 192.168.1.121
BNB_SUBSONIC_URL: http://navidrome:4533 BNB_SUBSONIC_URL: http://navidrome:4533

View File

@@ -5,5 +5,6 @@ module.exports = {
modulePathIgnorePatterns: [ modulePathIgnorePatterns: [
'<rootDir>/node_modules', '<rootDir>/node_modules',
'<rootDir>/build', '<rootDir>/build',
], ],
testTimeout: Number.parseInt(process.env["JEST_TIMEOUT"] || "5000")
}; };

View File

@@ -6,64 +6,67 @@
"author": "simojenki <simojenki@users.noreply.github.com>", "author": "simojenki <simojenki@users.noreply.github.com>",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"dependencies": { "dependencies": {
"@svrooij/sonos": "^2.4.0", "@svrooij/sonos": "^2.5.0",
"@types/express": "^4.17.13", "@types/express": "^4.17.17",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^11.0.1",
"@types/jsonwebtoken": "^8.5.5", "@types/jsonwebtoken": "^9.0.1",
"@types/jws": "^3.2.4", "@types/jws": "^3.2.5",
"@types/morgan": "^1.9.3", "@types/morgan": "^1.9.4",
"@types/node": "^16.7.13", "@types/node": "^16.11.7",
"@types/randomstring": "^1.1.8", "@types/randomstring": "^1.1.8",
"@types/sharp": "^0.28.6", "@types/sharp": "^0.31.1",
"@types/underscore": "^1.11.3", "@types/underscore": "^1.11.4",
"@types/uuid": "^8.3.1", "@types/uuid": "^9.0.1",
"axios": "^0.21.4", "@types/xmldom": "0.1.31",
"dayjs": "^1.10.6", "axios": "^1.3.4",
"eta": "^1.12.3", "dayjs": "^1.11.7",
"express": "^4.17.1", "eta": "^2.0.1",
"fp-ts": "^2.11.1", "express": "^4.18.2",
"fs-extra": "^10.0.0", "fp-ts": "^2.13.1",
"jsonwebtoken": "^8.5.1", "fs-extra": "^11.1.0",
"jsonwebtoken": "^9.0.0",
"jws": "^4.0.0", "jws": "^4.0.0",
"libxmljs2": "^0.28.0", "libxmljs2": "^0.31.0",
"morgan": "^1.10.0", "morgan": "^1.10.0",
"node-html-parser": "^4.1.4", "node-html-parser": "^6.1.5",
"randomstring": "^1.2.1", "randomstring": "^1.2.3",
"sharp": "^0.29.1", "sharp": "^0.31.3",
"soap": "^0.42.0", "soap": "^1.0.0",
"ts-md5": "^1.2.9", "ts-md5": "^1.3.1",
"typescript": "^4.4.2", "typescript": "^4.9.5",
"underscore": "^1.13.1", "underscore": "^1.13.6",
"urn-lib": "^2.0.0", "urn-lib": "^2.0.0",
"uuid": "^8.3.2", "uuid": "^9.0.0",
"winston": "^3.3.3" "winston": "^3.8.2",
"xmldom-ts": "^0.3.1"
}, },
"devDependencies": { "devDependencies": {
"@types/chai": "^4.2.21", "@types/chai": "^4.3.4",
"@types/jest": "^27.0.1", "@types/jest": "^29.4.0",
"@types/mocha": "^9.0.0", "@types/mocha": "^10.0.1",
"@types/supertest": "^2.0.11", "@types/supertest": "^2.0.12",
"@types/tmp": "^0.2.1", "@types/tmp": "^0.2.3",
"chai": "^4.3.4", "chai": "^4.3.7",
"get-port": "^5.1.1", "get-port": "^6.1.2",
"image-js": "^0.33.0", "image-js": "^0.35.3",
"jest": "^27.1.0", "jest": "^29.4.3",
"nodemon": "^2.0.12", "nodemon": "^2.0.21",
"supertest": "^6.1.6", "supertest": "^6.3.3",
"tmp": "^0.2.1", "tmp": "^0.2.1",
"ts-jest": "^27.0.5", "ts-jest": "^29.0.5",
"ts-mockito": "^2.6.1", "ts-mockito": "^2.6.1",
"ts-node": "^10.2.1", "ts-node": "^10.9.1",
"xmldom-ts": "^0.3.1", "xmldom-ts": "^0.3.1",
"xpath-ts": "^1.3.13" "xpath-ts": "^1.3.13"
}, },
"scripts": { "scripts": {
"clean": "rm -Rf build node_modules", "clean": "rm -Rf build node_modules",
"build": "tsc", "build": "tsc",
"dev": "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_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"
} },
"packageManager": "yarn@1.22.19"
} }

View File

@@ -88,14 +88,14 @@ const app = server(
clock, clock,
iconColors: config.icons, iconColors: config.icons,
applyContextPath: true, applyContextPath: true,
logRequests: true, logRequests: config.logRequests,
version, version,
smapiAuthTokens: new JWTSmapiLoginTokens(clock, config.secret, config.authTimeout), smapiAuthTokens: new JWTSmapiLoginTokens(clock, config.secret, config.authTimeout),
externalImageResolver: artistImageFetcher externalImageResolver: artistImageFetcher
} }
); );
app.listen(config.port, () => { const expressServer = app.listen(config.port, () => {
logger.info(`Listening on ${config.port} available @ ${config.bonobUrl}`); logger.info(`Listening on ${config.port} available @ ${config.bonobUrl}`);
}); });
@@ -113,6 +113,15 @@ if (config.sonos.autoRegister) {
logger.info(`Found device ${d.name}(${d.group}) @ ${d.ip}:${d.port}`); logger.info(`Found device ${d.name}(${d.group}) @ ${d.ip}:${d.port}`);
}); });
}); });
} };
process.on('SIGTERM', () => {
logger.info('SIGTERM signal received: closing HTTP server');
expressServer.close(() => {
logger.info('HTTP server closed');
});
process.exit(0);
});
export default app; export default app;

View File

@@ -85,6 +85,7 @@ export default function () {
validationPattern: COLOR, validationPattern: COLOR,
}), }),
}, },
logRequests: bnbEnvVar<boolean>("SERVER_LOG_REQUESTS", { default: false, parser: asBoolean }),
sonos: { sonos: {
serviceName: bnbEnvVar<string>("SONOS_SERVICE_NAME", { default: "bonob" })!, serviceName: bnbEnvVar<string>("SONOS_SERVICE_NAME", { default: "bonob" })!,
discovery: { discovery: {

View File

@@ -4,7 +4,7 @@ import { option as O } from "fp-ts";
import _ from "underscore"; import _ from "underscore";
export type LANG = "en-US" | "da-DK" | "de-DE" | "es-ES" | "fr-FR" | "it-IT" | "ja-JP" | "nb-NO" | "nl-NL" | "pt-BR" | "sv-SE" | "zh-CN" export type LANG = "en-US" | "da-DK" | "de-DE" | "es-ES" | "fr-FR" | "it-IT" | "ja-JP" | "nb-NO" | "nl-NL" | "pt-BR" | "sv-SE" | "zh-CN"
export type SUPPORTED_LANG = "en-US" | "nl-NL"; export type SUPPORTED_LANG = "en-US" | "da-DK" | "nl-NL";
export type KEY = export type KEY =
| "AppLinkMessage" | "AppLinkMessage"
| "artists" | "artists"
@@ -88,6 +88,47 @@ const translations: Record<SUPPORTED_LANG, Record<KEY, string>> = {
LOVE: "Love", LOVE: "Love",
LOVE_SUCCESS: "Track loved" LOVE_SUCCESS: "Track loved"
}, },
"da-DK": {
AppLinkMessage: "Forbinder Sonos med $BNB_SONOS_SERVICE_NAME",
artists: "Kunstnere",
albums: "Album",
tracks: "Numre",
playlists: "Afspilningslister",
genres: "Genre",
random: "Tilfældig",
topRated: "Højst vurderet",
recentlyAdded: "Senest tilføjet",
recentlyPlayed: "Senest afspillet",
mostPlayed: "Flest afspilninger",
success: "Succes",
failure: "Fejl",
expectedConfig: "Forventet konfiguration",
existingServiceConfig: "Eksisterende tjeneste konfiguration",
noExistingServiceRegistration: "Ingen eksisterende tjeneste registrering",
register: "Registrer",
removeRegistration: "Fjern registrering",
devices: "Enheder",
services: "Tjenester",
login: "Log på",
logInToBonob: "Log på $BNB_SONOS_SERVICE_NAME",
username: "Brugernavn",
password: "Adgangskode",
successfullyRegistered: "Registreret med succes",
registrationFailed: "Registrering fejlede!",
successfullyRemovedRegistration: "Registrering fjernet med succes",
failedToRemoveRegistration: "FJernelse af registrering fejlede!",
invalidLinkCode: "Ugyldig linkCode!",
loginSuccessful: "Log på succes!",
loginFailed: "Log på fejlede!",
noSonosDevices: "Ingen Sonos enheder",
favourites: "Favoritter",
STAR: "Tilføj stjerne",
UNSTAR: "Fjern stjerne",
STAR_SUCCESS: "Stjerne tilføjet",
UNSTAR_SUCCESS: "Stjerne fjernet",
LOVE: "Synes godt om",
LOVE_SUCCESS: "Syntes godt om"
},
"nl-NL": { "nl-NL": {
AppLinkMessage: "Sonos koppelen aan $BNB_SONOS_SERVICE_NAME", AppLinkMessage: "Sonos koppelen aan $BNB_SONOS_SERVICE_NAME",
artists: "Artiesten", artists: "Artiesten",

View File

@@ -6,7 +6,7 @@ export function debugIt<T>(thing: T): T {
} }
const logger = createLogger({ const logger = createLogger({
level: 'debug', level: process.env["BNB_LOG_LEVEL"] || 'info',
format: format.combine( format: format.combine(
format.timestamp({ format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss' format: 'YYYY-MM-DD HH:mm:ss'

View File

@@ -374,7 +374,7 @@ function server(
const id = req.params["id"]!; const id = req.params["id"]!;
const trace = uuid(); const trace = uuid();
logger.info( logger.debug(
`${trace} bnb<- ${req.method} ${req.path}?${JSON.stringify( `${trace} bnb<- ${req.method} ${req.path}?${JSON.stringify(
req.query req.query
)}, headers=${JSON.stringify({ ...req.headers, "bnbt": "*****", "bnbk": "*****" })}` )}, headers=${JSON.stringify({ ...req.headers, "bnbt": "*****", "bnbk": "*****" })}`
@@ -409,7 +409,7 @@ function server(
.then((stream) => ({ musicLibrary: it, stream })) .then((stream) => ({ musicLibrary: it, stream }))
) )
.then(({ musicLibrary, stream }) => { .then(({ musicLibrary, stream }) => {
logger.info( logger.debug(
`${trace} bnb<- stream response from music service for ${id}, status=${ `${trace} bnb<- stream response from music service for ${id}, status=${
stream.status stream.status
}, headers=(${JSON.stringify(stream.headers)})` }, headers=(${JSON.stringify(stream.headers)})`
@@ -435,7 +435,7 @@ function server(
sendStream: boolean; sendStream: boolean;
nowPlaying: boolean; nowPlaying: boolean;
}) => { }) => {
logger.info( logger.debug(
`${trace} bnb-> ${ `${trace} bnb-> ${
req.path req.path
}, status=${status}, headers=${JSON.stringify(headers)}` }, status=${status}, headers=${JSON.stringify(headers)}`

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
@@ -1066,8 +1069,9 @@ function bindSmapiSoapServiceToExpress(
soapyService.log = (type, data) => { soapyService.log = (type, data) => {
switch (type) { switch (type) {
// routing all soap info messages to debug so less noisy
case "info": case "info":
logger.info({ level: "info", data }); logger.debug({ level: "info", data });
break; break;
case "warn": case "warn":
logger.warn({ level: "warn", data }); logger.warn({ level: "warn", data });

View File

@@ -2,7 +2,7 @@ import { option as O, taskEither as TE } from "fp-ts";
import * as A from "fp-ts/Array"; import * as A from "fp-ts/Array";
import { ordString } from "fp-ts/lib/Ord"; import { ordString } from "fp-ts/lib/Ord";
import { pipe } from "fp-ts/lib/function"; import { pipe } from "fp-ts/lib/function";
import { Md5 } from "ts-md5/dist/md5"; import { Md5 } from "ts-md5";
import { import {
Credentials, Credentials,
MusicService, MusicService,

View File

@@ -271,6 +271,15 @@ describe("config", () => {
}); });
}); });
describe("logRequests", () => {
describeBooleanConfigValue(
"logRequests",
"BNB_SERVER_LOG_REQUESTS",
false,
(config) => config.logRequests
);
});
describe("sonos", () => { describe("sonos", () => {
describe("serviceName", () => { describe("serviceName", () => {
it("should default to bonob", () => { it("should default to bonob", () => {

View File

@@ -34,7 +34,7 @@ describe("i8n", () => {
describe("langs", () => { describe("langs", () => {
it("should be all langs that are explicitly defined", () => { it("should be all langs that are explicitly defined", () => {
expect(langs()).toEqual(["en-US", "nl-NL"]); expect(langs()).toEqual(["en-US", "da-DK", "nl-NL"]);
}); });
}); });

View File

@@ -167,15 +167,13 @@ describe("RangeBytesFromFilter", () => {
describe("server", () => { describe("server", () => {
jest.setTimeout(Number.parseInt(process.env["JEST_TIMEOUT"] || "2000"));
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
jest.resetAllMocks(); jest.resetAllMocks();
}); });
const bonobUrlWithNoContextPath = url("http://bonob.localhost:1234"); const bonobUrlWithNoContextPath = url("http://localhost:1234");
const bonobUrlWithContextPath = url("http://bonob.localhost:1234/aContext"); const bonobUrlWithContextPath = url("http://localhost:1234/aContext");
const langName = randomLang(); const langName = randomLang();
const acceptLanguage = `le-ET,${langName};q=0.9,en;q=0.8`; const acceptLanguage = `le-ET,${langName};q=0.9,en;q=0.8`;

View File

@@ -90,8 +90,6 @@ describe("rating to and from ints", () => {
}); });
describe("service config", () => { describe("service config", () => {
jest.setTimeout(Number.parseInt(process.env["JEST_TIMEOUT"] || "2000"));
const bonobWithNoContextPath = url("http://localhost:1234"); const bonobWithNoContextPath = url("http://localhost:1234");
const bonobWithContextPath = url("http://localhost:5678/some-context-path"); const bonobWithContextPath = url("http://localhost:5678/some-context-path");
@@ -122,7 +120,7 @@ describe("service config", () => {
describe(STRINGS_ROUTE, () => { describe(STRINGS_ROUTE, () => {
it("should return xml for the strings", async () => { it("should return xml for the strings", async () => {
const xml = await fetchStringsXml(); const xml: Document = await fetchStringsXml();
const sonosString = (id: string, lang: string) => const sonosString = (id: string, lang: string) =>
xpath.select( xpath.select(
@@ -521,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)
@@ -553,6 +551,26 @@ describe("playlistAlbumArtURL", () => {
)}/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`
);
});
});
}); });
describe("when the playlist has 4 tracks from 2 different albums, including some tracks that are missing coverArt urns", () => { describe("when the playlist has 4 tracks from 2 different albums, including some tracks that are missing coverArt urns", () => {

View File

@@ -1,4 +1,4 @@
import { Md5 } from "ts-md5/dist/md5"; import { Md5 } from "ts-md5";
import { v4 as uuid } from "uuid"; import { v4 as uuid } from "uuid";
import tmp from "tmp"; import tmp from "tmp";
import fse from "fs-extra"; import fse from "fs-extra";

12161
yarn.lock

File diff suppressed because it is too large Load Diff