Files

11 KiB
Raw Permalink Blame History

Herald

A Jellyfin plugin for two small jobs:

  • Notices. Admins write a message, every addressed user sees it once as a popup in the web client. A notice can require an explicit "Accept", and the admin can see who responded and who has not.
  • Watch-time stats. Approximate time each user spent watching over the last weeks, as a sortable table in the dashboard.

Built for Jellyfin 10.11.x (compiled against 10.11.11, net9.0).

Known limitation: web client only

Notices are shown by a script running inside jellyfin-web. That covers the browser, Jellyfin Media Player / the desktop app, and mobile apps as far as they wrap the web client.

Native clients never show notices: Android TV, Swiftfin, Kodi, Roku, Findroid, Infuse and similar apps do not load jellyfin-web. A user who only uses such a client stays in the "not yet" list of a notice until they open the web client once. Do not rely on a must-accept notice to gate access; it does not block anything on the server.

Watch-time stats are collected on the server and cover all clients.

Installation

From a plugin repository

  1. In Jellyfin: Dashboard → Plugins → Manage Repositories → New Repository, enter https://git.joshicodes.de/JoshiCodes/jellyfin-herald/raw/branch/main/manifest.json.
  2. Install Herald from the catalogue and restart the server.

Manually

  1. Take herald_<version>.zip from a release, or build it yourself (see Building).
  2. Unpack it into plugins/Herald_<version>/ inside the Jellyfin data directory, for example /config/plugins/Herald_1.0.0.0/ in the official container. The folder holds Jellyfin.Plugin.Herald.dll and meta.json.
  3. Restart Jellyfin. The log shows Loaded plugin: Herald.

Herald has its own entry in the dashboard sidebar, in the Plugins section. The same page opens from Dashboard → Plugins → Herald.

Getting the popup into the web client

The server part works on its own. For notices to appear, the client script (/Herald/client.js) has to be loaded by jellyfin-web. There are three ways.

