mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-05-05 23:50:21 +00:00
Merge pull request #317 from FoxxMD/GH-314/plexjsVersion
fix(Plex): Temporary plex validation fix
This commit is contained in:
commit
1e488b576c
3 changed files with 36 additions and 8 deletions
8
package-lock.json
generated
8
package-lock.json
generated
|
|
@ -25,7 +25,7 @@
|
|||
"@gr2m/net-interceptor": "^1.0.0",
|
||||
"@jellyfin/sdk": "^0.11.0",
|
||||
"@kenyip/backoff-strategies": "^1.0.4",
|
||||
"@lukehagar/plexjs": "^0.32.1",
|
||||
"@lukehagar/plexjs": "^0.39.0",
|
||||
"@react-nano/use-event-source": "^0.13.0",
|
||||
"@reduxjs/toolkit": "^1.9.5",
|
||||
"@supercharge/promise-pool": "^3.0.0",
|
||||
|
|
@ -1543,9 +1543,9 @@
|
|||
"integrity": "sha512-vduQZw2ctS3kIuSnCSSRiE4J90Y8WShR9xVG+e1lvFWksU2aTxjdkArcQqJ+XLm22JS380OZmrIPY1U06TAsng=="
|
||||
},
|
||||
"node_modules/@lukehagar/plexjs": {
|
||||
"version": "0.32.1",
|
||||
"resolved": "https://registry.npmjs.org/@lukehagar/plexjs/-/plexjs-0.32.1.tgz",
|
||||
"integrity": "sha512-cEIpepR1/BJYQey2lbzPhy342ZR/JmkChXKS+bOQkGLg1F17n45Zf650W67sBKMvF63effNVT0iUF3Fi3D7yPQ==",
|
||||
"version": "0.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@lukehagar/plexjs/-/plexjs-0.39.0.tgz",
|
||||
"integrity": "sha512-BXNHTh1Z9K0bb5qFKgYZv7gOC9+wYzOsatp/+DRGShGhp40bH0lTShzD6acKjqlIvqi2Pm7UJnF8+yBipE9Qmg==",
|
||||
"peerDependencies": {
|
||||
"zod": ">= 3"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
"@gr2m/net-interceptor": "^1.0.0",
|
||||
"@jellyfin/sdk": "^0.11.0",
|
||||
"@kenyip/backoff-strategies": "^1.0.4",
|
||||
"@lukehagar/plexjs": "^0.32.1",
|
||||
"@lukehagar/plexjs": "^0.39.0",
|
||||
"@react-nano/use-event-source": "^0.13.0",
|
||||
"@reduxjs/toolkit": "^1.9.5",
|
||||
"@supercharge/promise-pool": "^3.0.0",
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@ import { genGroupIdStr, getFirstNonEmptyString, getPlatformIdFromData, isDebugMo
|
|||
import { buildStatePlayerPlayIdententifyingInfo, parseArrayFromMaybeString } from "../utils/StringUtils.js";
|
||||
import { GetSessionsMetadata } from "@lukehagar/plexjs/sdk/models/operations/getsessions.js";
|
||||
import { PlexAPI } from "@lukehagar/plexjs";
|
||||
import {
|
||||
SDKValidationError,
|
||||
} from "@lukehagar/plexjs/sdk/models/errors";
|
||||
import { PlexApiSourceConfig } from "../common/infrastructure/config/source/plex.js";
|
||||
import { isPortReachable, joinedUrl } from '../utils/NetworkUtils.js';
|
||||
import normalizeUrl from 'normalize-url';
|
||||
|
|
@ -29,6 +26,7 @@ import { AbstractPlayerState, PlayerStateOptions } from './PlayerState/AbstractP
|
|||
import { Logger } from '@foxxmd/logging';
|
||||
import { MemoryPositionalSource } from './MemoryPositionalSource.js';
|
||||
import { FixedSizeList } from 'fixed-size-list';
|
||||
import { SDKValidationError } from '@lukehagar/plexjs/sdk/models/errors/sdkvalidationerror.js';
|
||||
|
||||
const shortDeviceId = truncateStringToLength(10, '');
|
||||
|
||||
|
|
@ -187,6 +185,17 @@ export default class PlexApiSource extends MemoryPositionalSource {
|
|||
|
||||
this.libraries = libraries.object.mediaContainer.directory.map(x => ({name: x.title, collectionType: x.type, uuid: x.uuid}));
|
||||
} catch (e) {
|
||||
if(e instanceof SDKValidationError) {
|
||||
if((e.rawValue as any).object?.MediaContainer?.Directory !== undefined) {
|
||||
// ensure directory has required values
|
||||
const ok = (e.rawValue as any).object?.MediaContainer?.Directory.every(x => x.title !== undefined && x.type !== undefined && x.uuid !== undefined);
|
||||
if(ok) {
|
||||
this.libraries = (e.rawValue as any).object.MediaContainer.Directory.map(x => ({name: x.title, collectionType: x.type, uuid: x.uuid}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.logger.debug({ rawValue: e.rawValue }, 'Plex Response');
|
||||
}
|
||||
throw new Error('Unable to get server libraries', {cause: e});
|
||||
}
|
||||
|
||||
|
|
@ -452,3 +461,22 @@ ${JSON.stringify(obj)}`);
|
|||
|
||||
getNewPlayer = (logger: Logger, id: PlayPlatformId, opts: PlayerStateOptions) => new PlexPlayerState(logger, id, opts);
|
||||
}
|
||||
|
||||
async function streamToString(stream: any) {
|
||||
const reader = stream.getReader();
|
||||
const textDecoder = new TextDecoder();
|
||||
let result = '';
|
||||
|
||||
async function read() {
|
||||
const { done, value } = await reader.read();
|
||||
|
||||
if (done) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result += textDecoder.decode(value, { stream: true });
|
||||
return read();
|
||||
}
|
||||
|
||||
return read();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue