/** * Jellyfin API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 10.8.9 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import localVarRequest from 'request'; import http from 'http'; /* tslint:disable:no-unused-locals */ import { GetPostedPlaybackInfoRequest } from '../model/getPostedPlaybackInfoRequest'; import { LiveStreamResponse } from '../model/liveStreamResponse'; import { OpenLiveStreamRequest } from '../model/openLiveStreamRequest'; import { PlaybackInfoResponse } from '../model/playbackInfoResponse'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://localhost'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== export enum MediaInfoApiApiKeys { CustomAuthentication, } export class MediaInfoApi { protected _basePath = defaultBasePath; protected _defaultHeaders : any = {}; protected _useQuerystring : boolean = false; protected authentications = { 'default': new VoidAuth(), 'CustomAuthentication': new ApiKeyAuth('header', 'Authorization'), } protected interceptors: Interceptor[] = []; constructor(basePath?: string); constructor(basePathOrUsername: string, password?: string, basePath?: string) { if (password) { if (basePath) { this.basePath = basePath; } } else { if (basePathOrUsername) { this.basePath = basePathOrUsername } } } set useQuerystring(value: boolean) { this._useQuerystring = value; } set basePath(basePath: string) { this._basePath = basePath; } set defaultHeaders(defaultHeaders: any) { this._defaultHeaders = defaultHeaders; } get defaultHeaders() { return this._defaultHeaders; } get basePath() { return this._basePath; } public setDefaultAuthentication(auth: Authentication) { this.authentications.default = auth; } public setApiKey(key: MediaInfoApiApiKeys, value: string) { (this.authentications as any)[MediaInfoApiApiKeys[key]].apiKey = value; } public addInterceptor(interceptor: Interceptor) { this.interceptors.push(interceptor); } /** * * @summary Closes a media source. * @param liveStreamId The livestream id. */ public async closeLiveStream (liveStreamId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/LiveStreams/Close'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); let localVarFormParams: any = {}; // verify required parameter 'liveStreamId' is not null or undefined if (liveStreamId === null || liveStreamId === undefined) { throw new Error('Required parameter liveStreamId was null or undefined when calling closeLiveStream.'); } if (liveStreamId !== undefined) { localVarQueryParameters['liveStreamId'] = ObjectSerializer.serialize(liveStreamId, "string"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Tests the network with a request with the size of the bitrate. * @param size The bitrate. Defaults to 102400. */ public async getBitrateTestBytes (size?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { const localVarPath = this.basePath + '/Playback/BitrateTest'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/octet-stream']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; if (size !== undefined) { localVarQueryParameters['size'] = ObjectSerializer.serialize(size, "number"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, encoding: null, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: Buffer; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "Buffer"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Gets live playback media info for an item. * @param itemId The item id. * @param userId The user id. */ public async getPlaybackInfo (itemId: string, userId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PlaybackInfoResponse; }> { const localVarPath = this.basePath + '/Items/{itemId}/PlaybackInfo' .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'itemId' is not null or undefined if (itemId === null || itemId === undefined) { throw new Error('Required parameter itemId was null or undefined when calling getPlaybackInfo.'); } // verify required parameter 'userId' is not null or undefined if (userId === null || userId === undefined) { throw new Error('Required parameter userId was null or undefined when calling getPlaybackInfo.'); } if (userId !== undefined) { localVarQueryParameters['userId'] = ObjectSerializer.serialize(userId, "string"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: PlaybackInfoResponse; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "PlaybackInfoResponse"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * For backwards compatibility parameters can be sent via Query or Body, with Query having higher precedence. Query parameters are obsolete. * @summary Gets live playback media info for an item. * @param itemId The item id. * @param userId The user id. * @param maxStreamingBitrate The maximum streaming bitrate. * @param startTimeTicks The start time in ticks. * @param audioStreamIndex The audio stream index. * @param subtitleStreamIndex The subtitle stream index. * @param maxAudioChannels The maximum number of audio channels. * @param mediaSourceId The media source id. * @param liveStreamId The livestream id. * @param autoOpenLiveStream Whether to auto open the livestream. * @param enableDirectPlay Whether to enable direct play. Default: true. * @param enableDirectStream Whether to enable direct stream. Default: true. * @param enableTranscoding Whether to enable transcoding. Default: true. * @param allowVideoStreamCopy Whether to allow to copy the video stream. Default: true. * @param allowAudioStreamCopy Whether to allow to copy the audio stream. Default: true. * @param getPostedPlaybackInfoRequest The playback info. */ public async getPostedPlaybackInfo (itemId: string, userId?: string, maxStreamingBitrate?: number, startTimeTicks?: number, audioStreamIndex?: number, subtitleStreamIndex?: number, maxAudioChannels?: number, mediaSourceId?: string, liveStreamId?: string, autoOpenLiveStream?: boolean, enableDirectPlay?: boolean, enableDirectStream?: boolean, enableTranscoding?: boolean, allowVideoStreamCopy?: boolean, allowAudioStreamCopy?: boolean, getPostedPlaybackInfoRequest?: GetPostedPlaybackInfoRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PlaybackInfoResponse; }> { const localVarPath = this.basePath + '/Items/{itemId}/PlaybackInfo' .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'itemId' is not null or undefined if (itemId === null || itemId === undefined) { throw new Error('Required parameter itemId was null or undefined when calling getPostedPlaybackInfo.'); } if (userId !== undefined) { localVarQueryParameters['userId'] = ObjectSerializer.serialize(userId, "string"); } if (maxStreamingBitrate !== undefined) { localVarQueryParameters['maxStreamingBitrate'] = ObjectSerializer.serialize(maxStreamingBitrate, "number"); } if (startTimeTicks !== undefined) { localVarQueryParameters['startTimeTicks'] = ObjectSerializer.serialize(startTimeTicks, "number"); } if (audioStreamIndex !== undefined) { localVarQueryParameters['audioStreamIndex'] = ObjectSerializer.serialize(audioStreamIndex, "number"); } if (subtitleStreamIndex !== undefined) { localVarQueryParameters['subtitleStreamIndex'] = ObjectSerializer.serialize(subtitleStreamIndex, "number"); } if (maxAudioChannels !== undefined) { localVarQueryParameters['maxAudioChannels'] = ObjectSerializer.serialize(maxAudioChannels, "number"); } if (mediaSourceId !== undefined) { localVarQueryParameters['mediaSourceId'] = ObjectSerializer.serialize(mediaSourceId, "string"); } if (liveStreamId !== undefined) { localVarQueryParameters['liveStreamId'] = ObjectSerializer.serialize(liveStreamId, "string"); } if (autoOpenLiveStream !== undefined) { localVarQueryParameters['autoOpenLiveStream'] = ObjectSerializer.serialize(autoOpenLiveStream, "boolean"); } if (enableDirectPlay !== undefined) { localVarQueryParameters['enableDirectPlay'] = ObjectSerializer.serialize(enableDirectPlay, "boolean"); } if (enableDirectStream !== undefined) { localVarQueryParameters['enableDirectStream'] = ObjectSerializer.serialize(enableDirectStream, "boolean"); } if (enableTranscoding !== undefined) { localVarQueryParameters['enableTranscoding'] = ObjectSerializer.serialize(enableTranscoding, "boolean"); } if (allowVideoStreamCopy !== undefined) { localVarQueryParameters['allowVideoStreamCopy'] = ObjectSerializer.serialize(allowVideoStreamCopy, "boolean"); } if (allowAudioStreamCopy !== undefined) { localVarQueryParameters['allowAudioStreamCopy'] = ObjectSerializer.serialize(allowAudioStreamCopy, "boolean"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(getPostedPlaybackInfoRequest, "GetPostedPlaybackInfoRequest") }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: PlaybackInfoResponse; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "PlaybackInfoResponse"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Opens a media source. * @param openToken The open token. * @param userId The user id. * @param playSessionId The play session id. * @param maxStreamingBitrate The maximum streaming bitrate. * @param startTimeTicks The start time in ticks. * @param audioStreamIndex The audio stream index. * @param subtitleStreamIndex The subtitle stream index. * @param maxAudioChannels The maximum number of audio channels. * @param itemId The item id. * @param enableDirectPlay Whether to enable direct play. Default: true. * @param enableDirectStream Whether to enable direct stream. Default: true. * @param openLiveStreamRequest The open live stream dto. */ public async openLiveStream (openToken?: string, userId?: string, playSessionId?: string, maxStreamingBitrate?: number, startTimeTicks?: number, audioStreamIndex?: number, subtitleStreamIndex?: number, maxAudioChannels?: number, itemId?: string, enableDirectPlay?: boolean, enableDirectStream?: boolean, openLiveStreamRequest?: OpenLiveStreamRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LiveStreamResponse; }> { const localVarPath = this.basePath + '/LiveStreams/Open'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; if (openToken !== undefined) { localVarQueryParameters['openToken'] = ObjectSerializer.serialize(openToken, "string"); } if (userId !== undefined) { localVarQueryParameters['userId'] = ObjectSerializer.serialize(userId, "string"); } if (playSessionId !== undefined) { localVarQueryParameters['playSessionId'] = ObjectSerializer.serialize(playSessionId, "string"); } if (maxStreamingBitrate !== undefined) { localVarQueryParameters['maxStreamingBitrate'] = ObjectSerializer.serialize(maxStreamingBitrate, "number"); } if (startTimeTicks !== undefined) { localVarQueryParameters['startTimeTicks'] = ObjectSerializer.serialize(startTimeTicks, "number"); } if (audioStreamIndex !== undefined) { localVarQueryParameters['audioStreamIndex'] = ObjectSerializer.serialize(audioStreamIndex, "number"); } if (subtitleStreamIndex !== undefined) { localVarQueryParameters['subtitleStreamIndex'] = ObjectSerializer.serialize(subtitleStreamIndex, "number"); } if (maxAudioChannels !== undefined) { localVarQueryParameters['maxAudioChannels'] = ObjectSerializer.serialize(maxAudioChannels, "number"); } if (itemId !== undefined) { localVarQueryParameters['itemId'] = ObjectSerializer.serialize(itemId, "string"); } if (enableDirectPlay !== undefined) { localVarQueryParameters['enableDirectPlay'] = ObjectSerializer.serialize(enableDirectPlay, "boolean"); } if (enableDirectStream !== undefined) { localVarQueryParameters['enableDirectStream'] = ObjectSerializer.serialize(enableDirectStream, "boolean"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(openLiveStreamRequest, "OpenLiveStreamRequest") }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: LiveStreamResponse; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "LiveStreamResponse"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } }