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.
After version v0.9.10, Add `maxShowNowPlayingCount` option to limit the number of Now Playing items displayed.
```yaml
widget:
type: emby
@ -19,4 +21,5 @@ widget:
enableUser: true # optional, defaults to false
showEpisodeNumber: true # optional, defaults to false
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.
After version v0.9.10, Add `maxShowNowPlayingCount` option to limit the number of Now Playing items displayed.
```yaml
widget:
type: jellyfin
@ -19,4 +21,5 @@ widget:
enableUser: true # optional, defaults to false
showEpisodeNumber: true # optional, defaults to false
expandOneStreamToTwoRows: false # optional, defaults to true
maxShowNowPlayingCount: 2 # optional, defaults to Infinity
```

View File

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

View File

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