import { URL } from 'node:url'; import type { ClientTimelineData, Player, PlayMediaOptions, SendCommandParams, SetParametersOptions, SetStreamsOptions } from './client.types.ts'; import type { PlexServer } from './server.ts'; export interface PlexOptions { /** (:class:`~plexapi.server.PlexServer`): PlexServer this client is connected to (optional). */ server?: PlexServer; /** (ElementTree): Response from PlexServer used to build this object (optional). */ data?: any; /** (str): Path used to generate data. */ initpath?: string; /** (str): HTTP URL to connect dirrectly to this client. */ baseurl?: string; /** (str): X-Plex-Token used for authenication (optional). */ token?: string; /** (:class:`~requests.Session`): requests.Session object if you want more control (optional). */ session?: string; /** (int): timeout in seconds on initial connect to client (default config.TIMEOUT). */ timeout?: number; } /** * Represents a single timeline entry from a Plex client. */ export declare class ClientTimeline { state: string; type: string; time: number; duration: number; seekRange: string; key: string; ratingKey: string; volume: number; shuffle: boolean; repeat: number; playQueueID: number; playQueueItemID: number; controllable: string; machineIdentifier: string; providerIdentifier: string; containerKey: string; address: string; port: number; protocol: string; constructor(data: ClientTimelineData); } /** * Main class for interacting with a Plex client. This class can connect * directly to the client and control it or proxy commands through your * Plex Server. To better understand the Plex client API's read this page: * https://github.com/plexinc/plex-media-player/wiki/Remote-control-API * Attributes: * TAG (str): 'Player' * key (str): '/resources' * device (str): Best guess on the type of device this is (PS, iPhone, Linux, etc). * deviceClass (str): Device class (pc, phone, etc). * machineIdentifier (str): Unique ID for this device. * model (str): Unknown * platform (str): Unknown * platformVersion (str): Description * product (str): Client Product (Plex for iOS, etc). * protocol (str): Always seems ot be 'plex'. * protocolCapabilities (list): List of client capabilities (navigation, playback, * timeline, mirror, playqueues). * protocolVersion (str): Protocol version (1, future proofing?) * server (:class:`~plexapi.server.PlexServer`): Server this client is connected to. * session (:class:`~requests.Session`): Session object used for connection. * state (str): Unknown * title (str): Name of this client (Johns iPhone, etc). * token (str): X-Plex-Token used for authenication * vendor (str): Unknown * version (str): Device version (4.6.1, etc). * _session (obj): Requests session object used to access this client. * _proxyThroughServer (bool): Set to True after calling * :func:`~plexapi.client.PlexClient.proxyThroughServer()` (default False). */ export declare class PlexClient { /** * HTTP address of the client */ _baseurl: string | null; /** * Token used to access this client */ _token: string | null; TAG: string; key: string; timeout: number; deviceClass?: string; machineIdentifier?: string; product?: string; protocol?: string; protocolCapabilities?: string[]; protocolVersion?: string; platform?: string; platformVersion?: string; title?: string; _server: PlexServer | null; _proxyThroughServer: boolean; private _commandId; constructor(options?: PlexOptions); /** * Alias of reload as any subsequent requests to this client will be * made directly to the device even if the object attributes were initially * populated from a PlexServer. * @param timeout */ connect(): Promise; /** * @alias PlexClient.connect */ reload(): Promise; /** * Main method used to handle HTTPS requests to the Plex client. This method helps * by encoding the response to utf-8 and parsing the returned XML into and * ElementTree object. Returns None if no data exists in the response. * TODO: use headers * @param path * @param method * @param headers * @param timeout */ query(path: string, method?: 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete', headers?: Record): Promise; /** * Build a URL string with proper token argument. Token will be appended to the URL * if either includeToken is True or TODO: CONFIG.log.show_secrets is 'true'. * @param key * @param options */ url(key: string, { includeToken }?: { includeToken?: boolean; }): URL; /** * Toggle or set proxy-through-server mode. When enabled, commands are sent * through the Plex server rather than directly to the client. * @param value Enable or disable proxy mode. If omitted, toggles current state. * @param server The PlexServer to proxy through. Required if not already set. */ proxyThroughServer(value?: boolean, server?: PlexServer): void; /** * Send a command to the client, either directly or via the server proxy. * @param command The player command path (e.g. 'playback/play'). * @param params Additional parameters for the command. */ sendCommand(command: string, params?: SendCommandParams): Promise; /** Open the context menu on the client. */ contextMenu(): Promise; /** Navigate back on the client. */ goBack(): Promise; /** Navigate to home on the client. */ goToHome(): Promise; /** Navigate to music on the client. */ goToMusic(): Promise; /** Move selection down. */ moveDown(): Promise; /** Move selection left. */ moveLeft(): Promise; /** Move selection right. */ moveRight(): Promise; /** Move selection up. */ moveUp(): Promise; /** Jump to next letter in lists. */ nextLetter(): Promise; /** Page down in lists. */ pageDown(): Promise; /** Page up in lists. */ pageUp(): Promise; /** Jump to previous letter in lists. */ previousLetter(): Promise; /** Select the current item. */ select(): Promise; /** Toggle the on-screen display. */ toggleOSD(): Promise; /** * Start or resume playback. * @param mtype Media type filter (video, music, photo). */ play(mtype?: string): Promise; /** * Pause playback. * @param mtype Media type filter (video, music, photo). */ pause(mtype?: string): Promise; /** * Stop playback. * @param mtype Media type filter (video, music, photo). */ stop(mtype?: string): Promise; /** * Seek to the specified offset in milliseconds. * @param offset Position in milliseconds. * @param mtype Media type filter (video, music, photo). */ seekTo(offset: number, mtype?: string): Promise; /** * Skip to the next item. * @param mtype Media type filter (video, music, photo). */ skipNext(mtype?: string): Promise; /** * Skip to the previous item. * @param mtype Media type filter (video, music, photo). */ skipPrevious(mtype?: string): Promise; /** * Skip to a specific item by key. * @param key The key of the item to skip to. * @param mtype Media type filter (video, music, photo). */ skipTo(key: string, mtype?: string): Promise; /** * Step back (small rewind). * @param mtype Media type filter (video, music, photo). */ stepBack(mtype?: string): Promise; /** * Step forward (small fast-forward). * @param mtype Media type filter (video, music, photo). */ stepForward(mtype?: string): Promise; /** * Set repeat mode. * @param repeat Repeat mode (0=off, 1=repeat one, 2=repeat all). * @param mtype Media type filter (video, music, photo). */ setRepeat(repeat: number, mtype?: string): Promise; /** * Set shuffle mode. * @param shuffle Shuffle mode (0=off, 1=on). * @param mtype Media type filter (video, music, photo). */ setShuffle(shuffle: number, mtype?: string): Promise; /** * Set volume level. * @param volume Volume level (0-100). * @param mtype Media type filter (video, music, photo). */ setVolume(volume: number, mtype?: string): Promise; /** * Set multiple playback parameters at once. * @param options Parameters to set. */ setParameters(options: SetParametersOptions): Promise; /** * Set the active audio, subtitle, or video stream. * @param options Stream selection options. */ setStreams(options: SetStreamsOptions): Promise; /** * Set the active audio stream. * @param audioStreamID ID of the audio stream. * @param mtype Media type filter (video, music, photo). */ setAudioStream(audioStreamID: number, mtype?: string): Promise; /** * Set the active subtitle stream. * @param subtitleStreamID ID of the subtitle stream. Use 0 to disable subtitles. * @param mtype Media type filter (video, music, photo). */ setSubtitleStream(subtitleStreamID: number, mtype?: string): Promise; /** * Set the active video stream. * @param videoStreamID ID of the video stream. * @param mtype Media type filter (video, music, photo). */ setVideoStream(videoStreamID: number, mtype?: string): Promise; /** * Start playback of media using a play queue. * @param media A Playable media item with a playlistItemID or ratingKey. * @param options Playback options. */ playMedia(media: any, options?: PlayMediaOptions): Promise; /** * Poll the client for timeline data (what is currently playing). * @param wait Time in seconds to wait for a response. */ timelines(wait?: number): Promise; /** * Returns the active (non-stopped) timeline, or undefined if nothing is playing. */ timeline(): Promise; /** * Returns true if the client is currently playing media. * @param includePaused If true, paused media counts as playing. */ isPlayingMedia(includePaused?: boolean): Promise; protected _loadData(data: Player): void; private _nextCommandId; /** * Returns a dict of all default headers for Client requests. */ private _headers; }