import { URL, URLSearchParams } from 'node:url';
import { Playable } from './base/playable.ts';
import { PlexClient } from './client.ts';
import { Hub, Library } from './library.ts';
import { Optimized } from './media.ts';
import { MyPlexAccount } from './myplex.ts';
import type { Playlist } from './playlist.ts';
import { PlayQueue } from './playqueue.ts';
import type { CreatePlayQueueOptions } from './playqueue.types.ts';
import { Agent, SEARCHTYPES } from './search.ts';
import type { BandwidthOptions, ContinueWatchingItemData, HistoryResult, HistoryOptions, SessionData, TranscodeSessionData, TranscodeImageOptions } from './server.types.ts';
import { Activity, ButlerTask, ServerPath, type ServerBrowseItem, StatisticsBandwidth, StatisticsResources, SystemAccount, SystemDevice, type ServerWalkEntry } from './serverModels.ts';
import { Settings } from './settings.ts';
export interface ServerBrowseOptions {
/** Server-visible path or a ServerPath object returned by browse(). Omit to browse roots. */
path?: string | ServerPath;
/** Include files in addition to directories. Defaults to true. */
includeFiles?: boolean;
}
/**
* This is the main entry point to interacting with a Plex server. It allows you to
* list connected clients, browse your library sections and perform actions such as
* emptying trash. If you do not know the auth token required to access your Plex
* server, or simply want to access your server with your username and password, you
* can also create an PlexServer instance from :class:`~plexapi.myplex.MyPlexAccount`.
*/
export declare class PlexServer {
baseurl: string;
token: string;
/**
* Default request timeout in milliseconds.
* @default 30000
*/
timeout: number;
key: string;
/** True if server allows camera upload */
allowCameraUpload: boolean;
/** True if server allows channel access (iTunes?) */
allowChannelAccess: boolean;
/** True is server allows media to be deleted. */
allowMediaDeletion: boolean;
/** True is server allows sharing */
allowSharing: boolean;
/** True is server allows sync */
allowSync: boolean;
/** Unknown */
allowTuners: boolean;
/** Plex server API version. */
apiVersion?: string;
/** Unknown */
livetv: number;
/** Unknown */
backgroundProcessing: boolean;
/** True if server has an HTTPS certificate */
certificate: boolean;
/** Unknown */
companionProxy: boolean;
/** Unknown */
diagnostics: string;
/** Unknown */
eventStream: boolean;
/** Human friendly name for this server */
friendlyName: string;
/**
* True if `Hub Search `_ is enabled. I believe this
* is enabled for everyone
*/
hubSearch: boolean;
/** Unique ID for this server (looks like an md5) */
machineIdentifier?: string;
/**
* True if `multiusers `_ are enabled.
*/
multiuser: boolean;
/** Unknown (True if logged into myPlex?) */
myPlex: boolean;
/** Unknown (ex!: mapped) */
myPlexMappingState: string;
/** Unknown (ex!: ok). */
myPlexSigninState: string;
/** True if you have a myPlex subscription */
myPlexSubscription: boolean;
/** Email address if signed into myPlex (user@example.com) */
myPlexUsername: string;
/** True if item clusters are enabled. */
itemClusters: boolean;
/** True if media providers are enabled. */
mediaProviders: boolean;
/** Plex server country code. */
countryCode: string;
/** Server offline transcode capability flag. */
offlineTranscode?: number;
/**
* List of features allowed by the server owner. This may be based
* on your PlexPass subscription. Features include!: camera_upload, cloudsync,
* content_filter, dvr, hardware_transcoding, home, lyrics, music_videos, pass,
* photo_autotags, premium_music_metadata, session_bandwidth_restrictions, sync,
* trailers, webhooks (and maybe more).
*/
ownerFeatures: string[];
/**
* True if photo `auto-tagging `_ is enabled.
*/
photoAutoTag?: boolean;
/** Platform the server is hosted on (ex!: Linux) */
platform: string;
/** Platform version (ex!: '6.1 (Build 7601)', '4.4.0-59-generic'). */
platformVersion: string;
/** Unknown */
pluginHost: boolean;
/** Unknown */
readOnlyLibraries: boolean;
/** Unknown */
requestParametersInCookie?: boolean;
/**
* Current `Streaming Brain `_ version.
*/
streamingBrainVersion: number;
streamingBrainABRVersion: number;
/**
* True if `syncing to a device `_ is enabled.
*/
sync: boolean;
/**
* Number of active video transcoding sessions.
*/
transcoderActiveVideoSessions: number;
/** True if audio transcoding audio is available. */
transcoderAudio: boolean;
/** True if audio transcoding lyrics is available. */
transcoderLyrics: boolean;
/** True if audio transcoding photos is available. */
transcoderPhoto: boolean;
/** True if audio transcoding subtitles is available. */
transcoderSubtitles: boolean;
/** True if audio transcoding video is available. */
transcoderVideo: boolean;
/** List of video bitrates. */
transcoderVideoBitrates: string;
/** List of video qualities. */
transcoderVideoQualities: string;
/** List of video resolutions. */
transcoderVideoResolutions: string;
/** Datetime the server was updated. */
updatedAt: number;
/** Unknown */
updater: boolean;
/** Current Plex version (ex!: 1.3.2.3112-1751929) */
version: string;
/** True if voice search is enabled. (is this Google Voice search?) */
voiceSearch: boolean;
/** Unknown */
pushNotifications: boolean;
_library?: Library;
_settings?: Settings;
private _myPlexAccount?;
constructor(baseurl: string, token: string, timeout?: number);
agents(mediaType?: number | string): Promise;
connect(): Promise;
/**
* Library to browse or search your media.
*/
library(): Promise;
/**
* Returns a list of media items or filter categories from the resulting
* `Hub Search `_
* against all items in your Plex library. This searches genres, actors, directors,
* playlists, as well as all the obvious media titles. It performs spell-checking
* against your search terms (because KUROSAWA is hard to spell). It also provides
* contextual search results. So for example, if you search for 'Pernice', it’ll
* return 'Pernice Brothers' as the artist result, but we’ll also go ahead and
* return your most-listened to albums and tracks from the artist. If you type
* 'Arnold' you’ll get a result for the actor, but also the most recently added
* movies he’s in.
* @param query Query to use when searching your library.
* @param options Search options.
*/
search(query: string, { mediatype, limit, }?: {
/** Optionally limit your search to the specified media type. */
mediatype?: keyof typeof SEARCHTYPES;
/** Optionally limit to the specified number of results per Hub. */
limit?: number;
}): Promise;
/**
* Browse server-visible filesystem paths through Plex.
*/
browse({ path, includeFiles }?: ServerBrowseOptions): Promise;
/**
* Walk a server-visible filesystem tree through Plex.
*/
walk(path?: string | ServerPath): AsyncGenerator;
/**
* Returns true when Plex can browse the given server-visible path.
*/
isBrowsable(path: string | ServerPath): Promise;
/**
* Main method used to handle HTTPS requests to the Plex server. 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 options
*/
query({ path, method, headers, body, username, password, }: {
path: string;
method?: 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete';
headers?: Record;
body?: Uint8Array;
username?: string;
password?: string;
}): Promise;
/**
* Returns a list of media items from watched history. If there are many results, they will
* be fetched from the server in batches of X_PLEX_CONTAINER_SIZE amounts. If you're only
* looking for the first results, it would be wise to set the maxResults option to that
* amount so this functions doesn't iterate over all results on the server.
* @param options Filter and paging options.
*/
history({ maxResults, minDate, ratingKey, accountId, librarySectionId, }?: HistoryOptions): Promise;
/** Returns a list of all active session (currently playing) media objects. */
sessions(): Promise;
/** Returns a list of all active transcode sessions. */
transcodeSessions(): Promise;
/** Returns a list of all current server activities. */
activities(): Promise;
/** Returns a list of all scheduled butler (maintenance) tasks. */
butlerTasks(): Promise;
/**
* Trigger a butler task to run immediately.
* @param taskName Name of the task to run (e.g. 'BackupDatabase', 'OptimizeDatabase', etc).
*/
runButlerTask(taskName: string): Promise;
/**
* Returns server bandwidth statistics.
* @param options Filter options for bandwidth stats.
*/
bandwidth(options?: BandwidthOptions): Promise;
/** Returns server resource usage statistics (CPU/memory). */
resources(): Promise;
/** Returns a list of all system accounts on the server. */
systemAccounts(): Promise;
/** Returns a list of all system devices on the server. */
systemDevices(): Promise;
/**
* Returns a URL to a transcoded image.
* @param options Transcode image options.
*/
transcodeImage(options: TranscodeImageOptions): URL;
/** Returns items from the Continue Watching hub. */
continueWatching(): Promise;
settings(): Promise;
/**
* Creates and returns a new PlayQueue.
*
* @param item Media item or playlist to add to PlayQueue
* @param options Creation options for the PlayQueue
* @returns New PlayQueue instance
*/
createPlayQueue(item: Playable | Playable[] | Playlist, options?: CreatePlayQueueOptions): Promise;
/**
* Returns a :class:`~plexapi.myplex.MyPlexAccount` object using the same
* token to access this server. If you are not the owner of this PlexServer
* you're likley to recieve an authentication error calling this.
*/
myPlexAccount(): MyPlexAccount;
clients(): Promise;
/** Returns list of all :class:`~plexapi.media.Optimized` objects connected to server. */
optimizedItems(): 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'.
*/
url(key: string, { includeToken, params, }?: {
includeToken?: boolean;
params?: URLSearchParams;
}): URL;
/**
* Build the Plex Web URL for the object.
* @param options Options for the URL.
*/
_buildWebURL({ base, endpoint, params, }?: {
/** The base URL before the fragment (``#!``). Default is https://app.plex.tv/desktop. */
base?: string;
/** The Plex Web URL endpoint. None for server, 'playlist' for playlists, 'details' for all other media types. */
endpoint?: string;
/** URL parameters to append. */
params?: URLSearchParams;
}): string;
_uriRoot(): string;
private _buildBrowseKey;
private _browseParentPath;
private _headers;
private _loadData;
/**
* Sometimes the PlexServer does not properly advertise port numbers required
* to connect. This attemps to look up device port number from plex.tv.
* See python plex issue #126: Make PlexServer.clients() more user friendly.
*/
private _myPlexClientPorts;
}