mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-09-03 05:10:00 +03:00
fix(jellyfin): Gaurd against active session without now playing data
This commit is contained in:
@@ -110,9 +110,13 @@ export interface ConfigMeta {
|
||||
|
||||
export type SourceData = (PlayObject | PlayerStateData);
|
||||
|
||||
export interface PlayerStateData {
|
||||
platformId: PlayPlatformId
|
||||
export interface PlayerStateData extends PlayerStateDataMaybePlay {
|
||||
play: PlayObject
|
||||
}
|
||||
|
||||
export interface PlayerStateDataMaybePlay {
|
||||
platformId: PlayPlatformId
|
||||
play?: PlayObject
|
||||
status?: ReportedPlayerStatus
|
||||
position?: number
|
||||
timestamp?: Dayjs
|
||||
|
||||
@@ -44,6 +44,7 @@ import {
|
||||
FormatPlayObjectOptions,
|
||||
InternalConfig,
|
||||
PlayerStateData,
|
||||
PlayerStateDataMaybePlay,
|
||||
PlayPlatformId, REPORTED_PLAYER_STATUSES
|
||||
} from "../common/infrastructure/Atomic.js";
|
||||
import { JellyApiSourceConfig } from "../common/infrastructure/config/source/jellyfin.js";
|
||||
@@ -278,7 +279,10 @@ export default class JellyfinApiSource extends MemorySource {
|
||||
//const userData = await getItemsApi(this.api).getItemUserData({itemId: 'ID', userId: this.user.Id});
|
||||
|
||||
const sessions = await getSessionApi(this.api).getSessions();
|
||||
const nonMSSessions = sessions.data.filter(x => x.DeviceId !== this.deviceId).map(x => this.sessionToPlayerState(x)) as PlayerStateData[];
|
||||
const nonMSSessions = sessions.data
|
||||
.filter(x => x.DeviceId !== this.deviceId)
|
||||
.map(x => this.sessionToPlayerState(x))
|
||||
.filter((x: PlayerStateDataMaybePlay) => x.play !== undefined) as PlayerStateData[];
|
||||
const validSessions: PlayerStateData[] = [];
|
||||
|
||||
for(const session of nonMSSessions) {
|
||||
@@ -292,7 +296,7 @@ export default class JellyfinApiSource extends MemorySource {
|
||||
return this.processRecentPlays(validSessions);
|
||||
}
|
||||
|
||||
sessionToPlayerState = (obj: SessionInfo): PlayerStateData => {
|
||||
sessionToPlayerState = (obj: SessionInfo): PlayerStateDataMaybePlay => {
|
||||
|
||||
const {
|
||||
UserName,
|
||||
|
||||
Reference in New Issue
Block a user