Enhancement: add maxShowNowPlayingCount option for Emby and Jellyfin widgets

This commit is contained in:
GodD6366 2024-09-24 19:36:54 +08:00
parent 8c1e50d9e7
commit fadde8c266
4 changed files with 11 additions and 1 deletions

View File

@ -9,6 +9,8 @@ You can create an API key from inside Emby at `Settings > Advanced > Api Keys`.
As of v0.6.11 the widget supports fields `["movies", "series", "episodes", "songs"]`. These blocks are disabled by default but can be enabled with the `enableBlocks` option, and the "Now Playing" feature (enabled by default) can be disabled with the `enableNowPlaying` option. As of v0.6.11 the widget supports fields `["movies", "series", "episodes", "songs"]`. These blocks are disabled by default but can be enabled with the `enableBlocks` option, and the "Now Playing" feature (enabled by default) can be disabled with the `enableNowPlaying` option.
After version v0.9.10, Add `maxShowNowPlayingCount` option to limit the number of Now Playing items displayed.
```yaml ```yaml
widget: widget:
type: emby type: emby
@ -19,4 +21,5 @@ widget:
enableUser: true # optional, defaults to false enableUser: true # optional, defaults to false
showEpisodeNumber: true # optional, defaults to false showEpisodeNumber: true # optional, defaults to false
expandOneStreamToTwoRows: false # optional, defaults to true expandOneStreamToTwoRows: false # optional, defaults to true
maxShowNowPlayingCount: 2 # optional, defaults to Infinity
``` ```

View File

@ -9,6 +9,8 @@ You can create an API key from inside Jellyfin at `Settings > Advanced > Api Key
As of v0.6.11 the widget supports fields `["movies", "series", "episodes", "songs"]`. These blocks are disabled by default but can be enabled with the `enableBlocks` option, and the "Now Playing" feature (enabled by default) can be disabled with the `enableNowPlaying` option. As of v0.6.11 the widget supports fields `["movies", "series", "episodes", "songs"]`. These blocks are disabled by default but can be enabled with the `enableBlocks` option, and the "Now Playing" feature (enabled by default) can be disabled with the `enableNowPlaying` option.
After version v0.9.10, Add `maxShowNowPlayingCount` option to limit the number of Now Playing items displayed.
```yaml ```yaml
widget: widget:
type: jellyfin type: jellyfin
@ -19,4 +21,5 @@ widget:
enableUser: true # optional, defaults to false enableUser: true # optional, defaults to false
showEpisodeNumber: true # optional, defaults to false showEpisodeNumber: true # optional, defaults to false
expandOneStreamToTwoRows: false # optional, defaults to true expandOneStreamToTwoRows: false # optional, defaults to true
maxShowNowPlayingCount: 2 # optional, defaults to Infinity
``` ```

View File

@ -397,6 +397,7 @@ export function cleanServiceGroups(groups) {
// emby, jellyfin // emby, jellyfin
enableBlocks, enableBlocks,
enableNowPlaying, enableNowPlaying,
maxShowNowPlayingCount,
// emby, jellyfin, tautulli // emby, jellyfin, tautulli
enableUser, enableUser,
@ -543,6 +544,7 @@ export function cleanServiceGroups(groups) {
if (["emby", "jellyfin"].includes(type)) { if (["emby", "jellyfin"].includes(type)) {
if (enableBlocks !== undefined) cleanedService.widget.enableBlocks = JSON.parse(enableBlocks); if (enableBlocks !== undefined) cleanedService.widget.enableBlocks = JSON.parse(enableBlocks);
if (enableNowPlaying !== undefined) cleanedService.widget.enableNowPlaying = JSON.parse(enableNowPlaying); if (enableNowPlaying !== undefined) cleanedService.widget.enableNowPlaying = JSON.parse(enableNowPlaying);
if (maxShowNowPlayingCount !== undefined) cleanedService.widget.maxShowNowPlayingCount = JSON.parse(maxShowNowPlayingCount);
} }
if (["emby", "jellyfin", "tautulli"].includes(type)) { if (["emby", "jellyfin", "tautulli"].includes(type)) {
if (expandOneStreamToTwoRows !== undefined) if (expandOneStreamToTwoRows !== undefined)

View File

@ -241,6 +241,7 @@ export default function Component({ service }) {
const enableUser = !!service.widget?.enableUser; // default is false const enableUser = !!service.widget?.enableUser; // default is false
const expandOneStreamToTwoRows = service.widget?.expandOneStreamToTwoRows !== false; // default is true const expandOneStreamToTwoRows = service.widget?.expandOneStreamToTwoRows !== false; // default is true
const showEpisodeNumber = !!service.widget?.showEpisodeNumber; // default is false const showEpisodeNumber = !!service.widget?.showEpisodeNumber; // default is false
const maxShowNowPlayingCount = service.widget?.maxShowNowPlayingCount ?? Infinity; // default is Infinity
if (!sessionsData || !countData) { if (!sessionsData || !countData) {
return ( return (
@ -273,7 +274,8 @@ export default function Component({ service }) {
return -1; return -1;
} }
return 0; return 0;
}); })
.slice(0, maxShowNowPlayingCount);
if (playing.length === 0) { if (playing.length === 0) {
return ( return (