Skip to content

Commit 2e41f80

Browse files
committed
Migrate state:push into the new event system.
1 parent eea52a1 commit 2e41f80

File tree

15 files changed

+365
-436
lines changed

15 files changed

+365
-436
lines changed

FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ command via CLI.
402402

403403
> [!IMPORTANT]
404404
> for environment variables that has `{TASK}` tag, you **MUST** replace it with one
405-
> of `IMPORT`, `EXPORT`, `PUSH`, `BACKUP`, `PRUNE`, `INDEXES`. To see tasks active settings run
405+
> of `IMPORT`, `EXPORT`, `BACKUP`, `PRUNE`, `INDEXES`. To see tasks active settings run
406406
407407
```bash
408408
$ docker exec -ti watchstate console system:tasks

NEWS.md

+40
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
# Old Updates
22

3+
### 2024-08-10
4+
5+
I have recently added new experimental feature, to play your content directly from the WebUI. This feature is still in
6+
alpha, and missing a lot of features. But it's a start. Right now it does auto transcode on the fly to play any content in the browser.
7+
8+
The feature requires that you mount your media directories to the `WatchState` container similar to the `File integrity` feature. I have plans to expand
9+
the feature to support more controls, however, right now it's only support basic subtitles streams and default audio stream or first audio stream.
10+
11+
The transcoder works by converting the media on the fly to `HLS` segments, and the subtitles are selectable via the player ui which are also converted to `vtt` format.
12+
13+
Expects bugs and issues, as the feature is still in alpha. But I would love to hear your feedback. You can play the media by visiting
14+
the history page of the item you will see red play button on top right corner of the page. If the items has a play button, then you correctly mounted
15+
the media directories. otherwise, the button be disabled with tooltip of `Media is inaccessible`.
16+
17+
The feature is not meant to replace your backend media player, the purpose of this feature is to quickly check the media without leaving the WebUI.
18+
19+
### 2024-08-01
20+
21+
We recently enabled listening on tls connections via `8443` which can be controlled by `HTTPS_PORT` environment variable.
22+
Before today, we simply only exposed the port via the `Dockerfile`, but we weren't listening for connections on it.
23+
24+
However, please keep in mind that the certificate is self-signed, and you might get a warning from your browser. You can
25+
either accept the warning or add the certificate to your trusted certificates. We strongly recommend using a reverse proxy.
26+
instead of relying on self-signed certificates.
27+
28+
### 2024-07-22
29+
30+
We have recently added a new WebUI feature, `File integrity`, this feature will help you to check if your media backends
31+
are reporting files that are not available on the disk. This feature is still in alpha, and we are working on improving
32+
it.
33+
34+
This feature `REQUIRES` that you mount your media directories to the `WatchState` container preferably as readonly. There is plans to add
35+
a path replacement feature to allow you change the pathing, but it's not implemented yet.
36+
37+
This feature will work on both local and remote cloud storages provided they are mounted into the container. We also may recommend not to
38+
use this feature depending on how your cloud storage provider treats file stat calls. As it might lead to unnecessary money spending. and of course
39+
it will be slower.
40+
41+
For more information about how we cache the stat calls, please refer to the [FAQ](FAQ.md#How-does-the-file-integrity-feature-works).
42+
343
### 2024-07-06
444

545
Recently we have introduced a new feature that allows you to use Jellyfin and Emby OAuth access tokens for syncing

README.md

+12-40
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ out of the box, this tool support `Jellyfin`, `Plex` and `Emby` media servers.
99

1010
## Updates
1111

12+
### 2024-08-19
13+
14+
We have migrated the `state:push` task into the new events system, as such the old task `state:push` is now gone.
15+
To enable the new event handler for push events, use the new environment variable `WS_PUSH_ENABLED` and set it to `true`.
16+
Right now, it's disabled by default. However, for people who had the old task enabled, it will reuse that setting.
17+
18+
Keep in mind, the new event handler is more efficient and will only push data when there is a change in the play state. And it's much faster
19+
than the old task. This event handler will push data within a minute of the change.
20+
21+
PS: Please enable the task by setting its new environment variable `WS_PUSH_ENABLED` to `true`. The old `WS_CRON_PUSH` is now gone.
22+
and will be removed in the future releases.
23+
1224
### 2024-08-18
1325

1426
We have started migrating the old events system to a new one, so far we have migrated the `progress` and `requests` to it. As such,
@@ -17,46 +29,6 @@ environment variable `WS_SYNC_PROGRESS` which you can set to `true` to enable th
1729

1830
We will continue to migrate the rest of the events to the new system, and we will keep you updated.
1931

20-
### 2024-08-10
21-
22-
I have recently added new experimental feature, to play your content directly from the WebUI. This feature is still in
23-
alpha, and missing a lot of features. But it's a start. Right now it does auto transcode on the fly to play any content in the browser.
24-
25-
The feature requires that you mount your media directories to the `WatchState` container similar to the `File integrity` feature. I have plans to expand
26-
the feature to support more controls, however, right now it's only support basic subtitles streams and default audio stream or first audio stream.
27-
28-
The transcoder works by converting the media on the fly to `HLS` segments, and the subtitles are selectable via the player ui which are also converted to `vtt` format.
29-
30-
Expects bugs and issues, as the feature is still in alpha. But I would love to hear your feedback. You can play the media by visiting
31-
the history page of the item you will see red play button on top right corner of the page. If the items has a play button, then you correctly mounted
32-
the media directories. otherwise, the button be disabled with tooltip of `Media is inaccessible`.
33-
34-
The feature is not meant to replace your backend media player, the purpose of this feature is to quickly check the media without leaving the WebUI.
35-
36-
### 2024-08-01
37-
38-
We recently enabled listening on tls connections via `8443` which can be controlled by `HTTPS_PORT` environment variable.
39-
Before today, we simply only exposed the port via the `Dockerfile`, but we weren't listening for connections on it.
40-
41-
However, please keep in mind that the certificate is self-signed, and you might get a warning from your browser. You can
42-
either accept the warning or add the certificate to your trusted certificates. We strongly recommend using a reverse proxy.
43-
instead of relying on self-signed certificates.
44-
45-
### 2024-07-22
46-
47-
We have recently added a new WebUI feature, `File integrity`, this feature will help you to check if your media backends
48-
are reporting files that are not available on the disk. This feature is still in alpha, and we are working on improving
49-
it.
50-
51-
This feature `REQUIRES` that you mount your media directories to the `WatchState` container preferably as readonly. There is plans to add
52-
a path replacement feature to allow you change the pathing, but it's not implemented yet.
53-
54-
This feature will work on both local and remote cloud storages provided they are mounted into the container. We also may recommend not to
55-
use this feature depending on how your cloud storage provider treats file stat calls. As it might lead to unnecessary money spending. and of course
56-
it will be slower.
57-
58-
For more information about how we cache the stat calls, please refer to the [FAQ](FAQ.md#How-does-the-file-integrity-feature-works).
59-
6032
Refer to [NEWS](NEWS.md) for old updates.
6133

6234
# Features

config/config.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use App\Commands\State\BackupCommand;
1010
use App\Commands\State\ExportCommand;
1111
use App\Commands\State\ImportCommand;
12-
use App\Commands\State\PushCommand;
1312
use App\Commands\System\IndexCommand;
1413
use App\Commands\System\PruneCommand;
1514
use App\Libs\Mappers\Import\MemoryMapper;
@@ -75,7 +74,10 @@
7574
'header' => (string)env('WS_TRUST_HEADER', 'X-Forwarded-For'),
7675
],
7776
'sync' => [
78-
'progress' => (bool)env('WS_SYNC_PROGRESS', false),
77+
'progress' => (bool)env('WS_SYNC_PROGRESS', (bool)env('WS_CRON_PROGRESS', false)),
78+
],
79+
'push' => [
80+
'enabled' => (bool)env('WS_PUSH_ENABLED', (bool)env('WS_CRON_PUSH', false)),
7981
],
8082
];
8183

@@ -266,14 +268,6 @@
266268
'timer' => $checkTaskTimer((string)env('WS_CRON_EXPORT_AT', '30 */1 * * *'), '30 */1 * * *'),
267269
'args' => env('WS_CRON_EXPORT_ARGS', '-v'),
268270
],
269-
PushCommand::TASK_NAME => [
270-
'command' => PushCommand::ROUTE,
271-
'name' => PushCommand::TASK_NAME,
272-
'info' => 'Send queued events to backends.',
273-
'enabled' => (bool)env('WS_CRON_PUSH', true),
274-
'timer' => $checkTaskTimer((string)env('WS_CRON_PUSH_AT', '*/10 * * * *'), '*/10 * * * *'),
275-
'args' => env('WS_CRON_PUSH_ARGS', '-v'),
276-
],
277271
BackupCommand::TASK_NAME => [
278272
'command' => BackupCommand::ROUTE,
279273
'name' => BackupCommand::TASK_NAME,

config/env.spec.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@
166166
'description' => 'Enable watch progress sync.',
167167
'type' => 'bool',
168168
],
169+
[
170+
'key' => 'WS_PUSH_ENABLED',
171+
'description' => 'Enable Push play state to backends. This feature depends on webhooks being enabled.',
172+
'type' => 'bool',
173+
],
169174
];
170175

171176
$validateCronExpression = function (string $value): string {
@@ -191,7 +196,7 @@
191196
};
192197

193198
// -- Do not forget to update the tasks list if you add a new task.
194-
$tasks = ['import', 'export', 'push', 'backup', 'prune', 'indexes'];
199+
$tasks = ['import', 'export', 'backup', 'prune', 'indexes'];
195200
$task_env = [
196201
[
197202
'key' => 'WS_CRON_{TASK}',

frontend/pages/events/index.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@
3939
</div>
4040
</div>
4141

42-
<div class="columns is-multiline" v-if="items.length < 1">
42+
<div class="columns is-multiline" v-if="filteredRows.length < 1">
4343
<div class="column is-12">
4444
<Message v-if="isLoading" message_class="has-background-info-90 has-text-dark" title="Loading"
4545
icon="fas fa-spinner fa-spin" message="Loading data. Please wait..."/>
4646
<Message v-else class="has-background-warning-80 has-text-dark" title="Warning"
4747
icon="fas fa-exclamation-triangle">
4848
<p>No items found.</p>
49+
<p v-if="query">Search for <strong>{{ query }}</strong> returned no results.</p>
4950
</Message>
5051
</div>
5152
</div>
@@ -79,16 +80,15 @@
7980
</div>
8081
<span class="card-footer-item">
8182
<span class="icon"><i class="fas fa-calendar"></i></span>
82-
<time class="has-tooltip" v-tooltip="`Created at: ${moment(item.created_at).format(tooltip_dateformat)}`">
83+
<time class="has-tooltip" v-tooltip="`Created at: ${moment(item.created_at)}`">
8384
{{ moment(item.created_at).fromNow() }}
8485
</time>
8586
</span>
8687
<span class="card-footer-item">
8788
<span v-if="!item.updated_at" class="icon"><i class="fas fa-spinner fa-spin"></i></span>
8889
<template v-else>
8990
<span class="icon"><i class="fas fa-calendar-alt"></i></span>
90-
<time class="has-tooltip"
91-
v-tooltip="`Updated at: ${moment(item.updated_at).format(tooltip_dateformat)}`">
91+
<time class="has-tooltip" v-tooltip="`Updated at: ${moment(item.updated_at)}`">
9292
{{ moment(item.updated_at).fromNow() }}
9393
</time>
9494
</template>
@@ -173,7 +173,7 @@ const filteredRows = computed(() => {
173173
174174
return items.value.filter(i => {
175175
return Object.keys(i).some(k => {
176-
if (typeof i[k] === 'object') {
176+
if (typeof i[k] === 'object' && null !== i[k]) {
177177
return Object.values(i[k]).some(v => typeof v === 'string' ? v.toLowerCase().includes(toTower) : false)
178178
}
179179
return typeof i[k] === 'string' ? i[k].toLowerCase().includes(toTower) : false

frontend/pages/history/[id]/index.vue

+8-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,14 @@
429429
</span>
430430
</span>
431431
<div v-if="showRawData" class="mt-2">
432-
<code class="is-block is-pre-wrap">{{ JSON.stringify(data, null, 2) }}</code>
432+
<code class="is-block is-pre-wrap">{{
433+
JSON.stringify(Object.keys(data)
434+
.filter(key => !['files', 'hardware', 'content_exists', '_toggle'].includes(key))
435+
.reduce((obj, key) => {
436+
obj[key] = data[key];
437+
return obj;
438+
}, {}), null, 2)
439+
}}</code>
433440
</div>
434441
</div>
435442

frontend/utils/events/helpers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const makeName = id => id.split('-').slice(0)[0]
33
const getStatusClass = status => {
44
switch (status) {
55
case 0:
6-
return 'is-light'
6+
return 'is-light has-text-dark'
77
case 1:
88
return 'is-warning'
99
case 2:
@@ -13,7 +13,7 @@ const getStatusClass = status => {
1313
case 4:
1414
return 'is-danger is-light'
1515
default:
16-
return 'is-light'
16+
return 'is-light has-text-dark'
1717
}
1818
}
1919

src/Commands/Events/DispatchCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#[Cli(command: self::ROUTE)]
2323
final class DispatchCommand extends Command
2424
{
25-
public const string TASK_NAME = 'Dispatch';
25+
public const string TASK_NAME = 'dispatch';
2626

2727
public const string ROUTE = 'events:dispatch';
2828

0 commit comments

Comments
 (0)