/** * 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 { FontFile } from '../model/fontFile'; import { ProblemDetails } from '../model/problemDetails'; import { RemoteSubtitleInfo } from '../model/remoteSubtitleInfo'; import { UploadSubtitleRequest } from '../model/uploadSubtitleRequest'; 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 SubtitleApiApiKeys { CustomAuthentication, } export class SubtitleApi { 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: SubtitleApiApiKeys, value: string) { (this.authentications as any)[SubtitleApiApiKeys[key]].apiKey = value; } public addInterceptor(interceptor: Interceptor) { this.interceptors.push(interceptor); } /** * * @summary Deletes an external subtitle file. * @param itemId The item id. * @param index The index of the subtitle file. */ public async deleteSubtitle (itemId: string, index: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/Videos/{itemId}/Subtitles/{index}' .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))) .replace('{' + 'index' + '}', encodeURIComponent(String(index))); 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 deleteSubtitle.'); } // verify required parameter 'index' is not null or undefined if (index === null || index === undefined) { throw new Error('Required parameter index was null or undefined when calling deleteSubtitle.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'DELETE', 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 Downloads a remote subtitle. * @param itemId The item id. * @param subtitleId The subtitle id. */ public async downloadRemoteSubtitles (itemId: string, subtitleId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/Items/{itemId}/RemoteSearch/Subtitles/{subtitleId}' .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))) .replace('{' + 'subtitleId' + '}', encodeURIComponent(String(subtitleId))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); 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 downloadRemoteSubtitles.'); } // verify required parameter 'subtitleId' is not null or undefined if (subtitleId === null || subtitleId === undefined) { throw new Error('Required parameter subtitleId was null or undefined when calling downloadRemoteSubtitles.'); } (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 Gets a fallback font file. * @param name The name of the fallback font file to get. */ public async getFallbackFont (name: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { const localVarPath = this.basePath + '/FallbackFont/Fonts/{name}' .replace('{' + 'name' + '}', encodeURIComponent(String(name))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['font/*']; // 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 'name' is not null or undefined if (name === null || name === undefined) { throw new Error('Required parameter name was null or undefined when calling getFallbackFont.'); } (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 a list of available fallback font files. */ public async getFallbackFontList (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { const localVarPath = this.basePath + '/FallbackFont/Fonts'; 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 = {}; (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: Array; }>((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, "Array"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Gets the remote subtitles. * @param id The item id. */ public async getRemoteSubtitles (id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { const localVarPath = this.basePath + '/Providers/Subtitles/Subtitles/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['text/*']; // 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 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getRemoteSubtitles.'); } (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 subtitles in a specified format. * @param routeItemId The (route) item id. * @param routeMediaSourceId The (route) media source id. * @param routeIndex The (route) subtitle stream index. * @param routeFormat The (route) format of the returned subtitle. * @param itemId The item id. * @param mediaSourceId The media source id. * @param index The subtitle stream index. * @param format The format of the returned subtitle. * @param endPositionTicks Optional. The end position of the subtitle in ticks. * @param copyTimestamps Optional. Whether to copy the timestamps. * @param addVttTimeMap Optional. Whether to add a VTT time map. * @param startPositionTicks The start position of the subtitle in ticks. */ public async getSubtitle (routeItemId: string, routeMediaSourceId: string, routeIndex: number, routeFormat: string, itemId?: string, mediaSourceId?: string, index?: number, format?: string, endPositionTicks?: number, copyTimestamps?: boolean, addVttTimeMap?: boolean, startPositionTicks?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { const localVarPath = this.basePath + '/Videos/{routeItemId}/{routeMediaSourceId}/Subtitles/{routeIndex}/Stream.{routeFormat}' .replace('{' + 'routeItemId' + '}', encodeURIComponent(String(routeItemId))) .replace('{' + 'routeMediaSourceId' + '}', encodeURIComponent(String(routeMediaSourceId))) .replace('{' + 'routeIndex' + '}', encodeURIComponent(String(routeIndex))) .replace('{' + 'routeFormat' + '}', encodeURIComponent(String(routeFormat))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['text/*']; // 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 'routeItemId' is not null or undefined if (routeItemId === null || routeItemId === undefined) { throw new Error('Required parameter routeItemId was null or undefined when calling getSubtitle.'); } // verify required parameter 'routeMediaSourceId' is not null or undefined if (routeMediaSourceId === null || routeMediaSourceId === undefined) { throw new Error('Required parameter routeMediaSourceId was null or undefined when calling getSubtitle.'); } // verify required parameter 'routeIndex' is not null or undefined if (routeIndex === null || routeIndex === undefined) { throw new Error('Required parameter routeIndex was null or undefined when calling getSubtitle.'); } // verify required parameter 'routeFormat' is not null or undefined if (routeFormat === null || routeFormat === undefined) { throw new Error('Required parameter routeFormat was null or undefined when calling getSubtitle.'); } if (itemId !== undefined) { localVarQueryParameters['itemId'] = ObjectSerializer.serialize(itemId, "string"); } if (mediaSourceId !== undefined) { localVarQueryParameters['mediaSourceId'] = ObjectSerializer.serialize(mediaSourceId, "string"); } if (index !== undefined) { localVarQueryParameters['index'] = ObjectSerializer.serialize(index, "number"); } if (format !== undefined) { localVarQueryParameters['format'] = ObjectSerializer.serialize(format, "string"); } if (endPositionTicks !== undefined) { localVarQueryParameters['endPositionTicks'] = ObjectSerializer.serialize(endPositionTicks, "number"); } if (copyTimestamps !== undefined) { localVarQueryParameters['copyTimestamps'] = ObjectSerializer.serialize(copyTimestamps, "boolean"); } if (addVttTimeMap !== undefined) { localVarQueryParameters['addVttTimeMap'] = ObjectSerializer.serialize(addVttTimeMap, "boolean"); } if (startPositionTicks !== undefined) { localVarQueryParameters['startPositionTicks'] = ObjectSerializer.serialize(startPositionTicks, "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(); 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 an HLS subtitle playlist. * @param itemId The item id. * @param index The subtitle stream index. * @param mediaSourceId The media source id. * @param segmentLength The subtitle segment length. */ public async getSubtitlePlaylist (itemId: string, index: number, mediaSourceId: string, segmentLength: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { const localVarPath = this.basePath + '/Videos/{itemId}/{mediaSourceId}/Subtitles/{index}/subtitles.m3u8' .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))) .replace('{' + 'index' + '}', encodeURIComponent(String(index))) .replace('{' + 'mediaSourceId' + '}', encodeURIComponent(String(mediaSourceId))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/x-mpegURL']; // 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 getSubtitlePlaylist.'); } // verify required parameter 'index' is not null or undefined if (index === null || index === undefined) { throw new Error('Required parameter index was null or undefined when calling getSubtitlePlaylist.'); } // verify required parameter 'mediaSourceId' is not null or undefined if (mediaSourceId === null || mediaSourceId === undefined) { throw new Error('Required parameter mediaSourceId was null or undefined when calling getSubtitlePlaylist.'); } // verify required parameter 'segmentLength' is not null or undefined if (segmentLength === null || segmentLength === undefined) { throw new Error('Required parameter segmentLength was null or undefined when calling getSubtitlePlaylist.'); } if (segmentLength !== undefined) { localVarQueryParameters['segmentLength'] = ObjectSerializer.serialize(segmentLength, "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 subtitles in a specified format. * @param routeItemId The (route) item id. * @param routeMediaSourceId The (route) media source id. * @param routeIndex The (route) subtitle stream index. * @param routeStartPositionTicks The (route) start position of the subtitle in ticks. * @param routeFormat The (route) format of the returned subtitle. * @param itemId The item id. * @param mediaSourceId The media source id. * @param index The subtitle stream index. * @param startPositionTicks The start position of the subtitle in ticks. * @param format The format of the returned subtitle. * @param endPositionTicks Optional. The end position of the subtitle in ticks. * @param copyTimestamps Optional. Whether to copy the timestamps. * @param addVttTimeMap Optional. Whether to add a VTT time map. */ public async getSubtitleWithTicks (routeItemId: string, routeMediaSourceId: string, routeIndex: number, routeStartPositionTicks: number, routeFormat: string, itemId?: string, mediaSourceId?: string, index?: number, startPositionTicks?: number, format?: string, endPositionTicks?: number, copyTimestamps?: boolean, addVttTimeMap?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { const localVarPath = this.basePath + '/Videos/{routeItemId}/{routeMediaSourceId}/Subtitles/{routeIndex}/{routeStartPositionTicks}/Stream.{routeFormat}' .replace('{' + 'routeItemId' + '}', encodeURIComponent(String(routeItemId))) .replace('{' + 'routeMediaSourceId' + '}', encodeURIComponent(String(routeMediaSourceId))) .replace('{' + 'routeIndex' + '}', encodeURIComponent(String(routeIndex))) .replace('{' + 'routeStartPositionTicks' + '}', encodeURIComponent(String(routeStartPositionTicks))) .replace('{' + 'routeFormat' + '}', encodeURIComponent(String(routeFormat))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['text/*']; // 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 'routeItemId' is not null or undefined if (routeItemId === null || routeItemId === undefined) { throw new Error('Required parameter routeItemId was null or undefined when calling getSubtitleWithTicks.'); } // verify required parameter 'routeMediaSourceId' is not null or undefined if (routeMediaSourceId === null || routeMediaSourceId === undefined) { throw new Error('Required parameter routeMediaSourceId was null or undefined when calling getSubtitleWithTicks.'); } // verify required parameter 'routeIndex' is not null or undefined if (routeIndex === null || routeIndex === undefined) { throw new Error('Required parameter routeIndex was null or undefined when calling getSubtitleWithTicks.'); } // verify required parameter 'routeStartPositionTicks' is not null or undefined if (routeStartPositionTicks === null || routeStartPositionTicks === undefined) { throw new Error('Required parameter routeStartPositionTicks was null or undefined when calling getSubtitleWithTicks.'); } // verify required parameter 'routeFormat' is not null or undefined if (routeFormat === null || routeFormat === undefined) { throw new Error('Required parameter routeFormat was null or undefined when calling getSubtitleWithTicks.'); } if (itemId !== undefined) { localVarQueryParameters['itemId'] = ObjectSerializer.serialize(itemId, "string"); } if (mediaSourceId !== undefined) { localVarQueryParameters['mediaSourceId'] = ObjectSerializer.serialize(mediaSourceId, "string"); } if (index !== undefined) { localVarQueryParameters['index'] = ObjectSerializer.serialize(index, "number"); } if (startPositionTicks !== undefined) { localVarQueryParameters['startPositionTicks'] = ObjectSerializer.serialize(startPositionTicks, "number"); } if (format !== undefined) { localVarQueryParameters['format'] = ObjectSerializer.serialize(format, "string"); } if (endPositionTicks !== undefined) { localVarQueryParameters['endPositionTicks'] = ObjectSerializer.serialize(endPositionTicks, "number"); } if (copyTimestamps !== undefined) { localVarQueryParameters['copyTimestamps'] = ObjectSerializer.serialize(copyTimestamps, "boolean"); } if (addVttTimeMap !== undefined) { localVarQueryParameters['addVttTimeMap'] = ObjectSerializer.serialize(addVttTimeMap, "boolean"); } (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(); 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 Search remote subtitles. * @param itemId The item id. * @param language The language of the subtitles. * @param isPerfectMatch Optional. Only show subtitles which are a perfect match. */ public async searchRemoteSubtitles (itemId: string, language: string, isPerfectMatch?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { const localVarPath = this.basePath + '/Items/{itemId}/RemoteSearch/Subtitles/{language}' .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))) .replace('{' + 'language' + '}', encodeURIComponent(String(language))); 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 searchRemoteSubtitles.'); } // verify required parameter 'language' is not null or undefined if (language === null || language === undefined) { throw new Error('Required parameter language was null or undefined when calling searchRemoteSubtitles.'); } if (isPerfectMatch !== undefined) { localVarQueryParameters['isPerfectMatch'] = ObjectSerializer.serialize(isPerfectMatch, "boolean"); } (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: Array; }>((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, "Array"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Upload an external subtitle file. * @param itemId The item the subtitle belongs to. * @param uploadSubtitleRequest The request body. */ public async uploadSubtitle (itemId: string, uploadSubtitleRequest: UploadSubtitleRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/Videos/{itemId}/Subtitles' .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); 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 uploadSubtitle.'); } // verify required parameter 'uploadSubtitleRequest' is not null or undefined if (uploadSubtitleRequest === null || uploadSubtitleRequest === undefined) { throw new Error('Required parameter uploadSubtitleRequest was null or undefined when calling uploadSubtitle.'); } (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(uploadSubtitleRequest, "UploadSubtitleRequest") }; 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)); } } }); }); }); } }