iobroker.spotify-connect 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Denis Haev <dogafox@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,139 @@
1
- # Temporary Holding Version
1
+ ![Logo](admin/spotify-connect.png)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # ioBroker.spotify-connect
4
+
5
+ [![Test](https://github.com/ioBroker/ioBroker.spotify-connect/actions/workflows/test.yml/badge.svg)](https://github.com/ioBroker/ioBroker.spotify-connect/actions/workflows/test.yml)
6
+
7
+ **Spotify Connect receiver for ioBroker.** The adapter appears as a speaker in the Spotify app on your phone or PC.
8
+ Whatever you play there is streamed over HTTP to any player in ioBroker that accepts a URL, for example
9
+ the satellites of ioBroker.assistant (ThirdReality Voice & Music Assistant), Dune HD players or other
10
+ devices with a `media.url` state.
11
+
12
+ It is based on [Spotify Soloist](https://developer.spotify.com/documentation/soloist), the official headless
13
+ Spotify Connect client from Spotify. It does not use reverse engineered Spotify clients.
14
+
15
+ ```
16
+ Spotify app -> Soloist -> PipeWire null sink -> HTTP stream -> media.url state -> speaker
17
+ ```
18
+
19
+ ## Requirements
20
+
21
+ - Linux on arm64 (Raspberry Pi 3/4/5), armv7 or x86_64. Debian 12/13 or Raspberry Pi OS recommended.
22
+ - A Spotify **Premium** account to create the Soloist API key. Free accounts can play on the device afterwards.
23
+ - Internet access at least every few weeks (Soloist builds expire after 90 days, see below).
24
+
25
+ Everything else is set up by the adapter:
26
+
27
+ - missing system packages (`pipewire`, `pipewire-pulse`, `wireplumber`, `pulseaudio-utils`, `ffmpeg`) are
28
+ installed with `sudo apt-get`, which standard ioBroker installations allow,
29
+ - Spotify Soloist is downloaded from Spotify's servers on first start,
30
+ - a private PipeWire instance is started for the adapter. It needs no login session and does not touch
31
+ sound cards or Bluetooth devices of the system.
32
+
33
+ ## Getting the Soloist API key
34
+
35
+ 1. Log in to the [Spotify for Developers dashboard](https://developer.spotify.com/dashboard) with your Spotify account
36
+ and accept the developer terms if asked.
37
+ 2. Open the [Spotify Soloist API Key page](https://developer.spotify.com/dashboard/soloist).
38
+ 3. Accept the Spotify terms if asked and generate the key.
39
+ 4. Copy the key (it starts with `spak_`) into the instance settings.
40
+
41
+ Do not share the key. Every user must generate an own key.
42
+
43
+ The same instructions with direct links are shown in the instance settings.
44
+
45
+ ## Configuration
46
+
47
+ | Tab | Setting | Description |
48
+ |---|---|---|
49
+ | Spotify | Soloist API key | Key from the Soloist API key page, stored encrypted |
50
+ | Spotify | Device name | Name shown in the Spotify app, e.g. "Living room" |
51
+ | Players | Players | States with role `media.url` that receive the stream URL while you play |
52
+ | Players | Stop players after pause | Seconds after a pause until the players are stopped (default 30) |
53
+ | Advanced | Address | Address the players use to reach ioBroker. Empty = detected automatically |
54
+ | Advanced | Stream port | HTTP port of the stream (default 8097) |
55
+ | Advanced | Stream format | MP3 256 kbit/s or FLAC |
56
+ | Advanced | Local Soloist API port | Port of the Soloist WebSocket API on 127.0.0.1 (default 9090). Must differ per instance |
57
+
58
+ For a ThirdReality speaker in ioBroker.assistant use
59
+ `assistant.0.satellites.<Name>.controls.linux_voice_assistant_media_player.url`.
60
+
61
+ On the first use open the Spotify app, tap the device icon and select the device name. This logs Soloist into
62
+ your account. The login is stored and survives restarts.
63
+
64
+ Several rooms: create one instance per Spotify Connect device, each with its own device name, stream port and API port.
65
+
66
+ ## States
67
+
68
+ | State | Description |
69
+ |---|---|
70
+ | `info.connection` | Soloist runs and is logged in to Spotify |
71
+ | `info.loggedIn`, `info.active` | Logged in / this is the active Spotify Connect device |
72
+ | `info.soloistVersion`, `info.buildDate`, `info.expiresInDays` | Installed Soloist build and remaining lifetime |
73
+ | `info.lastUpdateCheck`, `info.updateError` | Result of the last update check |
74
+ | `player.status` | `idle`, `playing`, `paused` or `buffering` |
75
+ | `player.title`, `player.artist`, `player.album`, `player.cover` | Current track |
76
+ | `player.duration`, `player.elapsed` | Duration and position in seconds |
77
+ | `player.context`, `player.uri` | Playlist or album, Spotify URI of the track |
78
+ | `player.shuffle`, `player.repeat` | Playback options |
79
+ | `control.play`, `control.pause`, `control.next`, `control.previous` | Buttons |
80
+ | `control.volume` | Volume 0 to 100 |
81
+ | `control.seek` | Jump to position (seconds) |
82
+ | `control.shuffle`, `control.repeat` | Shuffle on/off, repeat `off`, `context` or `track` |
83
+ | `control.playUri` | Play a Spotify URI (track, album, playlist, episode) |
84
+ | `control.activate` | Make this the active device |
85
+ | `stream.url`, `stream.clients` | Stream URL and number of connected players |
86
+
87
+ ## Soloist updates
88
+
89
+ Spotify Soloist builds stop working 90 days after their build date. The adapter takes care of it:
90
+
91
+ - it checks Spotify's download server daily, every 6 hours when less than 30 days are left,
92
+ - a new build is downloaded, tested and installed; the old binary is kept as `soloist.bak`,
93
+ - Soloist is restarted with the new build when nothing is playing, at the latest 3 days before expiry,
94
+ - if a build has expired (exit code 10), a new one is downloaded immediately,
95
+ - if updates fail, for example without internet, an ioBroker notification is shown.
96
+
97
+ Spotify does not allow redistributing Soloist, so the adapter never ships the binary. It always downloads it from
98
+ Spotify's official download server on your device.
99
+
100
+ ## Notes
101
+
102
+ - Soloist accepts the API key only as a command line argument, so local users of the system can see it in the
103
+ process list.
104
+ - The players are not synchronized with each other. For synchronized multiroom audio a different protocol is needed.
105
+ - By using Spotify Soloist you accept the [Spotify Terms and Conditions of Use](https://www.spotify.com/legal/end-user-agreement/).
106
+ - Spotify is a trademark of Spotify AB. This adapter is not affiliated with or endorsed by Spotify.
107
+
108
+ ## Changelog
109
+
110
+ <!--
111
+ Placeholder for the next version (at the beginning of the line):
112
+ ### **WORK IN PROGRESS**
113
+ -->
114
+ ### 0.1.0 (2026-11-07)
115
+ - (Denis) initial release: Spotify Connect receiver based on Spotify Soloist with automatic installation and updates
116
+
117
+ ## License
118
+
119
+ MIT License
120
+
121
+ Copyright (c) 2026 Denis Haev <dogafox@gmail.com>
122
+
123
+ Permission is hereby granted, free of charge, to any person obtaining a copy
124
+ of this software and associated documentation files (the "Software"), to deal
125
+ in the Software without restriction, including without limitation the rights
126
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
127
+ copies of the Software, and to permit persons to whom the Software is
128
+ furnished to do so, subject to the following conditions:
129
+
130
+ The above copyright notice and this permission notice shall be included in all
131
+ copies or substantial portions of the Software.
132
+
133
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
134
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
135
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
136
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
137
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
138
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
139
+ SOFTWARE.
@@ -0,0 +1,255 @@
1
+ {
2
+ "type": "tabs",
3
+ "i18n": false,
4
+ "items": {
5
+ "_spotify": {
6
+ "type": "panel",
7
+ "label": {
8
+ "en": "Spotify",
9
+ "de": "Spotify",
10
+ "ru": "Spotify"
11
+ },
12
+ "items": {
13
+ "_howtoHeader": {
14
+ "type": "header",
15
+ "size": 4,
16
+ "text": {
17
+ "en": "How to get the Soloist API key",
18
+ "de": "So bekommen Sie den Soloist-API-Key",
19
+ "ru": "Как получить API-ключ Soloist"
20
+ },
21
+ "sm": 12
22
+ },
23
+ "_howto": {
24
+ "type": "staticText",
25
+ "sm": 12,
26
+ "text": {
27
+ "en": "This adapter uses Spotify Soloist, the official Spotify Connect receiver from Spotify. Soloist needs a personal API key.<br><br><b>1.</b> You need a Spotify <b>Premium</b> account to create the key. Later, Free accounts can also play on the device.<br><b>2.</b> Open the Spotify for Developers dashboard (first button below) and log in with your normal Spotify account. On the first visit accept the developer terms.<br><b>3.</b> Open the page <b>Spotify Soloist API Key</b> (second button below).<br><b>4.</b> Accept the Spotify terms if asked and generate the key.<br><b>5.</b> Copy the key. It starts with <code>spak_</code>. Paste it into the field below. Do not share it: every user needs an own key.<br><b>6.</b> Save. The adapter downloads Soloist and all required system packages by itself and keeps Soloist up to date (Spotify builds expire after 90 days).<br><b>7.</b> Open the Spotify app on your phone or PC in the same network, tap the device icon and select the device name entered below. The first time, this logs Soloist into your account.",
28
+ "de": "Dieser Adapter nutzt Spotify Soloist, den offiziellen Spotify-Connect-Empfänger von Spotify. Soloist braucht einen persönlichen API-Key.<br><br><b>1.</b> Zum Erzeugen des Keys brauchen Sie ein Spotify-<b>Premium</b>-Konto. Abspielen können später auch Free-Konten.<br><b>2.</b> Öffnen Sie das Spotify-for-Developers-Dashboard (erster Button unten) und melden Sie sich mit Ihrem normalen Spotify-Konto an. Beim ersten Besuch die Entwickler-Bedingungen akzeptieren.<br><b>3.</b> Öffnen Sie die Seite <b>Spotify Soloist API Key</b> (zweiter Button unten).<br><b>4.</b> Bestätigen Sie die Spotify-Bedingungen, falls danach gefragt wird, und erzeugen Sie den Key.<br><b>5.</b> Kopieren Sie den Key. Er beginnt mit <code>spak_</code>. Fügen Sie ihn unten ein. Bitte nicht weitergeben: Jeder Nutzer braucht einen eigenen Key.<br><b>6.</b> Speichern. Der Adapter lädt Soloist und alle nötigen Systempakete selbst und hält Soloist aktuell (Spotify-Builds laufen nach 90 Tagen ab).<br><b>7.</b> Öffnen Sie die Spotify-App auf Handy oder PC im selben Netz, tippen Sie auf das Geräte-Symbol und wählen Sie den unten eingetragenen Gerätenamen. Beim ersten Mal meldet sich Soloist dabei mit Ihrem Konto an.",
29
+ "ru": "Адаптер использует Spotify Soloist, официальный приёмник Spotify Connect от Spotify. Для Soloist нужен личный API-ключ.<br><br><b>1.</b> Для создания ключа нужен аккаунт Spotify <b>Premium</b>. Воспроизводить потом могут и бесплатные аккаунты.<br><b>2.</b> Откройте Spotify for Developers Dashboard (первая кнопка ниже) и войдите со своим обычным аккаунтом Spotify. При первом входе примите условия для разработчиков.<br><b>3.</b> Откройте страницу <b>Spotify Soloist API Key</b> (вторая кнопка ниже).<br><b>4.</b> Если потребуется, примите условия Spotify и создайте ключ.<br><b>5.</b> Скопируйте ключ. Он начинается с <code>spak_</code>. Вставьте его в поле ниже. Не передавайте его другим: каждому пользователю нужен свой ключ.<br><b>6.</b> Сохраните. Адаптер сам загрузит Soloist и все нужные системные пакеты и будет обновлять Soloist (сборки Spotify действуют 90 дней).<br><b>7.</b> Откройте приложение Spotify на телефоне или ПК в той же сети, нажмите на значок устройств и выберите указанное ниже имя устройства. В первый раз Soloist при этом войдёт в ваш аккаунт."
30
+ }
31
+ },
32
+ "_linkDashboard": {
33
+ "type": "staticLink",
34
+ "button": true,
35
+ "variant": "outlined",
36
+ "href": "https://developer.spotify.com/dashboard",
37
+ "label": {
38
+ "en": "1. Open Spotify for Developers",
39
+ "de": "1. Spotify for Developers öffnen",
40
+ "ru": "1. Открыть Spotify for Developers"
41
+ },
42
+ "sm": 12,
43
+ "md": 6,
44
+ "lg": 4,
45
+ "newLine": true
46
+ },
47
+ "_linkSoloist": {
48
+ "type": "staticLink",
49
+ "button": true,
50
+ "variant": "contained",
51
+ "href": "https://developer.spotify.com/dashboard/soloist",
52
+ "label": {
53
+ "en": "2. Create Soloist API key",
54
+ "de": "2. Soloist-API-Key erzeugen",
55
+ "ru": "2. Создать API-ключ Soloist"
56
+ },
57
+ "sm": 12,
58
+ "md": 6,
59
+ "lg": 4
60
+ },
61
+ "apiKey": {
62
+ "type": "password",
63
+ "repeat": false,
64
+ "visible": true,
65
+ "label": {
66
+ "en": "Soloist API key",
67
+ "de": "Soloist-API-Key",
68
+ "ru": "API-ключ Soloist"
69
+ },
70
+ "help": {
71
+ "en": "Starts with spak_",
72
+ "de": "Beginnt mit spak_",
73
+ "ru": "Начинается с spak_"
74
+ },
75
+ "validator": "!data.apiKey || data.apiKey.startsWith('spak_')",
76
+ "validatorErrorText": "Key must start with spak_ / Key muss mit spak_ beginnen",
77
+ "validatorNoSaveOnError": true,
78
+ "sm": 12,
79
+ "md": 6,
80
+ "lg": 4,
81
+ "newLine": true
82
+ },
83
+ "deviceName": {
84
+ "type": "text",
85
+ "label": {
86
+ "en": "Device name in the Spotify app",
87
+ "de": "Gerätename in der Spotify-App",
88
+ "ru": "Имя устройства в приложении Spotify"
89
+ },
90
+ "help": {
91
+ "en": "e.g. Living room",
92
+ "de": "z. B. Wohnzimmer",
93
+ "ru": "например, Гостиная"
94
+ },
95
+ "sm": 12,
96
+ "md": 6,
97
+ "lg": 4
98
+ },
99
+ "_linkDocs": {
100
+ "type": "staticLink",
101
+ "href": "https://developer.spotify.com/documentation/soloist",
102
+ "label": {
103
+ "en": "Spotify Soloist documentation",
104
+ "de": "Dokumentation von Spotify Soloist",
105
+ "ru": "Документация Spotify Soloist"
106
+ },
107
+ "sm": 12,
108
+ "newLine": true
109
+ }
110
+ }
111
+ },
112
+ "_players": {
113
+ "type": "panel",
114
+ "label": {
115
+ "en": "Players",
116
+ "de": "Player",
117
+ "ru": "Плееры"
118
+ },
119
+ "items": {
120
+ "_playersInfo": {
121
+ "type": "staticText",
122
+ "sm": 12,
123
+ "text": {
124
+ "en": "When you play on this device in the Spotify app, the adapter writes the stream URL into these states. Any state with role <code>media.url</code> works, e.g. for a ThirdReality speaker in ioBroker.assistant: <code>assistant.0.satellites.&lt;Name&gt;.controls.linux_voice_assistant_media_player.url</code>. After a pause the players are stopped again.",
125
+ "de": "Sobald Sie in der Spotify-App auf diesem Gerät abspielen, schreibt der Adapter die Stream-URL in diese States. Es geht jeder State mit der Rolle <code>media.url</code>, z. B. für einen ThirdReality-Speaker in ioBroker.assistant: <code>assistant.0.satellites.&lt;Name&gt;.controls.linux_voice_assistant_media_player.url</code>. Nach einer Pause werden die Player wieder gestoppt.",
126
+ "ru": "Когда вы включаете воспроизведение на этом устройстве в приложении Spotify, адаптер записывает URL потока в эти состояния. Подходит любое состояние с ролью <code>media.url</code>, например для колонки ThirdReality в ioBroker.assistant: <code>assistant.0.satellites.&lt;Name&gt;.controls.linux_voice_assistant_media_player.url</code>. После паузы плееры снова останавливаются."
127
+ }
128
+ },
129
+ "targets": {
130
+ "type": "table",
131
+ "sm": 12,
132
+ "noDelete": false,
133
+ "items": [
134
+ {
135
+ "type": "checkbox",
136
+ "attr": "enabled",
137
+ "title": {
138
+ "en": "Active",
139
+ "de": "Aktiv",
140
+ "ru": "Вкл."
141
+ },
142
+ "width": 80,
143
+ "default": true
144
+ },
145
+ {
146
+ "type": "objectId",
147
+ "attr": "id",
148
+ "title": {
149
+ "en": "media.url state",
150
+ "de": "media.url-State",
151
+ "ru": "Состояние media.url"
152
+ },
153
+ "types": "state",
154
+ "customFilter": {
155
+ "common": {
156
+ "role": "media.url"
157
+ }
158
+ }
159
+ }
160
+ ]
161
+ },
162
+ "stopAfterSec": {
163
+ "type": "number",
164
+ "min": 0,
165
+ "label": {
166
+ "en": "Stop players after pause (seconds)",
167
+ "de": "Player nach Pause stoppen (Sekunden)",
168
+ "ru": "Остановить плееры после паузы (секунды)"
169
+ },
170
+ "sm": 12,
171
+ "md": 6,
172
+ "lg": 4,
173
+ "newLine": true
174
+ }
175
+ }
176
+ },
177
+ "_advanced": {
178
+ "type": "panel",
179
+ "label": {
180
+ "en": "Advanced",
181
+ "de": "Erweitert",
182
+ "ru": "Дополнительно"
183
+ },
184
+ "items": {
185
+ "streamHost": {
186
+ "type": "ip",
187
+ "listenOnAllPorts": false,
188
+ "onlyIp4": true,
189
+ "label": {
190
+ "en": "Address the players use to reach ioBroker",
191
+ "de": "Adresse, unter der die Player ioBroker erreichen",
192
+ "ru": "Адрес, по которому плееры видят ioBroker"
193
+ },
194
+ "help": {
195
+ "en": "Empty = detect automatically",
196
+ "de": "Leer = automatisch erkennen",
197
+ "ru": "Пусто = определить автоматически"
198
+ },
199
+ "sm": 12,
200
+ "md": 6,
201
+ "lg": 4
202
+ },
203
+ "streamPort": {
204
+ "type": "port",
205
+ "label": {
206
+ "en": "Stream port",
207
+ "de": "Stream-Port",
208
+ "ru": "Порт потока"
209
+ },
210
+ "sm": 12,
211
+ "md": 3,
212
+ "lg": 2
213
+ },
214
+ "format": {
215
+ "type": "select",
216
+ "label": {
217
+ "en": "Stream format",
218
+ "de": "Stream-Format",
219
+ "ru": "Формат потока"
220
+ },
221
+ "options": [
222
+ {
223
+ "label": "MP3 256 kbit/s",
224
+ "value": "mp3"
225
+ },
226
+ {
227
+ "label": "FLAC (lossless)",
228
+ "value": "flac"
229
+ }
230
+ ],
231
+ "sm": 12,
232
+ "md": 3,
233
+ "lg": 2
234
+ },
235
+ "apiPort": {
236
+ "type": "port",
237
+ "label": {
238
+ "en": "Local Soloist API port",
239
+ "de": "Lokaler Soloist-API-Port",
240
+ "ru": "Локальный порт API Soloist"
241
+ },
242
+ "help": {
243
+ "en": "Only on 127.0.0.1. Must differ per instance",
244
+ "de": "Nur auf 127.0.0.1. Pro Instanz verschieden",
245
+ "ru": "Только на 127.0.0.1. Для каждого экземпляра свой"
246
+ },
247
+ "sm": 12,
248
+ "md": 3,
249
+ "lg": 2,
250
+ "newLine": true
251
+ }
252
+ }
253
+ }
254
+ }
255
+ }
Binary file
@@ -0,0 +1,20 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0" stop-color="#1ed760"/>
5
+ <stop offset="1" stop-color="#1db954"/>
6
+ </linearGradient>
7
+ </defs>
8
+ <rect x="16" y="16" width="480" height="480" rx="104" fill="url(#bg)"/>
9
+ <g transform="translate(-14 0)">
10
+ <!-- speaker -->
11
+ <path d="M112 206 h56 l84 -70 v240 l-84 -70 h-56 a16 16 0 0 1 -16 -16 v-68 a16 16 0 0 1 16 -16 z"
12
+ fill="#191414" stroke="#191414" stroke-width="14" stroke-linejoin="round"/>
13
+ <!-- sound waves -->
14
+ <g fill="none" stroke="#191414" stroke-linecap="round">
15
+ <path d="M300 214 a60 60 0 0 1 0 84" stroke-width="26"/>
16
+ <path d="M338 172 a118 118 0 0 1 0 168" stroke-width="26" stroke-opacity="0.85"/>
17
+ <path d="M376 130 a176 176 0 0 1 0 252" stroke-width="26" stroke-opacity="0.65"/>
18
+ </g>
19
+ </g>
20
+ </svg>
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BUILD_LIFETIME_DAYS = void 0;
4
+ exports.soloistArch = soloistArch;
5
+ exports.soloistUrl = soloistUrl;
6
+ exports.ensureOsPackages = ensureOsPackages;
7
+ exports.parseVersion = parseVersion;
8
+ exports.getVersion = getVersion;
9
+ exports.getRemoteInfo = getRemoteInfo;
10
+ exports.downloadSoloist = downloadSoloist;
11
+ const node_fs_1 = require("node:fs");
12
+ const node_path_1 = require("node:path");
13
+ const node_stream_1 = require("node:stream");
14
+ const promises_1 = require("node:stream/promises");
15
+ const run_1 = require("./run");
16
+ /** Debian packages and the binary that proves each one is installed. */
17
+ const OS_PACKAGES = [
18
+ { pkg: 'pipewire', bin: 'pipewire' },
19
+ { pkg: 'pipewire-pulse', bin: 'pipewire-pulse' },
20
+ { pkg: 'wireplumber', bin: 'wireplumber' },
21
+ { pkg: 'pulseaudio-utils', bin: 'pactl' },
22
+ { pkg: 'ffmpeg', bin: 'ffmpeg' },
23
+ ];
24
+ const DOWNLOAD_BASE = 'https://soloist-builds.spotifycdn.com';
25
+ /** Builds are valid for 90 days after their build date (documented by Spotify). */
26
+ exports.BUILD_LIFETIME_DAYS = 90;
27
+ /** Maps Node's arch to Spotify's archive name. */
28
+ function soloistArch() {
29
+ switch (process.arch) {
30
+ case 'arm64':
31
+ return 'arm64';
32
+ case 'arm':
33
+ return 'arm32';
34
+ case 'x64':
35
+ return 'x86_64';
36
+ default:
37
+ throw new Error(`Spotify Soloist is not available for architecture "${process.arch}"`);
38
+ }
39
+ }
40
+ function soloistUrl() {
41
+ return `${DOWNLOAD_BASE}/soloist_release_${soloistArch()}.tar.gz`;
42
+ }
43
+ /**
44
+ * Installs missing Debian packages with "sudo -n apt-get". Standard ioBroker installations allow this
45
+ * without password. Returns the list of packages that are still missing.
46
+ */
47
+ async function ensureOsPackages(log) {
48
+ if (process.platform !== 'linux') {
49
+ throw new Error('This adapter currently supports Linux only');
50
+ }
51
+ const missing = [];
52
+ for (const p of OS_PACKAGES) {
53
+ if (!(await (0, run_1.hasBinary)(p.bin))) {
54
+ missing.push(p.pkg);
55
+ }
56
+ }
57
+ if (!missing.length) {
58
+ return [];
59
+ }
60
+ log.info(`Installing missing packages: ${missing.join(', ')}`);
61
+ const env = { ...process.env, DEBIAN_FRONTEND: 'noninteractive' };
62
+ let res = await (0, run_1.run)('sudo', ['-n', 'apt-get', 'install', '-y', '--no-install-recommends', ...missing], { env });
63
+ if (res.code !== 0 && /Unable to locate|has no installation candidate/i.test(res.stderr + res.stdout)) {
64
+ await (0, run_1.run)('sudo', ['-n', 'apt-get', 'update'], { env });
65
+ res = await (0, run_1.run)('sudo', ['-n', 'apt-get', 'install', '-y', '--no-install-recommends', ...missing], { env });
66
+ }
67
+ if (res.code !== 0) {
68
+ log.warn(`apt-get failed: ${(res.stderr || res.stdout).trim().split('\n').slice(-3).join(' ')}`);
69
+ }
70
+ const still = [];
71
+ for (const p of OS_PACKAGES) {
72
+ if (!(await (0, run_1.hasBinary)(p.bin))) {
73
+ still.push(p.pkg);
74
+ }
75
+ }
76
+ return still;
77
+ }
78
+ /** Parses "soloist 1.3.10.51 build 1793988108 (20261106) (g19412df6ea) (linux/aarch64)". */
79
+ function parseVersion(raw) {
80
+ const m = raw.match(/soloist\s+([\d.]+)\s+build\s+(\d+)/i);
81
+ if (!m) {
82
+ return null;
83
+ }
84
+ const buildTimestamp = parseInt(m[2], 10);
85
+ return {
86
+ version: m[1],
87
+ buildTimestamp,
88
+ expiresAt: buildTimestamp * 1000 + exports.BUILD_LIFETIME_DAYS * 24 * 3600 * 1000,
89
+ raw: raw.trim(),
90
+ };
91
+ }
92
+ async function getVersion(binary) {
93
+ if (!(0, node_fs_1.existsSync)(binary)) {
94
+ return null;
95
+ }
96
+ const res = await (0, run_1.run)(binary, ['--version'], { timeout: 15_000 });
97
+ return parseVersion(res.stdout + res.stderr);
98
+ }
99
+ async function getRemoteInfo() {
100
+ const res = await fetch(soloistUrl(), { method: 'HEAD' });
101
+ if (!res.ok) {
102
+ throw new Error(`HTTP ${res.status} for ${soloistUrl()}`);
103
+ }
104
+ return { lastModified: res.headers.get('last-modified') || '', etag: res.headers.get('etag') || '' };
105
+ }
106
+ /**
107
+ * Downloads the current Soloist build from Spotify into <dir>/soloist. The new binary is verified
108
+ * before it replaces the old one; the previous binary is kept as soloist.bak.
109
+ */
110
+ async function downloadSoloist(dir, log) {
111
+ await node_fs_1.promises.mkdir(dir, { recursive: true });
112
+ const tmp = (0, node_path_1.join)(dir, 'download');
113
+ await node_fs_1.promises.rm(tmp, { recursive: true, force: true });
114
+ await node_fs_1.promises.mkdir(tmp, { recursive: true });
115
+ const url = soloistUrl();
116
+ log.info(`Downloading Spotify Soloist from ${url}`);
117
+ const res = await fetch(url);
118
+ if (!res.ok || !res.body) {
119
+ throw new Error(`Download failed: HTTP ${res.status}`);
120
+ }
121
+ const remote = { lastModified: res.headers.get('last-modified') || '', etag: res.headers.get('etag') || '' };
122
+ const archive = (0, node_path_1.join)(tmp, 'soloist.tar.gz');
123
+ await (0, promises_1.pipeline)(node_stream_1.Readable.fromWeb(res.body), (0, node_fs_1.createWriteStream)(archive));
124
+ const tar = await (0, run_1.run)('tar', ['xzf', archive, '-C', tmp]);
125
+ if (tar.code !== 0) {
126
+ throw new Error(`Cannot unpack archive: ${tar.stderr.trim()}`);
127
+ }
128
+ const find = await (0, run_1.run)('find', [tmp, '-maxdepth', '3', '-type', 'f', '-name', 'soloist']);
129
+ const newBin = find.stdout.trim().split('\n')[0];
130
+ if (!newBin) {
131
+ throw new Error('Archive does not contain a "soloist" binary');
132
+ }
133
+ await node_fs_1.promises.chmod(newBin, 0o755);
134
+ const version = await getVersion(newBin);
135
+ if (!version) {
136
+ throw new Error('Downloaded binary does not start on this system');
137
+ }
138
+ const target = (0, node_path_1.join)(dir, 'soloist');
139
+ if ((0, node_fs_1.existsSync)(target)) {
140
+ await node_fs_1.promises.rm((0, node_path_1.join)(dir, 'soloist.bak'), { force: true });
141
+ await node_fs_1.promises.rename(target, (0, node_path_1.join)(dir, 'soloist.bak'));
142
+ }
143
+ await node_fs_1.promises.copyFile(newBin, target);
144
+ await node_fs_1.promises.chmod(target, 0o755);
145
+ await node_fs_1.promises.rm(tmp, { recursive: true, force: true });
146
+ log.info(`Spotify Soloist ${version.version} installed (build ${new Date(version.buildTimestamp * 1000).toISOString().slice(0, 10)})`);
147
+ return { version, remote };
148
+ }
149
+ //# sourceMappingURL=installer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/lib/installer.ts"],"names":[],"mappings":";;;AAiCA,kCAWC;AAED,gCAEC;AAMD,4CA8BC;AAGD,oCAYC;AAED,gCAMC;AAOD,sCAMC;AAMD,0CAyCC;AAvKD,qCAAwE;AACxE,yCAAiC;AACjC,6CAAuC;AACvC,mDAAgD;AAChD,+BAAuC;AAEvC,wEAAwE;AACxE,MAAM,WAAW,GAAmC;IAChD,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE;IACpC,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,EAAE;IAChD,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE;IAC1C,EAAE,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,OAAO,EAAE;IACzC,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE;CACnC,CAAC;AAEF,MAAM,aAAa,GAAG,uCAAuC,CAAC;AAC9D,mFAAmF;AACtE,QAAA,mBAAmB,GAAG,EAAE,CAAC;AAetC,kDAAkD;AAClD,SAAgB,WAAW;IACvB,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO;YACR,OAAO,OAAO,CAAC;QACnB,KAAK,KAAK;YACN,OAAO,OAAO,CAAC;QACnB,KAAK,KAAK;YACN,OAAO,QAAQ,CAAC;QACpB;YACI,MAAM,IAAI,KAAK,CAAC,sDAAsD,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IAC/F,CAAC;AACL,CAAC;AAED,SAAgB,UAAU;IACtB,OAAO,GAAG,aAAa,oBAAoB,WAAW,EAAE,SAAS,CAAC;AACtE,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CA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