@soffits/dsh-media-hub 0.0.0-stage → 0.7.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/CHANGELOG.md +97 -0
- package/LICENSE +21 -0
- package/README.md +78 -2
- package/client.js +223 -0
- package/cordis.patch.yml +11 -0
- package/dist/hls.mjs +41383 -0
- package/dist/index.js +15224 -0
- package/dist/tools.js +6884 -0
- package/icon.svg +7 -0
- package/locale/en.json +276 -0
- package/locale/fr.json +276 -0
- package/locale/zh.json +276 -0
- package/package.json +83 -4
- package/src/captions.js +74 -0
- package/src/formats.js +25 -0
- package/src/i18n.js +69 -0
- package/src/sync.js +84 -0
- package/web/about-view.js +32 -0
- package/web/avatars.js +46 -0
- package/web/books-view.js +192 -0
- package/web/continue-card.js +131 -0
- package/web/continue.js +59 -0
- package/web/details.js +103 -0
- package/web/discover-view.js +202 -0
- package/web/follow.js +29 -0
- package/web/format.js +57 -0
- package/web/known.js +19 -0
- package/web/library-view.js +234 -0
- package/web/nav.js +115 -0
- package/web/page.js +104 -0
- package/web/panel.css +363 -0
- package/web/player.js +736 -0
- package/web/presence-view.js +95 -0
- package/web/readiness.js +55 -0
- package/web/result-card.js +114 -0
- package/web/room-view.js +188 -0
- package/web/rooms-view.js +64 -0
- package/web/sort.js +30 -0
- package/web/ui.js +301 -0
- package/web/watching-view.js +100 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
- A show's details (title, blurb, score, related works, episode titles, cover) are now read from its source every time the page shows them, so a rename or a new season on the source appears without any refresh. The copy saved with the show is only an offline fallback: when the source can't answer in a few seconds, the page shows it with a note saying when it was saved, and the next answer refreshes it. Nothing is cached between page loads.
|
|
6
|
+
- The "Refresh info" menu item and the quiet backfill of details are gone: reading live makes both unnecessary.
|
|
7
|
+
|
|
8
|
+
## 0.6.2
|
|
9
|
+
|
|
10
|
+
- The page's tabs line up again: the selected tab no longer runs into the next one, and Discover's sort buttons keep their own width.
|
|
11
|
+
|
|
12
|
+
## 0.6.1
|
|
13
|
+
|
|
14
|
+
- A film, one video or a single link no longer talks about episodes. It gets no episode list, strip or "Episode 1 of 1", and its buttons say *Play*, *Continue at 12:34* or *Join Ana*, in the Continue card, Discover, the library, the room's side panel and the watch log the tool reads. Episode words show from two episodes on.
|
|
15
|
+
- "Preparing…" and "could not be prepared" no longer say "this episode".
|
|
16
|
+
|
|
17
|
+
## 0.6.0
|
|
18
|
+
|
|
19
|
+
- A new Watching tab. At the top, a card for the show someone is in now, or the one you watched last, over its blurred cover: who is in the room, the title, where it stands, a strip of its episodes (watched, now, on disk), and *Join … · episode n*, or *Continue* alone (still the default) with *Watch together* beside it, the room's link and *Ask*. Below it, news from followed works, the shared rooms as cards, and the other shows you started.
|
|
20
|
+
- Optional parts, each switched in the new `presence` setting and off by default: *So far*, a recap without spoilers kept with a show and shown only to viewers past what it covers; *How was it?*, asked once about a show finished or removed in the last two weeks, where one tap writes a `rating` line into the watch log, per person; and *Picks*, works a recommender extension suggests, each with its reason, to watch together or follow (the new `recommender` setting and docs/recommender-protocol.md).
|
|
21
|
+
- The tool's new `annotate` action keeps a recap or up to three suggested next steps with a library show; the steps show on the Continue card through @soffits/dsh-ui-actions, and starting one is written to the watch log.
|
|
22
|
+
- *Continue* from the page goes on where you stopped. Since 0.5 a room opened from the page started at the first episode, because the person's route never passed on that it was a library show.
|
|
23
|
+
- The page is built from DSH's own components (tabs, buttons, tags, state dots, icons) and @soffits/dsh-ui-kit (cards, the episode strip, tiles, times, suggested steps), with buttons 40 px tall on touch screens.
|
|
24
|
+
|
|
25
|
+
## 0.5.1
|
|
26
|
+
|
|
27
|
+
- Going back to an episode the cache already deleted, or jumping far ahead, no longer stays on loading. The episode you're on is now prepared at once, beside anything else; before, every episode that landed waited its turn in one line, so with sources that need a transcode (HEVC short dramas) the one you picked sat behind a dozen others. The next few episodes after yours are prepared one at a time, nearest first, and nothing outside that window is touched.
|
|
28
|
+
- Leaving an episode stops work on it unless it's one of the next few: its download, its transcode and its play-while-downloading copy. A copy cut off by a restart is made again instead of being offered half done.
|
|
29
|
+
- An episode whose download is already under way plays while it downloads as soon as a room comes to it, not only when someone was on it when the download started.
|
|
30
|
+
|
|
31
|
+
## 0.5.0
|
|
32
|
+
|
|
33
|
+
- Captions in the right language, for every source. The player starts the track in your language, else one in the video's own language that no machine translated, else none, and never a machine translation into a third language. The captions menu names each track in its own language (日本語, English) and marks machine-made ones *auto*. Link fetches every track a person made, plus machine-made ones only in your language and the video's own; a site's own codes that name no language (`ai-zh`) are left out. Local files follow the same rule by their file names (`ep1.zh.srt`), and text tracks inside a file go by their language.
|
|
34
|
+
- An episode plays while it downloads. Link fetches the video and the audio side by side and serves them as HLS once a few seconds are in, so a room starts in seconds instead of after the whole download and merge; the room keeps playing that copy when the file lands. Videos that have to be transcoded (local files, sources) start the same way, after their first seconds. A source's command can hand over files it is still writing with the new optional `partial` event (docs/source-protocol.md).
|
|
35
|
+
- One progress for the whole episode: the video and the audio are counted together from the start, with one size, speed and time left (estimated from the bitrate where a site announces no size), instead of the bar running once for the video and again for the audio.
|
|
36
|
+
- Watching starts alone. *Watch* (and continuing a show) opens a room only you are in, with the same progress, watch log, resume and rating as before; *Watch together* in the player opens that room to others where it stands and copies its link. Only rooms opened to others are listed. Rooms the assistant opens are shared from the start.
|
|
37
|
+
- Link looks each episode up when it fetches it, so a playlist's videos get their captions too, and episode file names are made by the hub (number, then title).
|
|
38
|
+
|
|
39
|
+
## 0.4.1
|
|
40
|
+
|
|
41
|
+
- A Link lookup of a long video with many generated subtitles no longer fails with "the page lists too much to read": the lookup asks yt-dlp for subtitle lists without the generated translations, which grew its answer past 25 MB.
|
|
42
|
+
|
|
43
|
+
## 0.4.0
|
|
44
|
+
|
|
45
|
+
- `cookies`: signed-in accounts for sites, by host, like `proxies` (`{ hosts, hostsFile, accounts }` rules). Each account is a Netscape cookies file with an optional User-Agent, belonging to a person (their sign-in id) or to everyone as the default, and optionally shared. A lookup or download uses the account of the person asking, else the default, else a shared one; a room uses the account of whoever opened it, for everyone in it. The Link card says which account a site is read with, and its qualities are what that account gets. yt-dlp reads a private copy of the cookies for each run, so the hub never changes the session it borrows, and cookie values are never logged or shown.
|
|
46
|
+
- Looking up and fetching a work and opening a room moved under DSH's `/api` (`/api/media-hub/info`, `/fetch`, `/rooms`), where the sign-in plugin says who is asking. `POST /media-hub/api/rooms`, `GET /media-hub/api/info` and `POST /media-hub/api/fetch` are gone.
|
|
47
|
+
- Errors say what happened in the viewer's language: a site that refused the request, one that wants a signed-in account, nothing at that address, or a proxy that isn't answering. yt-dlp's own output goes to the server log. A failed source is now HTTP 424 instead of 502, which proxies in front of DSH (Cloudflare among them) replaced with a page of their own, so the page only ever saw "HTTP 502". A response without the hub's JSON shows a sentence with its status instead of a bare code.
|
|
48
|
+
- Link fetches subtitles with each episode: every language the video has subtitles in, plus generated ones in your language and the video's own when nothing covers them, converted to WebVTT. The player offers them in its captions menu by language name and turns on the one in your language. Subtitles of a show from any source now reach the room (they were dropped before), and go with their episode when it is deleted.
|
|
49
|
+
- A room waiting on a download shows real progress, live for everyone in it: percent, size, speed and time left while yt-dlp fetches (video and audio counted together), then the preparing step, with a bar.
|
|
50
|
+
|
|
51
|
+
## 0.3.0
|
|
52
|
+
|
|
53
|
+
- Link reads any video or playlist page yt-dlp reads (YouTube, Vimeo, Bilibili and over a thousand more sites): it shows as one work with its thumbnail, length, uploader and episodes (a playlist's videos), and plays like a show from a source, downloaded through the rolling cache and served by DSH to every viewer. A quality picker on the card (*Auto*, a height, *Audio only*) sets yt-dlp's format choice; the show keeps it. Following a playlist adds its new videos as episodes.
|
|
54
|
+
- **Breaking:** YouTube no longer plays in an embedded player; it is one yt-dlp site like the others, so a room on it syncs as finely as a local file, works for viewers who can't reach YouTube, and is not split by ads. The assistant's tool (`videosync`) `start` takes `source: link` with `url` (and `quality`) instead of `source: youtube` with `urls`. Rooms lose their `source` field, and the watch log's `room.opened` lines no longer carry one.
|
|
55
|
+
- `proxies`: which proxy each request the hub makes itself takes, by host (`{ url, hosts, hostsFile }` rules, first match wins, others direct). Every yt-dlp call takes the rule of its page's host, a thumbnail the rule of its own host or its page's. A hosts file is read again when it changes; while it can't be read, or the proxy is down, the request fails instead of going direct. No site or country is named in the code.
|
|
56
|
+
- Pictures for everything through one pipeline and one cache (`coverCacheMb`): a source's cover through the source's command, a link's thumbnail through `proxies`, a still of the video for local files, shows without a cover and room previews. The page tries each picture in turn and shows a placeholder only when none exists. The `thumbs` route and folder are gone; `<stateDir>/thumbs` from earlier versions can be deleted.
|
|
57
|
+
- Source protocol: results and `info` may carry `url` (the work's page) and `duration` (seconds). A result's running time shows at a glance.
|
|
58
|
+
- *Ask* opens a conversation with the show or book attached to the message box as a card, through [@soffits/dsh-ui-actions](https://github.com/soffits/dsh-ui-actions) (install it as a plugin too; without it there is no *Ask*). The person writes beside the card, the sent message shows it with the hub's icon and name, and the agent gets the item as a short quote with its source and id instead of a block of Markdown and JSON.
|
|
59
|
+
- Languages: the page's words moved to `locale/<tag>.json`, one file per language, and the page now ships in French as well as English and Chinese. A language is added by adding its file; nothing in the code names a language. The sidebar `label` and source and kind labels take a string or `{ "<tag>": "text" }` (exact tag, then primary subtag, then English). The default sources' names come from the locale files (番茄 and 图书 in Chinese, Livres in French).
|
|
60
|
+
- Counts, sizes, dates, plural forms and language names are written by `Intl` for the viewer's language (sizes read "565 ko" in French; "1 episode" and "0 épisode" are right).
|
|
61
|
+
- The book language filter offers your language, the one picked and the languages in the results, instead of a fixed list.
|
|
62
|
+
- Phones: compact cards with a small fixed cover, the title and one info line beside it, and no gap under the cover; *Ask* is an icon in the card's corner; the search button stays beside the field; book filters fold behind a *Filters* button that shows how many are set; touch controls are at least 40 px. Wider screens: covers fill the card's height.
|
|
63
|
+
|
|
64
|
+
## 0.2.0
|
|
65
|
+
|
|
66
|
+
- Renamed from Video Sync to the media hub (`@soffits/dsh-media-hub`, repository soffits/dsh-media-hub). The page is *Media* in the sidebar (`label` renames it); routes moved from `/videosync` to `/media-hub`; room links are `?media-room=<id>`, and old `?videosync=<id>` links still open; an existing `$DSH_HOME/videosync` folder keeps being used. The agent tool keeps its name, `videosync`.
|
|
67
|
+
- Books: kinds have a `media` (`video`, `audio`, `book`). Book searches have filters (language, format, years, size) and cards with cover, author, year, language, origin and formats with sizes; *Download* fetches the file in the chosen format onto your shelf, *Save* hands it to the device with its proper type and name. Formats a source lacks are converted with Calibre's `ebook-convert` when it is installed (`converter`).
|
|
68
|
+
- My books: a shelf per signed-in person (through a `requestIdentity` provider; one shared shelf without one), with save, download again and delete; files kept under `bookCacheGb`.
|
|
69
|
+
- Discover searches *All sources* at once; a source that fails is named while the others still answer.
|
|
70
|
+
- *Ask* on every result and book opens a new conversation with a draft about it.
|
|
71
|
+
- Source protocol: `filters` (`--language`, `--format`, `--year-from`, `--year-to`), book fields (`formats`, `bytes`, `year`, `language`, `publisher`, `origin`) and `download --format` for one file. Default sources: fanqie (now with novels) and `bookfetch source`.
|
|
72
|
+
|
|
73
|
+
- iPhone: an episode change no longer leaves Safari on iOS stuck at "Loading…". A viewer counts as ready once the player can play (not only with 3 s buffered, which iOS never fetches while paused); a player that loads nothing while paused is started muted for a moment to make it load; after 8 s the viewer gets a "Tap to keep loading" button. Safari keeps one video element instead of preloading the next episode in a second one, which it would not let play with sound.
|
|
74
|
+
- Discover can sort the results it has (default order, most played, newest: each offered only when the results can be told apart by it) and load more: a source that has more pages says so (`next` in its search answer, `--offset` to ask for it, see docs/source-protocol.md) and a *Load more* button appends the next page, never repeating a work.
|
|
75
|
+
- Phone layout: on narrow screens the page description goes, the tabs stay at the top, library rows say the short thing first (score, status, how far you are) and the on-disk details muted below, and cards stack with a full-width action row; Discover's pickers, search and result actions fit the width (checked at 360 px). Details is a plain accent link.
|
|
76
|
+
- The plugin loads from a built `dist/` with its packages bundled in, so DSH imports it at boot without resolving any package (a link-installed copy failed to start with "Cannot find package 'ws'" after some restarts).
|
|
77
|
+
- Follow (追剧): a Follow button on a work (Discover, a library row's menu, a room's About tab). Following a work not in the library adds it as an empty show. Once a day per followed show (jittered, one at a time with a pause, through the source's command) and once when someone opens it, the host asks the source about it: a new season among the related works is added to the library as an empty show next to the earlier seasons and followed in turn; more episodes extend the season in progress. News shows in a "New" section of Watching (with a count on the tab), as chips on library rows, and in the watch log; `notifyCommand` (off by default) is run with a line of JSON on its standard input.
|
|
78
|
+
- Smoother automatic advance: the next episode loads in the background (at once for an episode under two minutes, else in the last 30 s) and is swapped in when the room moves on, so the switch passes the ready gate without a wait.
|
|
79
|
+
- A show from a source keeps its work's details in its notes (cover, title, score, popularity, episodes, status, tags, blurb, every `meta` field, related works one level deep, episode titles), taken when it is saved or watched. Library rows show the source's cover, score, status and tags, with the same Details as Discover (related works open in Discover); *Refresh info* in the row's menu asks the source again. Shows saved before this get their details once, in the background, one request at a time with a pause (`library` never repeats it by itself after a failure; use Refresh info). Episodes carry the source's titles.
|
|
80
|
+
- A room has two tabs beside the player: *Episodes* and *About* (the show's details; a related work opens in Discover in a new tab, so the room is never left by accident). The header shows the cover; at the bottom of the episode list the next season is offered with *Watch together now*.
|
|
81
|
+
- Rooms in Watching show a preview (a frame of the episode now playing, or the show's cover), who is in as overlapping avatars, and a progress bar. Viewers in a room are avatars too (picture when the sign-in plugin gives one for you, else initials), the stack opens a list with each person's state.
|
|
82
|
+
- The page has three tabs. *Watching* (the default) lists the open rooms with who is in and the episode, and the library shows someone started to continue, most recently watched first. *Library* is the library manager. *Discover* is search: first a source picker (every configured source, then *Link* for pasting a YouTube address), under it that source's own categories, then the search box. The tab, source and category are in the URL (`vs-tab`, `vs-source`, `vs-kind`), so a refresh, the back button and a link keep them; the last source and category are remembered per browser. Room links work as before. A work opened from another's related list is a focused view in Discover (with a Back control, its place in the URL as `vs-work`); related works are plain rows, so Details never nest inside Details.
|
|
83
|
+
- Ready gate: on opening a room, an episode change (including an episode still downloading) and a seek, the room waits until every viewer present can play a few seconds ahead, shows a waiting room with each viewer loading or ready, and starts everyone at one server time slightly ahead. After 10 s anyone may start without the viewers still loading. A viewer stalling mid-play for over a second pauses everyone ("Waiting for <name>") until they're ready again; stalls right after a start, or from a viewer just left out, are ignored. Someone leaving is no longer waited for; a room everybody left, or one reloaded after a restart, waits for its viewers again.
|
|
84
|
+
- Rooms with synced play, pause, seek, speed and episodes; server-timestamped state, clock-offset correction and drift correction by rate or seek; buffering holds the room briefly.
|
|
85
|
+
- Local files and episode folders, prepared for browsers (fast-start MP4, transcoding when needed), with subtitles converted to WebVTT.
|
|
86
|
+
- YouTube videos and playlists through the embed's own messaging, without YouTube's script in the DSH page.
|
|
87
|
+
- Video Sync page in the Web UI: open rooms, start a room from a YouTube link or the library, the player with episodes, viewers and who-did-what notices.
|
|
88
|
+
- `videosync` agent tool: start, list and close rooms.
|
|
89
|
+
- Rooms close by themselves 30 minutes after the last viewer leaves, or a day after creation when nobody opened them; the list shows who is watching or since when a room is empty.
|
|
90
|
+
- Library manager: posters, episodes, sizes, total and free space; delete a show or an episode, rename, keep; shows watched to the end are deleted after `autoDeleteDays` (7) unless kept; open rooms block deleting their show.
|
|
91
|
+
- Search with sources: each source is a configured command that speaks a small JSON protocol (`docs/source-protocol.md`; the `sources` setting, with a `fanqie` entry for short dramas and audiobooks by default); "Watch together now" opens a room with episode 1 and adds the rest as they download; "Save to library" downloads in the background.
|
|
92
|
+
- Watch log (`watch-log.jsonl`): rooms, viewers, episodes started and finished, where each viewer stopped. Library shows continue where they stopped. The tool gains `history`, `library` and `start` from a source's work id.
|
|
93
|
+
- Rolling cache for shows from a source: every episode is listed, only the one being watched, the next five (`cacheAhead`) and one behind (`cacheBehind`) are on disk; watched episodes fall out and are deleted, a jump to an uncached episode fetches it first, and `cacheLimitGb` (5) caps the total, least recently watched first. *Watch together now* opens the room at once. *Download all (offline)* keeps a whole show, never trimmed. The library says "cached N of M".
|
|
94
|
+
- The search box shows a loading state, drops answers older than the latest click and ignores a repeated click; Watch and Save buttons can't be pressed twice.
|
|
95
|
+
- Audio-only episodes (audiobook chapters) play in rooms.
|
|
96
|
+
- Search results are cards with cover, score, popularity (formatted per language), episodes, status and tags, and a Details view with every field the source gives and its related works and other seasons. Sources can send `cover`, `popularity`, `episode_count`, `status`, `tags`, `latest`, `meta` and (from `info`) `related`, and an optional `cover` verb; covers are fetched by the source's command, cached under `<stateDir>/covers` (`coverCacheMb`) and served on an authenticated route, never by the browser.
|
|
97
|
+
- Room list: copy the link or close a room from the list.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sakina
|
|
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,79 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Media hub for DeepSeek Harness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One page in the DSH Web UI for shows, novels, ebooks and papers. Search every source at once, watch a show together from different places with play, pause, seeking and episodes in sync, and download a book in the format you want (epub, txt, pdf...) onto your own shelf.
|
|
4
|
+
|
|
5
|
+
This plugin was called Video Sync (`@soffits/dsh-video-sync`) until 0.2.0; the repository moved from soffits/dsh-video-sync, and room links made under the old name still open. It is not related to the npm package `dsh-media-hub`, which embeds a different self-hosted app.
|
|
6
|
+
|
|
7
|
+
- **Books**: a book category (ebooks, novels, papers) gets filters for language, format, years and size. A result shows its cover, author, year, language, where the file comes from and the formats with their sizes; pick one and *Download* puts it on your shelf, then *Save* hands it to the device (Safari on iPhone offers Apple Books for an epub). With Calibre's `ebook-convert` installed, a format the source doesn't have is converted from the best one it has. **My books** in the Library tab lists what you downloaded: save again, download again, delete. Each person signed in has their own shelf when a sign-in plugin provides the `requestIdentity` service (dsh-oidc does); without one everyone shares one shelf. Files are shared between shelves and kept under `bookCacheGb`; past it the least recently used go and stay on the shelf to fetch again.
|
|
8
|
+
- **Chat about it**: every result and book has an *Ask* button that opens a new conversation with a draft quoting it, for you to finish and send.
|
|
9
|
+
|
|
10
|
+
- **Local files**: one video or a folder of episodes (numbered files play in natural order). Videos browsers can't play or seek well are remuxed, or transcoded to HLS that plays a few seconds in while the rest is made, and cached. Subtitles next to a video (`.srt`, `.ass`, `.vtt`, also `name.zh.srt`) and text subtitle tracks inside MKV files show up in the player; Chinese, Japanese and Korean legacy encodings are detected.
|
|
11
|
+
- **Link**: the address of a video or a playlist on any site [yt-dlp](https://github.com/yt-dlp/yt-dlp) reads (YouTube, Vimeo, Bilibili and over a thousand more). It shows as one work with its thumbnail, length and episodes (a playlist's videos), and plays like any show from a source: the episode being watched is downloaded first, then the next few, and every viewer streams the same file from DSH. Pick the quality before watching: *Auto* (the best up to `maxHeight`, in formats a browser plays as they are), a height, or *Audio only*. A link to a video inside a playlist plays that video; paste the playlist's own address for all of it. Captions come with each episode: every track a person made, plus machine-made ones only in your language and the video's own, never a machine translation into a third language. The player starts the one in your language, else the video's own when no machine translated it, else none, and names each track in its own language with *auto* on machine-made ones. An episode plays while it downloads: its video and audio are fetched side by side and served as HLS once a few seconds are in, and a room waiting on it shows one progress for the whole episode. Sites that need a signed-in account read the `cookies` setting; other yt-dlp options go in yt-dlp's own config file.
|
|
12
|
+
- **Sync**: the room's state lives on the server with server timestamps; each browser corrects its own clock offset and drift (under 0.3 s ignored, 0.3–2 s caught up by playing 5 % faster or slower, more than 2 s by a seek). Opening a room, switching episode and seeking go through a waiting room, as in Plex: playback holds until every viewer can play a few seconds ahead, each listed as loading or ready, then everyone starts at the same instant; after 10 s anyone may start without the ones still loading. When someone's player stalls mid-episode, everyone pauses with "Waiting for <name>" and resumes together. A dropped connection doesn't stop playback; the player resyncs when it's back.
|
|
13
|
+
- **Library**: shows (a folder of episodes, or one file) in `<stateDir>/library` and any `libraryRoots`, with a poster frame, episodes, size, the total and the free space on the disk. Delete a show or one episode, rename a show, keep it. Watched episodes are marked in the library and in the room; a show watched to the end (its last episode, or every episode) is deleted `autoDeleteDays` later unless someone keeps it, and the list says when. A show an open room plays can't be deleted or renamed. Opening a show again continues where its viewers stopped.
|
|
14
|
+
- **Sources**: one search box over *All sources* or one of them; each source is a configured command line tool that speaks a small JSON protocol ([docs/source-protocol.md](docs/source-protocol.md), the hub's public interface for extensions, see [docs/extensions.md](docs/extensions.md)) and brings its kinds. The defaults are `fanqie` (short dramas, audiobooks, novels) and `bookfetch source` (ebooks and papers); every request runs through the source's command, so any proxy its launcher enforces holds, and a wrapper for another site is one more entry. *Watch* opens it at once, for you alone (*Watch together* in the player opens that room to others where it stands and copies its link); *Save to library* adds the show; *Download all (offline)* keeps every episode on disk. Sources implement one small interface (`src/sources/index.js`).
|
|
15
|
+
- **Search results as cards**: cover, title, score, how many watched it ("36.7万次播放" or "36.7K plays", by the page language), episodes, whether it is finished, tags; *Details* shows everything the source gives (cast, heat, last update…) and the other seasons and linked works.
|
|
16
|
+
- **Pictures for everything**: a work's cover, a show's poster and a room's preview all come from the host and are cached under `<stateDir>/covers`: a source's cover through the source's own command (so its proxy keeps applying), a link's thumbnail through the `proxies` setting, and a still of the video for local files and shows without a cover. A browser never contacts a site's CDN, and a placeholder shows only when there is no picture at all.
|
|
17
|
+
- **Details read live, kept only as an offline copy**: a show from a source has its work (cover, score, popularity, tags, blurb, other fields, related works, episode titles) read from the source each time the library, a room's *About* tab or an episode list shows it; the copy saved with the show is shown, with the date, only when the source doesn't answer.
|
|
18
|
+
- **Follow**: a followed work is checked about once a day through its source (and when someone opens it). A new season is added to the library as an empty show, grouped with the earlier ones and followed too, and shows under *New* in Watching and in the watch log; more episodes extend the show. With `notifyCommand` set, that command gets one line of JSON on its standard input for each piece of news.
|
|
19
|
+
- **Rolling cache**: a show from a source lists every episode, but only a window is on disk: the episode people are on is fetched first, then the next few (`cacheAhead`, 5), and `cacheBehind` (1) watched ones stay. Watched episodes that fall out of the window are deleted (the watch log still marks them watched). Jumping to an episode that is not cached fetches it first (the room shows it as preparing), then refills the window around it. A show kept offline (*Download all (offline)*, or the library menu) is never trimmed. All cached episodes of other shows together stay under `cacheLimitGb` (5 GB): past it the least recently watched go first, never one near an open room. The library says *cached N of M* (and *offline*), and the episode list marks the ones not on disk.
|
|
20
|
+
- **Watch log**: `<stateDir>/watch-log.jsonl`, one JSON object per line: rooms opened and closed, viewers joining and leaving, episodes started and finished, and where each viewer stopped (`position` lines when someone leaves, the episode changes, the room closes, and every two minutes while playing).
|
|
21
|
+
- **Access**: only browsers signed in to DSH reach the rooms, the media and the sync channel. Names come from the sign-in plugin (dsh-oidc) when there is one.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
dsh plugin --profile web add github:soffits/dsh-media-hub
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The bundle adds two rows: `media-hub` (the page, shelves, rooms, media) and `media-hub-tools` (the assistant's `videosync` tool for rooms). Needs `ffmpeg`/`ffprobe` on the PATH for local media, `yt-dlp` for Link (keep it current: sites change), the commands of the sources you use (`fanqie` from fanqie-cli, `bookfetch` from [bookfetch-cli](https://github.com/soffits/bookfetch-cli); a source is hidden without its command), and optionally Calibre's `ebook-convert` for format conversion. Coming from Video Sync: replace the `@soffits/dsh-video-sync` package with this one; an existing `$DSH_HOME/videosync` folder keeps being used. A source's command runs in `<stateDir>/<source id>`, so nothing it writes into its working folder lands in DSH's.
|
|
30
|
+
|
|
31
|
+
## Use
|
|
32
|
+
|
|
33
|
+
- **From the page**: open **Media** in the sidebar (the `label` setting renames it). Three tabs: **Watching** (the default) lists the rooms opened to others, with who is in them and the episode, with copying a room's link or closing it, and the shows someone started, to continue; **Library** manages the shows and starts or continues one; **Discover** searches: pick a source (*All sources*, every configured one, or *Link* to paste the address of a video or playlist), then one of that source's categories, then search. The tab, source and category are in the page's URL (`?vs-tab=library`, `?vs-tab=discover&vs-source=<id>&vs-kind=<id>`), so a refresh and the back button keep them and a link can open a tab directly; the last source and category are remembered per browser.
|
|
34
|
+
- **Watching**: a card at the top for the show someone is in now, or the one you watched last, over its blurred cover: who is in the room, where it stands, a strip of its episodes (watched, now, on disk), and joining them, or continuing alone, or *Watch together* to open it to others. Optional parts, each off until switched on in `presence`: *So far*, a recap without spoilers kept with the show; *How was it?*, one tap that writes a rating into the watch log for a show finished or removed lately; and *Picks*, works a recommender extension suggests, each with its reason. Steps suggested for a show (written through the tool's `annotate`) show on the card when [@soffits/dsh-ui-actions](https://github.com/soffits/dsh-ui-actions) is installed.
|
|
35
|
+
- **From the assistant**: `videosync` with `action: start` and `source: local` plus `path`, `source: link` plus `url` (and `quality`), or `source: <source id>` plus `id` (and `offline: true` to keep every episode), returns a link to send. `list` and `close` manage rooms, `library` lists the shows, `history` summarises the watch log (shows, episodes finished, where each viewer stopped, with whom, when).
|
|
36
|
+
|
|
37
|
+
A room link looks like `https://dsh.example.com/?media-room=<room>` (DSH's advertised URL, `--public-url` when set) and opens the panel on that room.
|
|
38
|
+
|
|
39
|
+
## Languages
|
|
40
|
+
|
|
41
|
+
The page follows DSH's language setting. It ships in English, French and Chinese; its words are in `locale/<tag>.json`, one file per language, and the plugin offers whatever files are there, so a language is added by copying `locale/en.json` to `locale/<tag>.json` (a tag DSH knows, such as `de` or `pt-BR`) and translating the `ui` texts. A missing text falls back along DSH's chain for that language, ending at English. Counts, sizes, dates and language names are written by the browser's `Intl` for the viewer's language. Titles, tags and descriptions from sources stay as the source gives them.
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
| Field | Default | |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `label` | empty | Name of the sidebar entry: a string, or `{ "<tag>": "text" }` with one per language, picked by the viewer's language tag, then its primary subtag (`pt-BR` → `pt`), then `en`. Empty shows the page's own name (*Media*) in the viewer's language. |
|
|
48
|
+
| `libraryRoots` | `[]` | More folders the panel may start rooms from. |
|
|
49
|
+
| `delivery` | `origin` | `origin` serves media from DSH's own web server. `r2` (object storage with signed links) is reserved and not built yet. |
|
|
50
|
+
| `stateDir` | `$DSH_HOME/media-hub` (or an existing `$DSH_HOME/videosync`) | Open rooms, the default library folder (downloads go there), shelves and book files (`books/`), prepared media, posters, the watch log and library notes. |
|
|
51
|
+
| `maxHeight` | `1080` | Taller videos are transcoded to this height. |
|
|
52
|
+
| `threads` | `2` | ffmpeg threads; jobs run one at a time at low priority. |
|
|
53
|
+
| `emptyMinutes` | `30` | A room closes this long after its last viewer left. |
|
|
54
|
+
| `unopenedHours` | `24` | A room nobody opened yet closes this long after it was created. |
|
|
55
|
+
| `cacheDays` | `7` | Prepared media no room uses is deleted after this long. |
|
|
56
|
+
| `autoDeleteDays` | `7` | A show is deleted this long after it was watched to the end, unless kept. `0` keeps everything. |
|
|
57
|
+
| `cacheAhead` | `5` | Rolling cache: episodes kept after the one being watched. |
|
|
58
|
+
| `cacheBehind` | `1` | Rolling cache: watched episodes kept before it; older watched ones are deleted. |
|
|
59
|
+
| `cacheLimitGb` | `5` | Rolling cache: most disk (GB) cached episodes of shows from a source may use, the prepared copies included. Kept-offline shows don't count. `0` is no limit. |
|
|
60
|
+
| `notifyCommand` | `[]` | A command (program and fixed arguments) run with one line of JSON on stdin when a followed work gets a new season or new episodes. Empty runs nothing. |
|
|
61
|
+
| `presence` | Continue card on, the rest off | Which parts of Watching show: `continue` (the Continue card), `recap` (*So far*, a recap kept with the show, only for viewers past what it covers), `ratings` (*How was it?*) and `picks` (needs `recommender`). |
|
|
62
|
+
| `recommender` | none | `{ command, env }`: a command speaking [docs/recommender-protocol.md](docs/recommender-protocol.md). Empty shows no picks. |
|
|
63
|
+
| `coverCacheMb` | `50` | Most disk (MB) pictures may use (covers, posters, previews). The browser never fetches them from a site; the least recently shown are dropped past this. `0` is no limit. |
|
|
64
|
+
| `ytDlp` | `yt-dlp` | The yt-dlp command; Link is hidden without it. |
|
|
65
|
+
| `proxies` | `[]` | Which proxy each outbound request takes, by host: a list of `{ url, hosts, hostsFile }`. `url` is `socks5h://host:port` (names resolved by the proxy), `socks5://`, `socks4://`, `http://` or `https://`; `hosts` are patterns (`example.com` is that host and every host under it, `.example` every host ending so, `*` every host); `hostsFile` a file of more patterns, one per line, `#` for comments, read again when it changes. The first rule naming a host wins; other hosts go direct. Every yt-dlp call takes the rule of the page's host, and a thumbnail the rule of its own host or its page's, so a picture on an unlisted CDN goes the way its site does. While a hosts file can't be read, or the proxy is down, the request fails rather than go direct. Sources' commands keep their own network setup. |
|
|
66
|
+
| `cookies` | `[]` | Signed-in accounts for sites, by host: a list of `{ hosts, hostsFile, accounts }`, hosts written as in `proxies`. Each account is `{ person, name, file, userAgent, share }`: `file` a Netscape cookies file of a signed-in session (kept fresh by whatever holds that session; the hub only reads it and gives yt-dlp a private copy per run), `userAgent` the User-Agent that session uses, `person` the owner's sign-in id (empty for the default account everyone without their own uses), `name` what the page shows, `share` whether others without an account of their own may use it. A lookup or download uses the account of the person asking, else the default, else a shared one; a room uses the account of whoever opened it. |
|
|
67
|
+
| `bookCacheGb` | `5` | Most disk (GB) downloaded books may use; past it the least recently used files go and stay on their shelves to fetch again. `0` is no limit. |
|
|
68
|
+
| `converter` | `ebook-convert` | Calibre's converter; when installed, books can be downloaded in formats their source lacks. Empty turns conversion off. |
|
|
69
|
+
| `sources` | `fanqie`, `bookfetch` | The sources: a list of `{ id, label, kinds: [{ id, label, media }], filters, command: [program, ...fixed arguments], env }`; `label` is the source's name in Discover's picker and each kind's `label` its category, each a string or `{ "<tag>": "text" }` like the sidebar's; left empty, the page uses its own words for that id (`source.name.<id>`, `kind.<id>` in `locale/`), else the id; `media` is `video`, `audio` or `book`; `filters` lists the search filters the command understands (`language`, `format`, `year`). The list replaces the default, so keep the default entries when adding one; an empty list turns sources off. See [docs/source-protocol.md](docs/source-protocol.md). |
|
|
70
|
+
|
|
71
|
+
The tools row takes `agentName` (shown as who opened the assistant's rooms) and `waitSeconds` (how long `start` waits for the first episode to be ready).
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
`npm test` runs the unit tests (ffmpeg tests skip without ffmpeg). `npm run test:browsers` boots a throwaway DSH home with this checkout linked in and drives two Chromium contexts through a room: play, pause, seek, rate-based and seek-based drift correction, an episode switch and a reconnect; then the tabs with their state in the URL, the source and category pickers, a search through a stand-in source command, *Watch together now* with the room growing as episodes arrive, the watch log, watched marks, deleting an episode and a show from the library, and a link looked up and watched in a chosen quality through a stand-in yt-dlp, with every outbound call routed to a proxy that is down so the test never reaches the network.
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT
|
package/client.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Browser half of dsh-media-hub: the sidebar entry (named by the `label`
|
|
3
|
+
* setting, else the page's own name in the viewer's language) and its page
|
|
4
|
+
* in the main column. Its words come from the plugin's locale/ folder.
|
|
5
|
+
*
|
|
6
|
+
* Plain JavaScript in DSH's Client module format (no build step); React
|
|
7
|
+
* comes from the page's module table. This file registers the entry, the
|
|
8
|
+
* words and the styles; the page itself (search, rooms, library, one room)
|
|
9
|
+
* lives in browser modules the Host half serves under /media-hub/web/
|
|
10
|
+
* (page.js and the modules it imports), loaded when the page first opens.
|
|
11
|
+
*
|
|
12
|
+
* A link with ?media-room=<room> (or ?videosync=<room>, as links from the
|
|
13
|
+
* time this was Video Sync have it) opens the page on that room; one with
|
|
14
|
+
* the page's own vs-* parameters (tab, source, category: web/nav.js) opens
|
|
15
|
+
* the panel on them. "Chat about this" on a card starts a conversation
|
|
16
|
+
* through the Web UI's workspace service with a draft the person sends.
|
|
17
|
+
*/
|
|
18
|
+
window.__ModuleLoader__.load({
|
|
19
|
+
id: '@soffits/dsh-media-hub',
|
|
20
|
+
factory(require) {
|
|
21
|
+
const React = require('react')
|
|
22
|
+
const h = React.createElement
|
|
23
|
+
const { useState, useEffect } = React
|
|
24
|
+
|
|
25
|
+
const NS = 'dsh-media-hub'
|
|
26
|
+
const PANEL = 'dsh-media-hub'
|
|
27
|
+
const STYLE_ID = 'dsh-media-hub'
|
|
28
|
+
const LINK_PARAMS = ['media-room', 'videosync']
|
|
29
|
+
const web = name => new URL(`media-hub/web/${name}`, document.baseURI).href
|
|
30
|
+
|
|
31
|
+
function SidebarIcon({ size }) {
|
|
32
|
+
const stroke = { stroke: 'currentColor', strokeWidth: 1.2, strokeLinecap: 'round', strokeLinejoin: 'round' }
|
|
33
|
+
return h('svg', { width: size, height: size, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': true, focusable: 'false' },
|
|
34
|
+
h('rect', { x: 1.75, y: 2.75, width: 12.5, height: 8.5, rx: 1.5, ...stroke }),
|
|
35
|
+
h('path', { d: 'M6.9 5.3v3.4L9.7 7 6.9 5.3Z', fill: 'currentColor' }),
|
|
36
|
+
h('path', { d: 'M4.5 13.6c1 .5 2.2.8 3.5.8s2.5-.3 3.5-.8', ...stroke }))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* "Ask" through @soffits/dsh-ui-actions (ctx.uiActions), when it is installed: a new conversation with the
|
|
41
|
+
* item attached as a card. `source` names this plugin on the card; set in apply.
|
|
42
|
+
*/
|
|
43
|
+
let uiActions = null
|
|
44
|
+
let sourceName = () => ''
|
|
45
|
+
const chat = {
|
|
46
|
+
available: () => uiActions !== null,
|
|
47
|
+
start: about => uiActions?.chat({ source: '@soffits/dsh-media-hub', sourceName: sourceName(), ...about }),
|
|
48
|
+
}
|
|
49
|
+
/** DSH's locale store, set in apply before anything renders, so the page renders again when the viewer switches language. */
|
|
50
|
+
let localeStore
|
|
51
|
+
const activeLanguage = () => localeStore.getSnapshot().active
|
|
52
|
+
// Called through the store, never detached: its methods read their own `this`.
|
|
53
|
+
const subscribeLocale = listener => localeStore.subscribe(listener)
|
|
54
|
+
|
|
55
|
+
/** JSON from one of the Host's routes, or `fallback` (logged) when it does not answer. */
|
|
56
|
+
const getJson = (path, fallback) => fetch(new URL(path, document.baseURI))
|
|
57
|
+
.then(response => (response.ok ? response.json() : Promise.reject(new Error(`HTTP ${response.status}`))))
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
console.warn('[media-hub] %s: %s', path, error.message)
|
|
60
|
+
return fallback
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* What the entry and the page need before they show: the words (one table per locale/<tag>.json, so a
|
|
65
|
+
* language is added by adding its file), the `label` setting, and the language lookup for it.
|
|
66
|
+
*/
|
|
67
|
+
const loadStart = () => Promise.all([
|
|
68
|
+
getJson('media-hub/api/locales', {}),
|
|
69
|
+
getJson('media-hub/api/settings', {}),
|
|
70
|
+
import(web('i18n.js')),
|
|
71
|
+
])
|
|
72
|
+
|
|
73
|
+
/** DSH's own components, shared through the page's module table. */
|
|
74
|
+
const primitives = require('@deepseek-ai/dsh-client-ui-primitives')
|
|
75
|
+
/** The shared kit (ctx.uiKit), once it is there; the page waits for it. */
|
|
76
|
+
let kit = null
|
|
77
|
+
const kitListeners = new Set()
|
|
78
|
+
const kitStore = {
|
|
79
|
+
set(value) { kit = value; for (const listener of kitListeners) listener() },
|
|
80
|
+
subscribe(listener) { kitListeners.add(listener); return () => { kitListeners.delete(listener) } },
|
|
81
|
+
get: () => kit,
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The page's modules, loaded once and handed this page's React, DSH's components and the kit. */
|
|
85
|
+
let pageModule
|
|
86
|
+
const loadPage = () => {
|
|
87
|
+
pageModule ??= Promise.all([import(web('ui.js')), import(web('page.js'))]).then(([ui, page]) => {
|
|
88
|
+
ui.init(React, { primitives, kit })
|
|
89
|
+
ui.setChat(chat)
|
|
90
|
+
return page
|
|
91
|
+
})
|
|
92
|
+
return pageModule
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** A room asked for by the page's URL (?media-room=<id> or ?videosync=<id>), taken once. */
|
|
96
|
+
let linkedRoom = null
|
|
97
|
+
const takeLinkedRoom = () => {
|
|
98
|
+
const params = new URLSearchParams(location.search)
|
|
99
|
+
const param = LINK_PARAMS.find(name => params.get(name) !== null)
|
|
100
|
+
if (param === undefined) return
|
|
101
|
+
linkedRoom = params.get(param)
|
|
102
|
+
params.delete(param)
|
|
103
|
+
const query = params.toString()
|
|
104
|
+
history.replaceState(history.state, '', `${location.pathname}${query ? `?${query}` : ''}${location.hash}`)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function MediaHubPage({ translate }) {
|
|
108
|
+
const language = React.useSyncExternalStore(subscribeLocale, activeLanguage)
|
|
109
|
+
// A new function per language, so every view that keeps text derived from `t` builds it again;
|
|
110
|
+
// `t.language` is the viewer's tag, for Intl and for texts given per language.
|
|
111
|
+
const t = React.useMemo(() => Object.assign((...args) => translate(...args), { language }), [translate, language])
|
|
112
|
+
const [initialRoom] = useState(() => {
|
|
113
|
+
const id = linkedRoom
|
|
114
|
+
linkedRoom = null
|
|
115
|
+
return id
|
|
116
|
+
})
|
|
117
|
+
const [page, setPage] = useState(null)
|
|
118
|
+
const [error, setError] = useState(null)
|
|
119
|
+
const ready = React.useSyncExternalStore(kitStore.subscribe, kitStore.get) !== null
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (!ready) return undefined
|
|
122
|
+
let live = true
|
|
123
|
+
loadPage().then(module => { if (live) setPage(module) }, (reason) => {
|
|
124
|
+
pageModule = undefined
|
|
125
|
+
if (live) setError(reason.message)
|
|
126
|
+
})
|
|
127
|
+
return () => { live = false }
|
|
128
|
+
}, [ready])
|
|
129
|
+
return h('div', { className: 'vsync-page' },
|
|
130
|
+
page !== null && h(page.Page, { t, initialRoom }),
|
|
131
|
+
error && h('p', { className: 'vsync-error', role: 'alert', style: { padding: 24 } }, error))
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
inject: ['slots', 'locale'],
|
|
136
|
+
apply(ctx) {
|
|
137
|
+
const t = ctx.locale.bind(NS)
|
|
138
|
+
localeStore = ctx.locale
|
|
139
|
+
sourceName = () => t('panel')
|
|
140
|
+
ctx.inject(['uiKit'], (scope) => {
|
|
141
|
+
scope.effect(() => {
|
|
142
|
+
kitStore.set(scope.uiKit)
|
|
143
|
+
return () => kitStore.set(null)
|
|
144
|
+
}, 'media-hub: kit')
|
|
145
|
+
})
|
|
146
|
+
ctx.inject(['uiActions'], (scope) => {
|
|
147
|
+
scope.effect(() => {
|
|
148
|
+
uiActions = scope.uiActions
|
|
149
|
+
const off = uiActions.registerSource({ id: '@soffits/dsh-media-hub', name: () => sourceName(), icon: SidebarIcon })
|
|
150
|
+
return () => { off(); uiActions = null }
|
|
151
|
+
}, 'media-hub: ask')
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
ctx.effect(() => {
|
|
155
|
+
if (typeof document === 'undefined' || document.getElementById(STYLE_ID)) return () => {}
|
|
156
|
+
const tag = document.createElement('link')
|
|
157
|
+
tag.id = STYLE_ID
|
|
158
|
+
tag.rel = 'stylesheet'
|
|
159
|
+
tag.href = web('panel.css')
|
|
160
|
+
tag.dataset.plugin = '@soffits/dsh-media-hub'
|
|
161
|
+
document.head.appendChild(tag)
|
|
162
|
+
return () => tag.remove()
|
|
163
|
+
}, 'media-hub: styles')
|
|
164
|
+
|
|
165
|
+
// The words register first, so neither the entry nor the page ever shows a bare key.
|
|
166
|
+
ctx.effect(() => {
|
|
167
|
+
let live = true
|
|
168
|
+
const disposers = []
|
|
169
|
+
loadStart().then(([words, settings, { pick }]) => {
|
|
170
|
+
if (!live) return
|
|
171
|
+
try {
|
|
172
|
+
disposers.push(ctx.locale.register(NS, words))
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.warn('[media-hub] words: %s', error.message)
|
|
175
|
+
}
|
|
176
|
+
const label = settings.label ?? ''
|
|
177
|
+
sourceName = () => pick(label, activeLanguage()).trim() || t('panel')
|
|
178
|
+
disposers.push(ctx.slots.inject('main', () => ctx.slots.register({
|
|
179
|
+
name: 'main',
|
|
180
|
+
key: PANEL,
|
|
181
|
+
locale: NS,
|
|
182
|
+
inject: () => ({ translate: t }),
|
|
183
|
+
}, MediaHubPage)))
|
|
184
|
+
disposers.push(ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
185
|
+
name: 'sidebar.panellist',
|
|
186
|
+
id: PANEL,
|
|
187
|
+
order: 12,
|
|
188
|
+
locale: NS,
|
|
189
|
+
label: () => sourceName(),
|
|
190
|
+
}, SidebarIcon)))
|
|
191
|
+
})
|
|
192
|
+
return () => {
|
|
193
|
+
live = false
|
|
194
|
+
for (const dispose of disposers.reverse()) dispose()
|
|
195
|
+
}
|
|
196
|
+
}, 'media-hub: words and entries')
|
|
197
|
+
|
|
198
|
+
// A link to a room, or to a tab, opens this panel once it is registered.
|
|
199
|
+
ctx.effect(() => {
|
|
200
|
+
takeLinkedRoom()
|
|
201
|
+
let timer
|
|
202
|
+
let live = true
|
|
203
|
+
const open = () => {
|
|
204
|
+
let tries = 0
|
|
205
|
+
timer = setInterval(() => {
|
|
206
|
+
const layout = ctx.get('layout')
|
|
207
|
+
try {
|
|
208
|
+
layout?.selectPanel(PANEL)
|
|
209
|
+
if (layout) clearInterval(timer)
|
|
210
|
+
} catch {
|
|
211
|
+
// The main slot entry is not registered yet.
|
|
212
|
+
}
|
|
213
|
+
if (++tries > 50) clearInterval(timer)
|
|
214
|
+
}, 100)
|
|
215
|
+
}
|
|
216
|
+
if (linkedRoom !== null) open()
|
|
217
|
+
else import(web('nav.js')).then(({ hasNavParams }) => { if (live && hasNavParams(location.search)) open() }, () => {})
|
|
218
|
+
return () => { live = false; clearInterval(timer) }
|
|
219
|
+
}, 'media-hub: room link')
|
|
220
|
+
},
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
})
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Bundle layer for dsh-media-hub. The hub row serves the page (search,
|
|
2
|
+
# library, shelves, rooms) and the room sync channel; the tools row gives
|
|
3
|
+
# agents the videosync tool for watch-together rooms. Disable it, or mount
|
|
4
|
+
# `@soffits/dsh-media-hub/tools` in one agent preset instead, to limit who
|
|
5
|
+
# gets the tool.
|
|
6
|
+
- insert:
|
|
7
|
+
- id: media-hub
|
|
8
|
+
name: '@soffits/dsh-media-hub'
|
|
9
|
+
config: {}
|
|
10
|
+
- id: media-hub-tools
|
|
11
|
+
name: '@soffits/dsh-media-hub/tools'
|