iobroker.jellyfin 0.1.7 → 0.2.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/README.md CHANGED
@@ -11,78 +11,117 @@
11
11
 
12
12
  **🇩🇪 Deutsche Anleitung: [docs/de/README.md](docs/de/README.md)**
13
13
 
14
- See what is playing on your [Jellyfin](https://jellyfin.org) apps and control them from ioBroker – pause the movie when the doorbell rings, dim the lights when a film starts or show the cover in your visualization.
14
+ See in ioBroker what is playing on your [Jellyfin](https://jellyfin.org) apps and control them: pause the film when the doorbell rings, dim the lights when a film starts, start your music playlist from a wall panel or show the cover in your visualization.
15
15
 
16
16
  ## What you can do
17
17
 
18
- - See on every Jellyfin app (TV, phone, browser) what is playing: title, series, episode, cover, position
19
- - Start a film, a series, an episode, an album or a song by its title
20
- - Play, pause, stop, skip forward and back, jump to a position
21
- - Change the volume or mute
22
- - Show a message on the TV screen (e.g. "Someone is at the door")
23
- - Start a scan of your libraries
18
+ - **See what is playing** on every Jellyfin app (TV, phone, tablet, browser, DLNA speaker): title, series, episode, artist, cover, position
19
+ - **Control playback:** play, pause, stop, next / previous, skip, jump to a position
20
+ - **Start something:** a film, a series, an episode, an album or a song by its title – or a **playlist**, also in random order
21
+ - **Volume:** louder, quieter, mute (depends on the device, see [Which devices work how](#which-devices-work-how))
22
+ - **Messages:** show a short text on the TV screen, e.g. "Someone is at the door"
23
+ - **Server:** see the version, whether an update is waiting, and start a scan of your libraries
24
24
 
25
25
  ## What you need
26
26
 
27
- - A Jellyfin server, version 12 or newer
28
- - The Jellyfin app on the devices you want to see or control
27
+ - A Jellyfin server, **version 12 or newer**
28
+ - The Jellyfin app on the devices you want to see or control (or the Jellyfin DLNA plugin for speakers)
29
29
 
30
- ## Setup in 3 steps
30
+ ## Setup
31
31
 
32
- 1. **Create a key in Jellyfin:** open Jellyfin in the browser → **Dashboard** → **API keys** → **+**, name it `ioBroker` and copy the key.
33
- 2. **Install the adapter** in ioBroker and open the instance settings.
34
- 3. **Enter the server address** exactly as you open Jellyfin in the browser (with port, e.g. `http://192.168.1.10:8096`) and the **key**, then save.
32
+ 1. **Create a key in Jellyfin:** open Jellyfin in the browser → **Dashboard** → **API keys** → **+**, name it `ioBroker`, copy the key.
33
+ 2. **Install the adapter:** in ioBroker open **Adapters**, search for `jellyfin` and install it.
34
+ 3. **Fill in the settings** of the instance and save:
35
35
 
36
- That's it. Every Jellyfin app that is connected to the server now appears as a device below `jellyfin.0`.
36
+ | Setting | What to enter |
37
+ |---|---|
38
+ | Server address | the address you use to open Jellyfin in the browser, **with port**, e.g. `http://192.168.1.10:8096` (behind a reverse proxy also with the path, e.g. `https://example.com/jellyfin`) |
39
+ | API key | the key from step 1 |
40
+ | Only show devices that can be controlled | tick it if you only want devices that accept commands (e.g. no DLNA speakers that only show what is playing) |
41
+
42
+ That's it. Every Jellyfin app that connects to the server now appears as a device below `jellyfin.0` – named after the device, e.g. `Firefox` or `SHIELD`.
43
+
44
+ The expert mode of the settings additionally shows the update interval, the cover size and the request timeout. The defaults fit almost everyone.
37
45
 
38
- ## Using the values
46
+ ## Your devices in ioBroker
39
47
 
40
48
  Each device has three folders:
41
49
 
42
50
  | Folder | What is in it |
43
51
  |---|---|
44
- | `info` | Name of the device, app, user, whether it is connected and whether it can be controlled |
45
- | `media` | What is playing: `state` (play / pause / stop), `title`, `series`, `season`, `episode`, `cover`, `elapsed`, `duration`, and `seek`, `volume`, `mute` |
46
- | `command` | Buttons: `play`, `pause`, `playPause`, `stop`, `next`, `previous`, `forward`, `rewind`, `volumeUp`, `volumeDown`, `toggleMute`, `playTitle` and `message` |
52
+ | `info` | name, app, user, whether it is connected (`reachable`) and whether it accepts commands right now (`remoteControl`) |
53
+ | `media` | what is playing: `state` (`play` / `pause` / `stop`), `title`, `series`, `season`, `episode`, `artist`, `album`, `cover`, `elapsed`, `duration` – and the values you can change: `seek`, `volume`, `mute`, `repeat` |
54
+ | `command` | buttons (`play`, `pause`, `playPause`, `stop`, `next`, `previous`, `forward`, `rewind`, `volumeUp`, `volumeDown`, `toggleMute`) and text fields to start something (`playTitle`, `playPlaylist`, `playShuffled`) or to show a `message` |
47
55
 
48
- **Examples**
56
+ Below `jellyfin.0.server` you find the server version, whether an update or a restart is pending, how many devices are connected and playing, the list of all `playlists` and the button `refreshLibrary`.
49
57
 
50
- - **Dim the light when a film starts:** react to `jellyfin.0.<device>.media.state` changing to `play`.
51
- - **Start a film:** write its title into `jellyfin.0.<device>.command.playTitle`, e.g. `Home Alone`.
58
+ ## Everyday use
59
+
60
+ ### Automations
61
+
62
+ - **Dim the light when a film starts:** react to `jellyfin.0.<device>.media.state` changing to `play` (and back to normal on `pause` / `stop`).
52
63
  - **Pause when the doorbell rings:** set `jellyfin.0.<device>.command.pause` to `true`.
53
64
  - **Message on the TV:** write the text into `jellyfin.0.<device>.command.message`.
54
- - **Cover in VIS:** use `jellyfin.0.<device>.media.cover` as image address.
55
- - **Jump to the middle:** write `50` into `media.seek` (percent of the film).
65
+ - **Start a film:** write its title into `jellyfin.0.<device>.command.playTitle`, e.g. `Home Alone`. A series starts with its first episode.
56
66
 
57
- Below `jellyfin.0.server` you see the server version, whether an update or restart is pending, how many devices are connected and playing, and the button `refreshLibrary` to scan all libraries.
67
+ ### Music and playlists
58
68
 
59
- ## Good to know
69
+ - **Start a playlist:** choose it in `jellyfin.0.<device>.command.playPlaylist`. The field offers all playlists of your server as a list, so you can use it directly as a drop-down in VIS. Writing the name also works.
70
+ - **Random order:** write the name of a playlist, album, artist or series into `command.playShuffled`.
71
+ - Jellyfin itself sends the songs of the list to the device. This is why it also works on devices without their own playlist function, e.g. speakers connected via the Jellyfin DLNA plugin.
72
+ - A new playlist appears in the drop-down within 10 minutes – by its name you can start it right away.
60
73
 
61
- - **One device, two connections:** the Jellyfin apps for phones, tablets and TVs register twice with the server (the app and its player). The adapter combines both into one device: you see what the player shows and the commands go to the app.
62
- - **A device shows "cannot be controlled"** (`info.remoteControl` = false) although the app is open: restart the app. If that does not help, log out in the app and log in again.
63
- - **Volume** works differently on every device:
74
+ ### Remote control in VIS
64
75
 
65
- | Device | Volume value | Louder / quieter | Mute |
66
- |---|---|---|---|
67
- | Browser | ✔ | ✔ | ✔ |
68
- | TV app (Fire TV, NVIDIA SHIELD, Android TV) | ✘ only a small step | ✔ | ✔ (not when the sound goes to an AV receiver) |
69
- | Phone / tablet app | ✘ (system volume) | ✘ | ✔ |
70
-
71
- - **Android phone app:** with the integrated player (default) you see what is playing, but the app does not accept commands. Remote control works with the **web player** (app settings) – a film started from ioBroker then waits until you tap play once on the phone.
72
- - **iPad app:** works out of the box, a film started from ioBroker plays immediately.
73
- - **Messages:** TV apps hide messages with a display time after 2–3 seconds, no matter which time is set. In the browser, messages without a display time stay until they are closed.
74
- - **A device shows "not connected":** the app is closed or the device is off. As soon as the app connects again, everything updates automatically.
75
- - A command is only sent if the app accepts it at that moment. Otherwise you find a short note in the log.
76
- - **Old devices** are never deleted automatically, so you keep your scripts and VIS links when a device is off for a while. You can delete a device you no longer use in the **Objects** tab.
77
- - **Option "Only show devices that can be controlled":** new devices are only added if they accept commands. Devices that already exist stay – delete them in the **Objects** tab if you do not want them.
76
+ Most player widgets need the same few values. Use these states of your device:
77
+
78
+ | Widget field | State |
79
+ |---|---|
80
+ | Status (playing / paused) | `media.state` |
81
+ | Title / artist / album | `media.title`, `media.artist`, `media.album` |
82
+ | Cover | `media.cover` (an image address that works without login) |
83
+ | Position and length | `media.elapsed`, `media.duration` (seconds; the position counts on every second while playing) |
84
+ | Progress bar / jump | `media.seek` (percent, write to jump) |
85
+ | Buttons | `command.playPause`, `command.next`, `command.previous`, `command.stop` |
86
+ | Volume / mute | `media.volume`, `media.mute` |
87
+ | Playlist selection | `command.playPlaylist` |
88
+
89
+ ## Which devices work how
90
+
91
+ The adapter shows what the Jellyfin server reports and sends the commands to the app. What a device can do depends on the app:
92
+
93
+ | Device | Accepts commands | Status | Volume value | Louder / quieter | Mute |
94
+ |---|---|---|---|---|---|
95
+ | Browser | ✔ | ✔ | ✔ | ✔ | ✔ |
96
+ | TV app (Fire TV, NVIDIA SHIELD, Android TV) | ✔ | ✔ | ✘ only a small step | ✔ | ✔ (not when the sound goes to an AV receiver) |
97
+ | iPad app | ✔ – a started film plays at once | ✔ | ✘ | ✘ | ✔ |
98
+ | Android phone app, web player | ✔ – a started film waits until you tap play once | ✔ | ✘ | ✘ | ✔ |
99
+ | Android phone app, integrated player (default) | ✘ | ✔ | – | – | – |
100
+ | DLNA speakers (e.g. Sonos) via the Jellyfin DLNA plugin | ✔ | partly – some speakers do not report pause and mute back | ✔ | not tested yet | partly |
101
+
102
+ On the Android phone you switch to the web player in the app settings.
103
+
104
+ ## Good to know
105
+
106
+ - **One device, two connections:** the apps for phones, tablets and TVs register twice with the server (the app and its player). The adapter combines both into one device: you see what the player shows and the commands go to the app.
107
+ - **A device shows "cannot be controlled"** (`info.remoteControl` = `false`) although the app is open: restart the app. If that does not help, log out in the app and log in again. Apps on phones and tablets only accept commands while they are in the foreground.
108
+ - **A device shows "not connected":** the app is closed or the device is off. As soon as the app connects again, everything updates by itself.
109
+ - **Commands are only sent when the app accepts them** at that moment. Otherwise you find a short note in the log.
110
+ - **Messages:** TV apps hide a message with a display time after 2–3 seconds. In the browser a message without display time stays until it is closed.
111
+ - **Old devices are never deleted automatically**, so your scripts and VIS links survive when a device is off for a while. Delete devices you no longer use in the **Objects** tab. The option "Only show devices that can be controlled" also does not delete existing devices.
78
112
 
79
113
  ## Questions and problems
80
114
 
81
- - **"The Jellyfin server rejected the API key"** – check the key, or create a new one in the Jellyfin dashboard.
82
- - **"Jellyfin was not found at this address"** – check the address, port and – if Jellyfin runs behind a reverse proxy – the path (e.g. `https://example.com/jellyfin`).
83
- - **"Cannot reach the Jellyfin server"** – is the server running and reachable from the ioBroker computer?
84
- - **"Jellyfin … is not supported"** – the adapter needs Jellyfin 12 or newer, please update the server.
85
- - Something else? Please open an [issue](https://github.com/Schimi1983/ioBroker.jellyfin/issues) and add the log (log level *debug*).
115
+ | Message in the log | What to do |
116
+ |---|---|
117
+ | The Jellyfin server rejected the API key | check the key or create a new one in the Jellyfin dashboard |
118
+ | Jellyfin was not found at this address | check address and port – behind a reverse proxy also the path |
119
+ | Cannot reach the Jellyfin server | is the server running and reachable from the ioBroker computer? The adapter keeps trying and connects by itself as soon as the server is back |
120
+ | Jellyfin … is not supported | update the server to version 12 or newer |
121
+
122
+ **A value does not change although the device does what it should** (e.g. stays on `play` after pause): set the log level of the instance to *debug*. The log then shows a line `Jellyfin reports …` for every change – if the pause is missing there, the device does not report it to Jellyfin.
123
+
124
+ Something else? Please open an [issue](https://github.com/Schimi1983/ioBroker.jellyfin/issues) with the log (log level *debug*) and tell us which Jellyfin app on which device.
86
125
 
87
126
  <details>
88
127
  <summary>For advanced users</summary>
@@ -100,33 +139,45 @@ Below `jellyfin.0.server` you see the server version, whether an update or resta
100
139
  | `media.state` | string | read | `play`, `pause`, `stop` |
101
140
  | `media.title`, `media.type`, `media.series`, `media.season`, `media.episode`, `media.artist`, `media.album`, `media.genre`, `media.year` | string | read | current item |
102
141
  | `media.cover` | string | read | cover URL (no login needed) |
103
- | `media.duration` / `media.elapsed` | number (s) | read | length and position |
142
+ | `media.duration` / `media.elapsed` | number (s) | read | length and position (counted on locally between the reports of the server) |
104
143
  | `media.seek` | number (%) | read/write | position in percent, write to jump |
105
144
  | `media.volume` | number (%) | read/write | volume (only filled if the app reports its volume) |
106
145
  | `media.mute` | boolean | read/write | mute (only filled if the app reports its volume) |
107
146
  | `media.repeat` | number | read/write | `0` off, `1` all, `2` one (only filled if the app supports it) |
108
147
  | `media.itemId` | string | read | Jellyfin id of the current item |
109
148
  | `command.*` | boolean | write | buttons |
110
- | `command.playTitle` | string | read/write | title (search, exact match preferred; a series starts with its first episode) or Jellyfin item id |
149
+ | `command.playTitle` | string | read/write | title (search, exact match preferred; also finds playlists) or Jellyfin item id |
150
+ | `command.playPlaylist` | string | read/write | name or id of a playlist; the value list contains all playlists of all users, refreshed every 10 minutes |
151
+ | `command.playShuffled` | string | read/write | name or id of a playlist, album, artist or series – shuffled by the server |
111
152
  | `command.message` | string | read/write | text or JSON `{"text":"…","header":"…","timeoutMs":5000}` |
112
153
  | `command.generalCommand` | string | read/write | any Jellyfin command, e.g. `GoHome` or `{"Name":"SetVolume","Arguments":{"Volume":"30"}}` |
113
154
 
155
+ Server states: `server.name`, `server.version`, `server.updateAvailable`, `server.restartPending`, `server.activeDevices`, `server.playingDevices`, `server.playlists` (JSON `[{"id":"…","name":"…","count":12}]`), `server.refreshLibrary` (button).
156
+
114
157
  Device ids: browsers use their own (shortened) id; apps are identified by app, device name and user (16-character hash), so both connections of an app end up in the same device.
115
158
 
116
- ### Message via script
159
+ ### Scripts
117
160
 
118
161
  ```typescript
119
- // all devices that can show messages
162
+ const tv = 'jellyfin.0.<device>';
163
+
164
+ // pause when the doorbell rings
165
+ on({ id: 'doorbell.0.ring', val: true }, () => setState(`${tv}.command.pause`, true));
166
+
167
+ // start a playlist in the morning, shuffled
168
+ schedule('0 7 * * 1-5', () => setState(`${tv}.command.playShuffled`, 'Good morning'));
169
+
170
+ // message on all devices that can show messages
120
171
  sendTo('jellyfin.0', 'message', { text: 'Someone is at the door', header: 'Doorbell' });
121
- // one device (object id or part of the device name)
122
- sendTo('jellyfin.0', 'message', { text: 'Dinner is ready', device: 'SHIELD' }, (res) => log(JSON.stringify(res)));
172
+ // message on one device (object id or part of the device name)
173
+ sendTo('jellyfin.0', 'message', { text: 'Dinner is ready', device: 'SHIELD' }, res => log(JSON.stringify(res)));
123
174
  ```
124
175
 
125
- The answer is `{ sent: <number of devices>, errors: [...] }`.
176
+ The answer of `sendTo` is `{ sent: <number of devices>, errors: [...] }`. In Blockly use the block *control* with the same states.
126
177
 
127
178
  ### Expert settings
128
179
 
129
- Visible in the instance settings with the expert mode switched on: update interval (how often the server sends the playback status, default 5 s), cover height (default 300 px, 0 = original) and request timeout.
180
+ Visible in the instance settings with the expert mode switched on: update interval (how often the server sends the playback status, default 5 s), cover height (default 300 px, 0 = original size) and request timeout (default 10 s).
130
181
 
131
182
  </details>
132
183
 
@@ -149,6 +200,12 @@ Jellyfin is a free software project. This adapter is not affiliated with or endo
149
200
  Placeholder for the next version (at the beginning of the line):
150
201
  ### **WORK IN PROGRESS**
151
202
  -->
203
+ ### 0.2.0 (2026-11-28)
204
+
205
+ - (Schimi1983) Start playlists: `command.playPlaylist` (with a selection list of all playlists), `command.playShuffled` (playlist, album, artist or series in random order) and `server.playlists`; `command.playTitle` also finds playlists (#8)
206
+ - (Schimi1983) README rewritten: setup, everyday use, music and playlists, remote control in VIS, which devices work how
207
+ - (Schimi1983) With log level "debug" the adapter logs what Jellyfin reports for each device (play/pause, position, volume, mute) whenever it changes - helps to find out whether a wrong state comes from Jellyfin or from the adapter
208
+
152
209
  ### 0.1.7 (2026-11-20)
153
210
 
154
211
  - (Schimi1983) The elapsed time (`media.elapsed`, `media.seek`) now counts on every second while playing, instead of jumping with each report of the server
@@ -169,10 +226,6 @@ Jellyfin is a free software project. This adapter is not affiliated with or endo
169
226
  - (Schimi) The connection to Jellyfin is given up and retried if it cannot be opened within the request timeout
170
227
  - (Schimi) `info.client` uses the role `text`
171
228
 
172
- ### 0.1.3 (2026-11-01)
173
-
174
- - (Schimi) Existing installations also get the translated names of `info` and `info.connection`
175
-
176
229
  [Older changelogs can be found there](CHANGELOG_OLD.md)
177
230
 
178
231
  ## License
package/build/lib/api.js CHANGED
@@ -20,9 +20,13 @@ var api_exports = {};
20
20
  __export(api_exports, {
21
21
  JellyfinApi: () => JellyfinApi,
22
22
  JellyfinHttpError: () => JellyfinHttpError,
23
+ SEARCH_TYPES: () => SEARCH_TYPES,
24
+ SHUFFLE_TYPES: () => SHUFFLE_TYPES,
23
25
  normalizeBaseUrl: () => normalizeBaseUrl
24
26
  });
25
27
  module.exports = __toCommonJS(api_exports);
28
+ const SEARCH_TYPES = "Movie,Series,Episode,Audio,MusicAlbum,MusicVideo,Video,Playlist";
29
+ const SHUFFLE_TYPES = "Playlist,MusicAlbum,MusicArtist,Series,Season,BoxSet";
26
30
  class JellyfinHttpError extends Error {
27
31
  /**
28
32
  * @param status - HTTP status code (0 = network error / timeout)
@@ -185,13 +189,14 @@ class JellyfinApi {
185
189
  *
186
190
  * @param term - search text
187
191
  * @param userId - user of the session (library permissions of this user apply)
192
+ * @param types - item types to search (default: films, series, episodes, music, videos, playlists)
188
193
  * @returns best match or `undefined`
189
194
  */
190
- async findItem(term, userId) {
195
+ async findItem(term, userId, types = SEARCH_TYPES) {
191
196
  var _a, _b;
192
197
  const q = new URLSearchParams({
193
198
  searchTerm: term,
194
- includeItemTypes: "Movie,Series,Episode,Audio,MusicAlbum,MusicVideo,Video",
199
+ includeItemTypes: types,
195
200
  recursive: "true",
196
201
  limit: "10"
197
202
  });
@@ -206,14 +211,40 @@ class JellyfinApi {
206
211
  return ((_a2 = i.Name) != null ? _a2 : "").toLowerCase() === lower;
207
212
  })) != null ? _b : items[0];
208
213
  }
214
+ /** GET /Users – all users of the server (needs an API key with admin rights, which API keys have). */
215
+ async getUsers() {
216
+ const list = await this.request("GET", "/Users");
217
+ return Array.isArray(list) ? list.filter((u) => !!(u == null ? void 0 : u.Id)) : [];
218
+ }
219
+ /**
220
+ * Playlists of one user.
221
+ *
222
+ * @param userId - user id
223
+ */
224
+ async getPlaylists(userId) {
225
+ var _a;
226
+ const q = new URLSearchParams({
227
+ userId,
228
+ includeItemTypes: "Playlist",
229
+ recursive: "true",
230
+ sortBy: "SortName",
231
+ fields: "ChildCount"
232
+ });
233
+ const res = await this.request("GET", `/Items?${q.toString()}`);
234
+ return (_a = res == null ? void 0 : res.Items) != null ? _a : [];
235
+ }
236
+ // @KI_HINWEIS: the server expands playlists, albums, artists and series to their entries itself
237
+ // (SessionManager.SendPlayCommand) and shuffles them for `PlayShuffle` - this also works for clients
238
+ // without a shuffle function of their own, e.g. DLNA renderers.
209
239
  /**
210
- * POST /Sessions/{id}/Playing – starts playback of items on a client ("PlayNow").
240
+ * POST /Sessions/{id}/Playing – starts playback of items on a client ("PlayNow" or "PlayShuffle").
211
241
  *
212
242
  * @param sessionId - Jellyfin session id
213
243
  * @param itemIds - ids of the items to play
244
+ * @param shuffle - play in random order
214
245
  */
215
- async playNow(sessionId, itemIds) {
216
- const q = new URLSearchParams({ playCommand: "PlayNow", itemIds: itemIds.join(",") });
246
+ async playNow(sessionId, itemIds, shuffle = false) {
247
+ const q = new URLSearchParams({ playCommand: shuffle ? "PlayShuffle" : "PlayNow", itemIds: itemIds.join(",") });
217
248
  await this.request("POST", `/Sessions/${encodeURIComponent(sessionId)}/Playing?${q.toString()}`);
218
249
  }
219
250
  /** POST /Library/Refresh – starts a library scan (returns immediately). */
@@ -225,6 +256,8 @@ class JellyfinApi {
225
256
  0 && (module.exports = {
226
257
  JellyfinApi,
227
258
  JellyfinHttpError,
259
+ SEARCH_TYPES,
260
+ SHUFFLE_TYPES,
228
261
  normalizeBaseUrl
229
262
  });
230
263
  //# sourceMappingURL=api.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/api.ts"],
4
- "sourcesContent": ["import type { ItemInfo, PlaystateCommand, RepeatMode, SessionInfo, SystemInfo } from './types';\n\n/** Error for every non-2xx answer of the Jellyfin server. */\nexport class JellyfinHttpError extends Error {\n /**\n * @param status - HTTP status code (0 = network error / timeout)\n * @param path - request path without query (never contains the API key)\n * @param message - error text\n */\n public constructor(\n public readonly status: number,\n public readonly path: string,\n message: string,\n ) {\n super(message);\n this.name = 'JellyfinHttpError';\n }\n}\n\n/** Connection settings of {@link JellyfinApi}. */\nexport interface JellyfinApiOptions {\n /** Server URL incl. optional base path, e.g. `http://192.168.1.10:8096` or `https://host/jellyfin` */\n baseUrl: string;\n /** API key created in the Jellyfin dashboard */\n apiKey: string;\n /** Device id under which the adapter registers itself (filtered out of the session list) */\n deviceId: string;\n /** Adapter version, reported to the server */\n version: string;\n /** Request timeout in ms */\n timeoutMs: number;\n}\n\n/**\n * Normalizes the configured server URL: trims, removes trailing slashes, adds `http://` if missing.\n *\n * @param url - URL as entered by the user\n * @returns normalized URL or `null` if it is not a valid http(s) URL\n */\nexport function normalizeBaseUrl(url: string | undefined): string | null {\n let value = (url ?? '').trim();\n if (!value) {\n return null;\n }\n if (/^[a-z][a-z0-9+.-]*:\\/\\//i.test(value)) {\n if (!/^https?:\\/\\//i.test(value)) {\n return null;\n }\n } else {\n value = `http://${value}`;\n }\n try {\n const parsed = new URL(value);\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n return null;\n }\n return `${parsed.protocol}//${parsed.host}${parsed.pathname}`.replace(/\\/+$/, '');\n } catch {\n return null;\n }\n}\n\n/**\n * Thin REST client for Jellyfin 12.x. Uses only the modern `Authorization: MediaBrowser \u2026 Token=\"\u2026\"`\n * header (legacy `X-Emby-Token` / `api_key` are rejected by Jellyfin 12).\n */\nexport class JellyfinApi {\n private readonly auth: string;\n\n /** @param opts - connection settings */\n public constructor(private readonly opts: JellyfinApiOptions) {\n const esc = (v: string): string => v.replace(/\"/g, '');\n this.auth =\n `MediaBrowser Client=\"ioBroker\", Device=\"ioBroker\", DeviceId=\"${esc(opts.deviceId)}\", ` +\n `Version=\"${esc(opts.version)}\", Token=\"${esc(opts.apiKey)}\"`;\n }\n\n /** Base URL without trailing slash (also used for image URLs). */\n public get baseUrl(): string {\n return this.opts.baseUrl;\n }\n\n // @KI_HINWEIS: Jellyfin 12 only accepts `ApiKey` (not the legacy `api_key`) in the query.\n /**\n * WebSocket URL. The key has to go into the query because Node's WebSocket cannot send headers.\n */\n public get socketUrl(): string {\n const url = new URL(`${this.opts.baseUrl}/socket`);\n url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';\n url.searchParams.set('ApiKey', this.opts.apiKey);\n url.searchParams.set('deviceId', this.opts.deviceId);\n return url.toString();\n }\n\n /**\n * Sends a request and returns the parsed JSON body (or `undefined` for empty answers like 204).\n *\n * @param method - HTTP method\n * @param path - path incl. query, starting with `/`\n * @param body - optional JSON body\n */\n public async request<T>(method: 'GET' | 'POST', path: string, body?: unknown): Promise<T | undefined> {\n const headers: Record<string, string> = { Authorization: this.auth };\n if (body !== undefined) {\n headers['Content-Type'] = 'application/json';\n }\n const plainPath = path.split('?')[0];\n let res: Response;\n try {\n res = await fetch(`${this.opts.baseUrl}${path}`, {\n method,\n headers,\n body: body === undefined ? undefined : JSON.stringify(body),\n signal: AbortSignal.timeout(this.opts.timeoutMs),\n });\n } catch (e) {\n const err = e as Error & { cause?: { code?: string } };\n const reason = err.name === 'TimeoutError' ? 'timeout' : (err.cause?.code ?? err.message);\n throw new JellyfinHttpError(0, plainPath, `${method} ${plainPath} failed: ${reason}`);\n }\n const text = await res.text();\n if (!res.ok) {\n throw new JellyfinHttpError(res.status, plainPath, `${method} ${plainPath} \u2192 HTTP ${res.status}`);\n }\n if (!text) {\n return undefined;\n }\n try {\n return JSON.parse(text) as T;\n } catch {\n return undefined;\n }\n }\n\n /** GET /System/Info */\n public async getSystemInfo(): Promise<SystemInfo> {\n return (await this.request<SystemInfo>('GET', '/System/Info')) ?? {};\n }\n\n /** GET /Sessions (all sessions incl. inactive, our own session is filtered out) */\n public async getSessions(): Promise<SessionInfo[]> {\n const list = await this.request<SessionInfo[]>('GET', '/Sessions');\n return Array.isArray(list) ? list.filter(s => s.DeviceId !== this.opts.deviceId) : [];\n }\n\n /**\n * POST /Sessions/{id}/Playing/{command}\n *\n * @param sessionId - Jellyfin session id\n * @param command - playstate command\n * @param seekPositionTicks - only for `Seek`\n */\n public async playstate(sessionId: string, command: PlaystateCommand, seekPositionTicks?: number): Promise<void> {\n const query = seekPositionTicks !== undefined ? `?seekPositionTicks=${Math.round(seekPositionTicks)}` : '';\n await this.request('POST', `/Sessions/${encodeURIComponent(sessionId)}/Playing/${command}${query}`);\n }\n\n /**\n * POST /Sessions/{id}/Command \u2013 general command with optional arguments.\n *\n * @param sessionId - Jellyfin session id\n * @param name - GeneralCommandType, e.g. `SetVolume`\n * @param args - command arguments (all values as strings)\n */\n public async generalCommand(sessionId: string, name: string, args?: Record<string, string>): Promise<void> {\n await this.request('POST', `/Sessions/${encodeURIComponent(sessionId)}/Command`, {\n Name: name,\n Arguments: args ?? {},\n });\n }\n\n /**\n * POST /Sessions/{id}/Command \u2013 SetRepeatMode\n *\n * @param sessionId - Jellyfin session id\n * @param mode - repeat mode\n */\n public async setRepeatMode(sessionId: string, mode: RepeatMode): Promise<void> {\n await this.generalCommand(sessionId, 'SetRepeatMode', { RepeatMode: mode });\n }\n\n /**\n * POST /Sessions/{id}/Message\n *\n * @param sessionId - Jellyfin session id\n * @param text - message text\n * @param header - optional header\n * @param timeoutMs - optional display time (ignored by the Android TV app)\n */\n public async sendMessage(sessionId: string, text: string, header?: string, timeoutMs?: number): Promise<void> {\n const body: Record<string, unknown> = { Header: header || 'ioBroker', Text: text };\n if (timeoutMs && timeoutMs > 0) {\n body.TimeoutMs = Math.round(timeoutMs);\n }\n await this.request('POST', `/Sessions/${encodeURIComponent(sessionId)}/Message`, body);\n }\n\n /**\n * Searches a playable item by name (movies, series, episodes, music, videos).\n * A series is played by Jellyfin from its first episode.\n *\n * @param term - search text\n * @param userId - user of the session (library permissions of this user apply)\n * @returns best match or `undefined`\n */\n public async findItem(term: string, userId?: string): Promise<ItemInfo | undefined> {\n const q = new URLSearchParams({\n searchTerm: term,\n includeItemTypes: 'Movie,Series,Episode,Audio,MusicAlbum,MusicVideo,Video',\n recursive: 'true',\n limit: '10',\n });\n if (userId) {\n q.set('userId', userId);\n }\n const res = await this.request<{ Items?: ItemInfo[] }>('GET', `/Items?${q.toString()}`);\n const items = res?.Items ?? [];\n const lower = term.toLowerCase();\n // exact title first, otherwise the server's best match\n return items.find(i => (i.Name ?? '').toLowerCase() === lower) ?? items[0];\n }\n\n /**\n * POST /Sessions/{id}/Playing \u2013 starts playback of items on a client (\"PlayNow\").\n *\n * @param sessionId - Jellyfin session id\n * @param itemIds - ids of the items to play\n */\n public async playNow(sessionId: string, itemIds: string[]): Promise<void> {\n const q = new URLSearchParams({ playCommand: 'PlayNow', itemIds: itemIds.join(',') });\n await this.request('POST', `/Sessions/${encodeURIComponent(sessionId)}/Playing?${q.toString()}`);\n }\n\n /** POST /Library/Refresh \u2013 starts a library scan (returns immediately). */\n public async refreshLibrary(): Promise<void> {\n await this.request('POST', '/Library/Refresh');\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,0BAA0B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlC,YACa,QACA,MAChB,SACF;AACE,UAAM,OAAO;AAJG;AACA;AAIhB,SAAK,OAAO;AAAA,EAChB;AACJ;AAsBO,SAAS,iBAAiB,KAAwC;AACrE,MAAI,SAAS,oBAAO,IAAI,KAAK;AAC7B,MAAI,CAAC,OAAO;AACR,WAAO;AAAA,EACX;AACA,MAAI,2BAA2B,KAAK,KAAK,GAAG;AACxC,QAAI,CAAC,gBAAgB,KAAK,KAAK,GAAG;AAC9B,aAAO;AAAA,IACX;AAAA,EACJ,OAAO;AACH,YAAQ,UAAU,KAAK;AAAA,EAC3B;AACA,MAAI;AACA,UAAM,SAAS,IAAI,IAAI,KAAK;AAC5B,QAAI,OAAO,aAAa,WAAW,OAAO,aAAa,UAAU;AAC7D,aAAO;AAAA,IACX;AACA,WAAO,GAAG,OAAO,QAAQ,KAAK,OAAO,IAAI,GAAG,OAAO,QAAQ,GAAG,QAAQ,QAAQ,EAAE;AAAA,EACpF,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AAMO,MAAM,YAAY;AAAA;AAAA,EAId,YAA6B,MAA0B;AAA1B;AAChC,UAAM,MAAM,CAAC,MAAsB,EAAE,QAAQ,MAAM,EAAE;AACrD,SAAK,OACD,gEAAgE,IAAI,KAAK,QAAQ,CAAC,eACtE,IAAI,KAAK,OAAO,CAAC,aAAa,IAAI,KAAK,MAAM,CAAC;AA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\n/** Item types searched by {@link JellyfinApi.findItem} by default. */\nexport const SEARCH_TYPES = 'Movie,Series,Episode,Audio,MusicAlbum,MusicVideo,Video,Playlist';\n/** Item types that can be played shuffled (collections of entries). */\nexport const SHUFFLE_TYPES = 'Playlist,MusicAlbum,MusicArtist,Series,Season,BoxSet';\n\n/** Error for every non-2xx answer of the Jellyfin server. */\nexport class JellyfinHttpError extends Error {\n /**\n * @param status - HTTP status code (0 = network error / timeout)\n * @param path - request path without query (never contains the API key)\n * @param message - error text\n */\n public constructor(\n public readonly status: number,\n public readonly path: string,\n message: string,\n ) {\n super(message);\n this.name = 'JellyfinHttpError';\n }\n}\n\n/** Connection settings of {@link JellyfinApi}. */\nexport interface JellyfinApiOptions {\n /** Server URL incl. optional base path, e.g. `http://192.168.1.10:8096` or `https://host/jellyfin` */\n baseUrl: string;\n /** API key created in the Jellyfin dashboard */\n apiKey: string;\n /** Device id under which the adapter registers itself (filtered out of the session list) */\n deviceId: string;\n /** Adapter version, reported to the server */\n version: string;\n /** Request timeout in ms */\n timeoutMs: number;\n}\n\n/**\n * Normalizes the configured server URL: trims, removes trailing slashes, adds `http://` if missing.\n *\n * @param url - URL as entered by the user\n * @returns normalized URL or `null` if it is not a valid http(s) URL\n */\nexport function normalizeBaseUrl(url: string | undefined): string | null {\n let value = (url ?? '').trim();\n if (!value) {\n return null;\n }\n if (/^[a-z][a-z0-9+.-]*:\\/\\//i.test(value)) {\n if (!/^https?:\\/\\//i.test(value)) {\n return null;\n }\n } else {\n value = `http://${value}`;\n }\n try {\n const parsed = new URL(value);\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n return null;\n }\n return `${parsed.protocol}//${parsed.host}${parsed.pathname}`.replace(/\\/+$/, '');\n } catch {\n return null;\n }\n}\n\n/**\n * Thin REST client for Jellyfin 12.x. Uses only the modern `Authorization: MediaBrowser \u2026 Token=\"\u2026\"`\n * header (legacy `X-Emby-Token` / `api_key` are rejected by Jellyfin 12).\n */\nexport class JellyfinApi {\n private readonly auth: string;\n\n /** @param opts - connection settings */\n public constructor(private readonly opts: JellyfinApiOptions) {\n const esc = (v: string): string => v.replace(/\"/g, '');\n this.auth =\n `MediaBrowser Client=\"ioBroker\", Device=\"ioBroker\", DeviceId=\"${esc(opts.deviceId)}\", ` +\n `Version=\"${esc(opts.version)}\", Token=\"${esc(opts.apiKey)}\"`;\n }\n\n /** Base URL without trailing slash (also used for image URLs). */\n public get baseUrl(): string {\n return this.opts.baseUrl;\n }\n\n // @KI_HINWEIS: Jellyfin 12 only accepts `ApiKey` (not the legacy `api_key`) in the query.\n /**\n * WebSocket URL. The key has to go into the query because Node's WebSocket cannot send headers.\n */\n public get socketUrl(): string {\n const url = new URL(`${this.opts.baseUrl}/socket`);\n url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';\n url.searchParams.set('ApiKey', this.opts.apiKey);\n url.searchParams.set('deviceId', this.opts.deviceId);\n return url.toString();\n }\n\n /**\n * Sends a request and returns the parsed JSON body (or `undefined` for empty answers like 204).\n *\n * @param method - HTTP method\n * @param path - path incl. query, starting with `/`\n * @param body - optional JSON body\n */\n public async request<T>(method: 'GET' | 'POST', path: string, body?: unknown): Promise<T | undefined> {\n const headers: Record<string, string> = { Authorization: this.auth };\n if (body !== undefined) {\n headers['Content-Type'] = 'application/json';\n }\n const plainPath = path.split('?')[0];\n let res: Response;\n try {\n res = await fetch(`${this.opts.baseUrl}${path}`, {\n method,\n headers,\n body: body === undefined ? undefined : JSON.stringify(body),\n signal: AbortSignal.timeout(this.opts.timeoutMs),\n });\n } catch (e) {\n const err = e as Error & { cause?: { code?: string } };\n const reason = err.name === 'TimeoutError' ? 'timeout' : (err.cause?.code ?? err.message);\n throw new JellyfinHttpError(0, plainPath, `${method} ${plainPath} failed: ${reason}`);\n }\n const text = await res.text();\n if (!res.ok) {\n throw new JellyfinHttpError(res.status, plainPath, `${method} ${plainPath} \u2192 HTTP ${res.status}`);\n }\n if (!text) {\n return undefined;\n }\n try {\n return JSON.parse(text) as T;\n } catch {\n return undefined;\n }\n }\n\n /** GET /System/Info */\n public async getSystemInfo(): Promise<SystemInfo> {\n return (await this.request<SystemInfo>('GET', '/System/Info')) ?? {};\n }\n\n /** GET /Sessions (all sessions incl. inactive, our own session is filtered out) */\n public async getSessions(): Promise<SessionInfo[]> {\n const list = await this.request<SessionInfo[]>('GET', '/Sessions');\n return Array.isArray(list) ? list.filter(s => s.DeviceId !== this.opts.deviceId) : [];\n }\n\n /**\n * POST /Sessions/{id}/Playing/{command}\n *\n * @param sessionId - Jellyfin session id\n * @param command - playstate command\n * @param seekPositionTicks - only for `Seek`\n */\n public async playstate(sessionId: string, command: PlaystateCommand, seekPositionTicks?: number): Promise<void> {\n const query = seekPositionTicks !== undefined ? `?seekPositionTicks=${Math.round(seekPositionTicks)}` : '';\n await this.request('POST', `/Sessions/${encodeURIComponent(sessionId)}/Playing/${command}${query}`);\n }\n\n /**\n * POST /Sessions/{id}/Command \u2013 general command with optional arguments.\n *\n * @param sessionId - Jellyfin session id\n * @param name - GeneralCommandType, e.g. `SetVolume`\n * @param args - command arguments (all values as strings)\n */\n public async generalCommand(sessionId: string, name: string, args?: Record<string, string>): Promise<void> {\n await this.request('POST', `/Sessions/${encodeURIComponent(sessionId)}/Command`, {\n Name: name,\n Arguments: args ?? {},\n });\n }\n\n /**\n * POST /Sessions/{id}/Command \u2013 SetRepeatMode\n *\n * @param sessionId - Jellyfin session id\n * @param mode - repeat mode\n */\n public async setRepeatMode(sessionId: string, mode: RepeatMode): Promise<void> {\n await this.generalCommand(sessionId, 'SetRepeatMode', { RepeatMode: mode });\n }\n\n /**\n * POST /Sessions/{id}/Message\n *\n * @param sessionId - Jellyfin session id\n * @param text - message text\n * @param header - optional header\n * @param timeoutMs - optional display time (ignored by the Android TV app)\n */\n public async sendMessage(sessionId: string, text: string, header?: string, timeoutMs?: number): Promise<void> {\n const body: Record<string, unknown> = { Header: header || 'ioBroker', Text: text };\n if (timeoutMs && timeoutMs > 0) {\n body.TimeoutMs = Math.round(timeoutMs);\n }\n await this.request('POST', `/Sessions/${encodeURIComponent(sessionId)}/Message`, body);\n }\n\n /**\n * Searches a playable item by name (movies, series, episodes, music, videos).\n * A series is played by Jellyfin from its first episode.\n *\n * @param term - search text\n * @param userId - user of the session (library permissions of this user apply)\n * @param types - item types to search (default: films, series, episodes, music, videos, playlists)\n * @returns best match or `undefined`\n */\n public async findItem(term: string, userId?: string, types = SEARCH_TYPES): Promise<ItemInfo | undefined> {\n const q = new URLSearchParams({\n searchTerm: term,\n includeItemTypes: types,\n recursive: 'true',\n limit: '10',\n });\n if (userId) {\n q.set('userId', userId);\n }\n const res = await this.request<{ Items?: ItemInfo[] }>('GET', `/Items?${q.toString()}`);\n const items = res?.Items ?? [];\n const lower = term.toLowerCase();\n // exact title first, otherwise the server's best match\n return items.find(i => (i.Name ?? '').toLowerCase() === lower) ?? items[0];\n }\n\n /** GET /Users \u2013 all users of the server (needs an API key with admin rights, which API keys have). */\n public async getUsers(): Promise<UserInfo[]> {\n const list = await this.request<UserInfo[]>('GET', '/Users');\n return Array.isArray(list) ? list.filter(u => !!u?.Id) : [];\n }\n\n /**\n * Playlists of one user.\n *\n * @param userId - user id\n */\n public async getPlaylists(userId: string): Promise<ItemInfo[]> {\n const q = new URLSearchParams({\n userId,\n includeItemTypes: 'Playlist',\n recursive: 'true',\n sortBy: 'SortName',\n fields: 'ChildCount',\n });\n const res = await this.request<{ Items?: ItemInfo[] }>('GET', `/Items?${q.toString()}`);\n return res?.Items ?? [];\n }\n\n // @KI_HINWEIS: the server expands playlists, albums, artists and series to their entries itself\n // (SessionManager.SendPlayCommand) and shuffles them for `PlayShuffle` - this also works for clients\n // without a shuffle function of their own, e.g. DLNA renderers.\n /**\n * POST /Sessions/{id}/Playing \u2013 starts playback of items on a client (\"PlayNow\" or \"PlayShuffle\").\n *\n * @param sessionId - Jellyfin session id\n * @param itemIds - ids of the items to play\n * @param shuffle - play in random order\n */\n public async playNow(sessionId: string, itemIds: string[], shuffle = false): Promise<void> {\n const q = new URLSearchParams({ playCommand: shuffle ? 'PlayShuffle' : 'PlayNow', itemIds: itemIds.join(',') });\n await this.request('POST', `/Sessions/${encodeURIComponent(sessionId)}/Playing?${q.toString()}`);\n }\n\n /** POST /Library/Refresh \u2013 starts a library scan (returns immediately). */\n public async refreshLibrary(): Promise<void> {\n await this.request('POST', '/Library/Refresh');\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,eAAe;AAErB,MAAM,gBAAgB;AAGtB,MAAM,0BAA0B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlC,YACa,QACA,MAChB,SACF;AACE,UAAM,OAAO;AAJG;AACA;AAIhB,SAAK,OAAO;AAAA,EAChB;AACJ;AAsBO,SAAS,iBAAiB,KAAwC;AACrE,MAAI,SAAS,oBAAO,IAAI,KAAK;AAC7B,MAAI,CAAC,OAAO;AACR,WAAO;AAAA,EACX;AACA,MAAI,2BAA2B,KAAK,KAAK,GAAG;AACxC,QAAI,CAAC,gBAAgB,KAAK,KAAK,GAAG;AAC9B,aAAO;AAAA,IACX;AAAA,EACJ,OAAO;AACH,YAAQ,UAAU,KAAK;AAAA,EAC3B;AACA,MAAI;AACA,UAAM,SAAS,IAAI,IAAI,KAAK;AAC5B,QAAI,OAAO,aAAa,WAAW,OAAO,aAAa,UAAU;AAC7D,aAAO;AAAA,IACX;AACA,WAAO,GAAG,OAAO,QAAQ,KAAK,OAAO,IAAI,GAAG,OAAO,QAAQ,GAAG,QAAQ,QAAQ,EAAE;AAAA,EACpF,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AAMO,MAAM,YAAY;AAAA;AAAA,EAId,YAA6B,MAA0B;AAA1B;AAChC,UAAM,MAAM,CAAC,MAAsB,EAAE,QAAQ,MAAM,EAAE;AACrD,SAAK,OACD,gEAAgE,IAAI,KAAK,QAAQ,CAAC,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X,QAAQ;AAAA,MACR,QAAQ;AAAA,IACZ,CAAC;AACD,UAAM,MAAM,MAAM,KAAK,QAAgC,OAAO,UAAU,EAAE,SAAS,CAAC,EAAE;AACtF,YAAO,gCAAK,UAAL,YAAc,CAAC;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,MAAa,QAAQ,WAAmB,SAAmB,UAAU,OAAsB;AACvF,UAAM,IAAI,IAAI,gBAAgB,EAAE,aAAa,UAAU,gBAAgB,WAAW,SAAS,QAAQ,KAAK,GAAG,EAAE,CAAC;AAC9G,UAAM,KAAK,QAAQ,QAAQ,aAAa,mBAAmB,SAAS,CAAC,YAAY,EAAE,SAAS,CAAC,EAAE;AAAA,EACnG;AAAA;AAAA,EAGA,MAAa,iBAAgC;AACzC,UAAM,KAAK,QAAQ,QAAQ,kBAAkB;AAAA,EACjD;AACJ;",
6
6
  "names": ["_a"]
7
7
  }
@@ -466,6 +466,45 @@ const LIST = [
466
466
  "\u0412\u0456\u0434\u0442\u0432\u043E\u0440\u0438\u0442\u0438 \u0444\u0456\u043B\u044C\u043C, \u0435\u043F\u0456\u0437\u043E\u0434 \u0430\u0431\u043E \u043F\u0456\u0441\u043D\u044E \u0437\u0430 \u043D\u0430\u0437\u0432\u043E\u044E (\u0430\u0431\u043E ID)",
467
467
  "\u6309\u6807\u9898\uFF08\u6216 ID\uFF09\u64AD\u653E\u7535\u5F71\u3001\u5267\u96C6\u6216\u6B4C\u66F2"
468
468
  ),
469
+ t(
470
+ "Play a playlist (name or id)",
471
+ "Playlist abspielen (Name oder ID)",
472
+ "\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043F\u043B\u0435\u0439\u043B\u0438\u0441\u0442 (\u043D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u0438\u043B\u0438 ID)",
473
+ "Reproduzir uma playlist (nome ou ID)",
474
+ "Een afspeellijst afspelen (naam of id)",
475
+ "Lire une playlist (nom ou ID)",
476
+ "Riproduci una playlist (nome o ID)",
477
+ "Reproducir una lista de reproducci\xF3n (nombre o ID)",
478
+ "Odtw\xF3rz playlist\u0119 (nazwa lub ID)",
479
+ "\u0412\u0456\u0434\u0442\u0432\u043E\u0440\u0438\u0442\u0438 \u043F\u043B\u0435\u0439\u043B\u0438\u0441\u0442 (\u043D\u0430\u0437\u0432\u0430 \u0430\u0431\u043E ID)",
480
+ "\u64AD\u653E\u64AD\u653E\u5217\u8868\uFF08\u540D\u79F0\u6216 ID\uFF09"
481
+ ),
482
+ t(
483
+ "Play a playlist, album, artist or series in random order (name or id)",
484
+ "Playlist, Album, Interpret oder Serie in zuf\xE4lliger Reihenfolge abspielen (Name oder ID)",
485
+ "\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043F\u043B\u0435\u0439\u043B\u0438\u0441\u0442, \u0430\u043B\u044C\u0431\u043E\u043C, \u0438\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044F \u0438\u043B\u0438 \u0441\u0435\u0440\u0438\u0430\u043B \u0432 \u0441\u043B\u0443\u0447\u0430\u0439\u043D\u043E\u043C \u043F\u043E\u0440\u044F\u0434\u043A\u0435 (\u043D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u0438\u043B\u0438 ID)",
486
+ "Reproduzir uma playlist, \xE1lbum, artista ou s\xE9rie em ordem aleat\xF3ria (nome ou ID)",
487
+ "Een afspeellijst, album, artiest of serie in willekeurige volgorde afspelen (naam of id)",
488
+ "Lire une playlist, un album, un artiste ou une s\xE9rie dans un ordre al\xE9atoire (nom ou ID)",
489
+ "Riproduci una playlist, un album, un artista o una serie in ordine casuale (nome o ID)",
490
+ "Reproducir una lista, \xE1lbum, artista o serie en orden aleatorio (nombre o ID)",
491
+ "Odtw\xF3rz playlist\u0119, album, wykonawc\u0119 lub serial w losowej kolejno\u015Bci (nazwa lub ID)",
492
+ "\u0412\u0456\u0434\u0442\u0432\u043E\u0440\u0438\u0442\u0438 \u043F\u043B\u0435\u0439\u043B\u0438\u0441\u0442, \u0430\u043B\u044C\u0431\u043E\u043C, \u0432\u0438\u043A\u043E\u043D\u0430\u0432\u0446\u044F \u0430\u0431\u043E \u0441\u0435\u0440\u0456\u0430\u043B \u0443 \u0432\u0438\u043F\u0430\u0434\u043A\u043E\u0432\u043E\u043C\u0443 \u043F\u043E\u0440\u044F\u0434\u043A\u0443 (\u043D\u0430\u0437\u0432\u0430 \u0430\u0431\u043E ID)",
493
+ "\u968F\u673A\u64AD\u653E\u64AD\u653E\u5217\u8868\u3001\u4E13\u8F91\u3001\u827A\u672F\u5BB6\u6216\u5267\u96C6\uFF08\u540D\u79F0\u6216 ID\uFF09"
494
+ ),
495
+ t(
496
+ "Playlists (JSON list with id, name and number of entries)",
497
+ "Playlists (JSON-Liste mit ID, Name und Anzahl der Eintr\xE4ge)",
498
+ "\u041F\u043B\u0435\u0439\u043B\u0438\u0441\u0442\u044B (\u0441\u043F\u0438\u0441\u043E\u043A JSON \u0441 ID, \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u0435\u043C \u0438 \u0447\u0438\u0441\u043B\u043E\u043C \u0437\u0430\u043F\u0438\u0441\u0435\u0439)",
499
+ "Playlists (lista JSON com ID, nome e n\xFAmero de entradas)",
500
+ "Afspeellijsten (JSON-lijst met id, naam en aantal items)",
501
+ "Playlists (liste JSON avec ID, nom et nombre d'entr\xE9es)",
502
+ "Playlist (elenco JSON con ID, nome e numero di voci)",
503
+ "Listas de reproducci\xF3n (lista JSON con ID, nombre y n\xFAmero de entradas)",
504
+ "Playlisty (lista JSON z ID, nazw\u0105 i liczb\u0105 pozycji)",
505
+ "\u041F\u043B\u0435\u0439\u043B\u0438\u0441\u0442\u0438 (\u0441\u043F\u0438\u0441\u043E\u043A JSON \u0437 ID, \u043D\u0430\u0437\u0432\u043E\u044E \u0442\u0430 \u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044E \u0437\u0430\u043F\u0438\u0441\u0456\u0432)",
506
+ "\u64AD\u653E\u5217\u8868\uFF08\u5305\u542B ID\u3001\u540D\u79F0\u548C\u6761\u76EE\u6570\u7684 JSON \u5217\u8868\uFF09"
507
+ ),
469
508
  t(
470
509
  "Show message on the screen",
471
510
  "Meldung auf dem Bildschirm anzeigen",