diff --git a/widgets/jellyfin-now-playing/README.md b/widgets/jellyfin-now-playing/README.md new file mode 100644 index 00000000..e7d373ef --- /dev/null +++ b/widgets/jellyfin-now-playing/README.md @@ -0,0 +1,140 @@ + + +# Jellyfin Now Playing Widget + +Displays currently playing sessions on a jellyfin server, with metadata. Displays track name, artist, album, user and device information. Also shows a minimal progress bar + + +![](preview.png) + + +--- +```yaml + - type: custom-api + cache: 1m + title: Now Playing + url: ${JELLYFIN_URL}/Sessions + headers: + X-Emby-Token: ${API_TOKEN} + template: | + {{ $sessions := .JSON.Array "" }} + {{ $found := false }} + {{ $showArt := true }} + + {{ range $index, $s := $sessions }} + + {{ $type := $.JSON.String (printf "%d.NowPlayingItem.MediaType" $index) }} + + {{ if eq $type "Audio" }} + {{ $found = true }} + + {{ $user := $.JSON.String (printf "%d.UserName" $index) }} + {{ $device := $.JSON.String (printf "%d.DeviceName" $index) }} + {{ $client := $.JSON.String (printf "%d.Client" $index) }} + + {{ if eq $device "" }} + {{ $device = $client }} + {{ end }} + + {{ $name := $.JSON.String (printf "%d.NowPlayingItem.Name" $index) }} + {{ $artist := $.JSON.String (printf "%d.NowPlayingItem.Artists.0" $index) }} + {{ $album := $.JSON.String (printf "%d.NowPlayingItem.Album" $index) }} + {{ $albumId := $.JSON.String (printf "%d.NowPlayingItem.AlbumId" $index) }} + + {{ $position := $.JSON.Float (printf "%d.PlayState.PositionTicks" $index) }} + {{ $runtime := $.JSON.Float (printf "%d.NowPlayingItem.RunTimeTicks" $index) }} + + {{ $progress := 0.0 }} + {{ if gt $runtime 0.0 }} + {{ $progress = mul (div $position $runtime) 100.0 }} + {{ end }} + +
+ + {{ if and $showArt (ne $albumId "") }} + + {{ end }} + +
+ +
+ {{ $device }} ยท {{ $user }} +
+ +
+ {{ $name }} +
+ +
+ {{ $artist }} +
+ +
+ {{ $album }} +
+ +
+
+
+
+
+ +
+
+ + {{ end }} + + {{ end }} + + {{ if not $found }} +
Nothing playing
+ {{ end }} +``` + + +## Configuration + +### Required environment variables + +| Variable | Description | +|----------|-------------| +| `JELLYFIN_URL` | Base URL of your Jellyfin server (e.g. `https://jellyfin.example.com`) | +| `API_TOKEN` | Jellyfin API key / access token | + +--- + +## Note on Album Artwork + +Album artwork is enabled by default. + +To disable it (recommended if you want to avoid exposing API tokens in image URLs), set: + +```go +{{ $showArt := false }} +``` + +inside the widget template. + +--- + diff --git a/widgets/jellyfin-now-playing/meta.yaml b/widgets/jellyfin-now-playing/meta.yaml new file mode 100644 index 00000000..7260afa4 --- /dev/null +++ b/widgets/jellyfin-now-playing/meta.yaml @@ -0,0 +1,3 @@ +title: Jellyfin Now Playing +description: Displays songs currently playing on a jellyfin server, with multiple user and device streams. +author: fayezh26 diff --git a/widgets/jellyfin-now-playing/preview.png b/widgets/jellyfin-now-playing/preview.png new file mode 100644 index 00000000..ae3299cb Binary files /dev/null and b/widgets/jellyfin-now-playing/preview.png differ