Install the File Transformation plugin (repository URL https://www.iamparadox.dev/jellyfin/plugins/manifest.json) and restart. Herald registers itself at startup and File Transformation adds one script tag to the index.html it serves. Nothing on disk is changed.

The log tells you which case you are in:

Registered the Herald client script with File Transformation 3.0.3.0

or, if it is missing:

The File Transformation plugin is not installed, so the Herald client script is not injected ...

File Transformation releases are tied to exact Jellyfin versions, so pick the build that matches your server.

To check the result, open http://<server>/web/index.html and look for data-herald-client in the source. Other plugins that use File Transformation (MediaBar, Home Screen Sections, Jellyfin Enhanced and so on) can be installed alongside.

Fallback: JavaScript Injector

With the JavaScript Injector plugin, add a script with this content and enable it:

(function () {
    var script = document.createElement('script');
    script.src = '../Herald/client.js';
    script.defer = true;
    document.head.appendChild(script);
})();

Fallback: edit index.html

Add this line right before </body> in index.html of your jellyfin-web folder (/usr/share/jellyfin/web/ on most Linux packages, /jellyfin/jellyfin-web/ in the official container):

<script defer src="../Herald/client.js"></script>

This is overwritten by every Jellyfin update.

Jellyfin 10.11 has no "Custom HTML" setting in the dashboard. The branding page only takes CSS and a login disclaimer, neither of which can load a script.

Using it

Notices tab

  • New notice: title, message, whether it has to be accepted, whether it is enabled, and who gets it (all users, or users picked from a list).
  • Wait before "Accept" can be clicked: for a must-accept notice, the number of seconds (0 to 600) the Accept button stays locked. It shows a countdown, and only time with the tab in view counts.
  • The message is plain text and line breaks are kept. A small Markdown subset is understood: **bold**, *italic*, [text](https://…), and lines starting with - or 1. as lists. HTML is not interpreted; it shows up as text.
  • Enabled switches a notice off without deleting it.
  • Re-show to everyone shows the notice again to all addressed users, including those who already responded. Editing a notice does not do that.
  • Responses lists who accepted or dismissed and when, and who is still missing.

What users see

One notice at a time, oldest first. A normal notice has a Close button; clicking outside or pressing Escape also closes it and counts as dismissed. A must-accept notice has only an Accept button; clicking outside and Escape do nothing. If a wait is set, the button reads Accept (12) and unlocks when the countdown reaches zero. The script asks for new notices after login, after a user switch, and then every 10 minutes while the tab is visible.

Stats tab

Per user: watch time over the last 7 and 30 days, plays in the last 30 days, and last activity. Click a column header to sort.

API

All routes are under /Herald. Authentication is Jellyfin's normal Authorization: MediaBrowser Token="…" header. Responses use Jellyfin's usual PascalCase JSON; request bodies are accepted in any casing. Ids are GUIDs.

Method Route Access Purpose
GET /Herald/client.js anyone The client script.
GET /Herald/Notices/Pending signed-in user Enabled notices addressed to the caller that they have not responded to at the current revision, oldest first.
POST /Herald/Notices/{id}/Ack signed-in user Body { "revision": 1, "action": "Accepted" } (Accepted or Dismissed). 204 on success, 400 if a must-accept notice is dismissed, 404 if the notice is gone or not addressed to the caller, 409 if the revision is outdated.
GET /Herald/Notices admin All notices.
GET /Herald/Notices/{id} admin One notice.
POST /Herald/Notices admin Create. Body: Title, Body, RequireAccept, AcceptDelaySeconds (0 to 600, ignored unless RequireAccept), Enabled, Target: { AllUsers, UserIds }.
PUT /Herald/Notices/{id} admin Update, same body. Keeps the revision.
DELETE /Herald/Notices/{id} admin Delete the notice and its responses.
POST /Herald/Notices/{id}/Reshow admin Bump the revision.
GET /Herald/Notices/{id}/Acks admin Responses to the current revision (UserName, Action, Timestamp) and the addressed users still pending.
GET /Herald/Stats?days=30 admin Per user: UserName, WatchedSeconds, WatchedHours, PlayCount, LastActivity. days is 1 to 90 and includes today.

A notice looks like this:

{
  "Id": "0aadc31081754558a45ffc79dd49a820",
  "Title": "House rules",
  "Body": "Be nice.",
  "RequireAccept": true,
  "AcceptDelaySeconds": 15,
  "Enabled": true,
  "Target": { "AllUsers": false, "UserIds": ["21b3bac6acfe496bbca02a21c21e36d4"] },
  "Revision": 2,
  "CreatedAt": "2026-11-13T16:57:12.5166578Z",
  "UpdatedAt": "2026-11-13T16:57:12.9794785Z"
}

How the stats are calculated

Clients report to the server when playback starts, every few seconds while it runs, and when it stops. Herald listens to those reports:

  • The time between two consecutive reports of the same playback is added to the user's total, measured on the server's clock.
  • Nothing is added for a stretch that began with a "paused" report.
  • A single gap adds at most 60 seconds. After 5 minutes without a report the playback counts as closed and the gap adds nothing.
  • Each playback start counts as one play.
  • Only one row per user and day is stored (watched seconds, plays, last activity). There is no per-item or per-event history. Rows older than 90 days are deleted by the scheduled task Clean up Herald watch-time stats, daily at 03:30.
  • "Day" means the server's local day. Time that crosses midnight is split between both days.

Where the numbers are off:

  • It measures playing, not watching. A film running in an empty room counts in full.
  • Buffering counts as long as the client keeps reporting and does not report itself as paused.
  • Sparse reporters are undercounted. A client that reports less often than once a minute only gets 60 seconds per report.
  • Playback speed is ignored. An hour at 2× is an hour of watch time for two hours of content.
  • Plays are starts, not completions. Opening a film for ten seconds is a play. Each episode of a binge is a play.
  • Lost stop reports (app killed, network gone) lose up to the last reporting interval, usually a few seconds.
  • Sessions with several users attached credit the full time to each of them.
  • Offline playback of downloaded media is invisible to the server.
  • Counting starts when the plugin is installed. Nothing is back-filled from Jellyfin's play history, and time zone changes of the server shift which day later playback is booked on.

Data

Everything is in one SQLite file, herald/herald.db in Jellyfin's data directory (/config/data/herald/herald.db in the official container). It holds the notices, the responses and the daily watch-time rows. Deleting the file while the server is stopped resets the plugin.

The plugin uses the SQLite library that ships with Jellyfin and bundles none of its own.

Building

Requires the .NET 9 SDK.

dotnet build -c Release
dotnet test -c Release

Package with jprm:

pip install jprm
mkdir -p artifacts
jprm plugin build . --output artifacts

This writes artifacts/herald_<version>.zip. The Jellyfin version, target framework and SQLite version are set in Directory.Build.props; targetAbi is in build.yaml.

Releasing

The version lives in build.yaml (version) and Directory.Build.props (Version, AssemblyVersion, FileVersion); keep them equal, the workflow fails otherwise. Put the release notes in changelog in build.yaml.

Every push to main builds and tests. If the version has no v<version> tag yet, the workflow (.gitea/workflows/build.yaml, Gitea Actions) also creates that tag and a release with the plugin zip, adds the version to manifest.json and commits that file back to main. So a release is: bump the version, push, and pull the manifest commit afterwards.

Hosting your own repository

The manifest.json in the source tree is a complete plugin repository; the URL under Installation is its raw link on main. A copy is attached to every release.

To host it elsewhere, build the manifest yourself:

jprm repo init ./repo
jprm repo add --plugin-url https://example.org/herald/herald_1.0.0.0.zip ./repo artifacts/herald_1.0.0.0.zip

Serve the resulting manifest.json and the zip over HTTP(S) and add the manifest URL in Jellyfin.

License

GPL-3.0, see LICENSE.