/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../lib/schemas.js"; import * as openEnums from "../types/enums.js"; import { OpenEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { SDKValidationError } from "./errors/sdk-validation-error.js"; import { SourceAudioDetails, SourceAudioDetails$inboundSchema, } from "./source-audio-details.js"; import { SourceVideoDetails, SourceVideoDetails$inboundSchema, } from "./source-video-details.js"; import { StreamAudioDetails, StreamAudioDetails$inboundSchema, } from "./stream-audio-details.js"; import { StreamVideoDetails, StreamVideoDetails$inboundSchema, } from "./stream-video-details.js"; import { SubtitleInfo, SubtitleInfo$inboundSchema } from "./subtitle-info.js"; import { TranscodeInfo, TranscodeInfo$inboundSchema, } from "./transcode-info.js"; export const SessionHistoryState = { Playing: "playing", Paused: "paused", Stopped: "stopped", } as const; export type SessionHistoryState = OpenEnum; export const SessionHistoryMediaType = { Movie: "movie", Episode: "episode", Track: "track", Live: "live", Photo: "photo", Unknown: "unknown", } as const; export type SessionHistoryMediaType = OpenEnum; export const SessionHistoryVideoDecision = { Directplay: "directplay", Copy: "copy", Transcode: "transcode", } as const; export type SessionHistoryVideoDecision = OpenEnum< typeof SessionHistoryVideoDecision >; export const SessionHistoryAudioDecision = { Directplay: "directplay", Copy: "copy", Transcode: "transcode", } as const; export type SessionHistoryAudioDecision = OpenEnum< typeof SessionHistoryAudioDecision >; export type SessionHistoryUser = { id: string; username: string; /** * Avatar path from media server */ thumbUrl: string | null; /** * Proxied avatar URL */ avatarUrl: string | null; }; export type SessionHistory = { id: string; serverId: string; serverName: string; state: SessionHistoryState; mediaTitle: string; mediaType: SessionHistoryMediaType; /** * Show name (episodes only) */ showTitle: string | null; seasonNumber: number | null; episodeNumber: number | null; year: number | null; /** * Artist name (music tracks only) */ artistName: string | null; /** * Album name (music tracks only) */ albumName: string | null; /** * Track number (music tracks only) */ trackNumber: number | null; /** * Disc number (music tracks only) */ discNumber: number | null; /** * Poster path */ thumbPath: string | null; /** * Proxied poster URL */ posterUrl: string | null; /** * Total watch time across segments */ durationMs: number | null; progressMs: number | null; /** * Media length */ totalDurationMs: number | null; startedAt: Date; stoppedAt: Date | null; /** * True if watched 85%+ */ watched: boolean; /** * Pause/resume segment count */ segmentCount: number; device: string | null; player: string | null; product: string | null; platform: string | null; isTranscode: boolean | null; videoDecision: SessionHistoryVideoDecision | null; audioDecision: SessionHistoryAudioDecision | null; /** * Bitrate in kbps */ bitrate: number | null; sourceVideoCodec: string | null; sourceAudioCodec: string | null; sourceAudioChannels: number | null; sourceVideoWidth: number | null; sourceVideoHeight: number | null; sourceVideoDetails: SourceVideoDetails | null; sourceAudioDetails: SourceAudioDetails | null; streamVideoCodec: string | null; streamAudioCodec: string | null; streamVideoDetails: StreamVideoDetails | null; streamAudioDetails: StreamAudioDetails | null; transcodeInfo: TranscodeInfo | null; subtitleInfo: SubtitleInfo | null; /** * 4K, 1080p, 720p, etc. */ resolution: string | null; sourceVideoCodecDisplay: string | null; sourceAudioCodecDisplay: string | null; audioChannelsDisplay: string | null; streamVideoCodecDisplay: string | null; streamAudioCodecDisplay: string | null; user: SessionHistoryUser; }; /** @internal */ export const SessionHistoryState$inboundSchema: z.ZodMiniType< SessionHistoryState, unknown > = openEnums.inboundSchema(SessionHistoryState); /** @internal */ export const SessionHistoryMediaType$inboundSchema: z.ZodMiniType< SessionHistoryMediaType, unknown > = openEnums.inboundSchema(SessionHistoryMediaType); /** @internal */ export const SessionHistoryVideoDecision$inboundSchema: z.ZodMiniType< SessionHistoryVideoDecision, unknown > = openEnums.inboundSchema(SessionHistoryVideoDecision); /** @internal */ export const SessionHistoryAudioDecision$inboundSchema: z.ZodMiniType< SessionHistoryAudioDecision, unknown > = openEnums.inboundSchema(SessionHistoryAudioDecision); /** @internal */ export const SessionHistoryUser$inboundSchema: z.ZodMiniType< SessionHistoryUser, unknown > = z.object({ id: types.string(), username: types.string(), thumbUrl: types.nullable(types.string()), avatarUrl: types.nullable(types.string()), }); export function sessionHistoryUserFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SessionHistoryUser$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SessionHistoryUser' from JSON`, ); } /** @internal */ export const SessionHistory$inboundSchema: z.ZodMiniType< SessionHistory, unknown > = z.object({ id: types.string(), serverId: types.string(), serverName: types.string(), state: SessionHistoryState$inboundSchema, mediaTitle: types.string(), mediaType: SessionHistoryMediaType$inboundSchema, showTitle: types.nullable(types.string()), seasonNumber: types.nullable(types.number()), episodeNumber: types.nullable(types.number()), year: types.nullable(types.number()), artistName: types.nullable(types.string()), albumName: types.nullable(types.string()), trackNumber: types.nullable(types.number()), discNumber: types.nullable(types.number()), thumbPath: types.nullable(types.string()), posterUrl: types.nullable(types.string()), durationMs: types.nullable(types.number()), progressMs: types.nullable(types.number()), totalDurationMs: types.nullable(types.number()), startedAt: types.date(), stoppedAt: types.nullable(types.date()), watched: types.boolean(), segmentCount: types.number(), device: types.nullable(types.string()), player: types.nullable(types.string()), product: types.nullable(types.string()), platform: types.nullable(types.string()), isTranscode: types.nullable(types.boolean()), videoDecision: types.nullable(SessionHistoryVideoDecision$inboundSchema), audioDecision: types.nullable(SessionHistoryAudioDecision$inboundSchema), bitrate: types.nullable(types.number()), sourceVideoCodec: types.nullable(types.string()), sourceAudioCodec: types.nullable(types.string()), sourceAudioChannels: types.nullable(types.number()), sourceVideoWidth: types.nullable(types.number()), sourceVideoHeight: types.nullable(types.number()), sourceVideoDetails: types.nullable(SourceVideoDetails$inboundSchema), sourceAudioDetails: types.nullable(SourceAudioDetails$inboundSchema), streamVideoCodec: types.nullable(types.string()), streamAudioCodec: types.nullable(types.string()), streamVideoDetails: types.nullable(StreamVideoDetails$inboundSchema), streamAudioDetails: types.nullable(StreamAudioDetails$inboundSchema), transcodeInfo: types.nullable(TranscodeInfo$inboundSchema), subtitleInfo: types.nullable(SubtitleInfo$inboundSchema), resolution: types.nullable(types.string()), sourceVideoCodecDisplay: types.nullable(types.string()), sourceAudioCodecDisplay: types.nullable(types.string()), audioChannelsDisplay: types.nullable(types.string()), streamVideoCodecDisplay: types.nullable(types.string()), streamAudioCodecDisplay: types.nullable(types.string()), user: z.lazy(() => SessionHistoryUser$inboundSchema), }); export function sessionHistoryFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SessionHistory$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SessionHistory' from JSON`, ); }