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 + + + + + +--- +```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 }} + +