jellyfin-discord-bot/jellyfin/api/hlsSegmentApi.ts

491 lines
21 KiB
TypeScript
Raw Normal View History

2023-04-15 22:02:40 +02:00
/**
* 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 { ProblemDetails } from '../model/problemDetails';
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 HlsSegmentApiApiKeys {
CustomAuthentication,
}
export class HlsSegmentApi {
protected _basePath = defaultBasePath;
protected _defaultHeaders : any = {};
protected _useQuerystring : boolean = false;
protected authentications = {
'default': <Authentication>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: HlsSegmentApiApiKeys, value: string) {
(this.authentications as any)[HlsSegmentApiApiKeys[key]].apiKey = value;
}
public addInterceptor(interceptor: Interceptor) {
this.interceptors.push(interceptor);
}
/**
*
* @summary Gets the specified audio segment for an audio item.
* @param itemId The item id.
* @param segmentId The segment id.
*/
public async getHlsAudioSegmentLegacyAac (itemId: string, segmentId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> {
const localVarPath = this.basePath + '/Audio/{itemId}/hls/{segmentId}/stream.aac'
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)))
.replace('{' + 'segmentId' + '}', encodeURIComponent(String(segmentId)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
const produces = ['audio/*'];
// 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 getHlsAudioSegmentLegacyAac.');
}
// verify required parameter 'segmentId' is not null or undefined
if (segmentId === null || segmentId === undefined) {
throw new Error('Required parameter segmentId was null or undefined when calling getHlsAudioSegmentLegacyAac.');
}
(<any>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) {
(<any>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 the specified audio segment for an audio item.
* @param itemId The item id.
* @param segmentId The segment id.
*/
public async getHlsAudioSegmentLegacyMp3 (itemId: string, segmentId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> {
const localVarPath = this.basePath + '/Audio/{itemId}/hls/{segmentId}/stream.mp3'
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)))
.replace('{' + 'segmentId' + '}', encodeURIComponent(String(segmentId)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
const produces = ['audio/*'];
// 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 getHlsAudioSegmentLegacyMp3.');
}
// verify required parameter 'segmentId' is not null or undefined
if (segmentId === null || segmentId === undefined) {
throw new Error('Required parameter segmentId was null or undefined when calling getHlsAudioSegmentLegacyMp3.');
}
(<any>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) {
(<any>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 hls video playlist.
* @param itemId The video id.
* @param playlistId The playlist id.
*/
public async getHlsPlaylistLegacy (itemId: string, playlistId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> {
const localVarPath = this.basePath + '/Videos/{itemId}/hls/{playlistId}/stream.m3u8'
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)))
.replace('{' + 'playlistId' + '}', encodeURIComponent(String(playlistId)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<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 getHlsPlaylistLegacy.');
}
// verify required parameter 'playlistId' is not null or undefined
if (playlistId === null || playlistId === undefined) {
throw new Error('Required parameter playlistId was null or undefined when calling getHlsPlaylistLegacy.');
}
(<any>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) {
(<any>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 hls video segment.
* @param itemId The item id.
* @param playlistId The playlist id.
* @param segmentId The segment id.
* @param segmentContainer The segment container.
*/
public async getHlsVideoSegmentLegacy (itemId: string, playlistId: string, segmentId: string, segmentContainer: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> {
const localVarPath = this.basePath + '/Videos/{itemId}/hls/{playlistId}/{segmentId}.{segmentContainer}'
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)))
.replace('{' + 'playlistId' + '}', encodeURIComponent(String(playlistId)))
.replace('{' + 'segmentId' + '}', encodeURIComponent(String(segmentId)))
.replace('{' + 'segmentContainer' + '}', encodeURIComponent(String(segmentContainer)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
const produces = ['video/*', '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 getHlsVideoSegmentLegacy.');
}
// verify required parameter 'playlistId' is not null or undefined
if (playlistId === null || playlistId === undefined) {
throw new Error('Required parameter playlistId was null or undefined when calling getHlsVideoSegmentLegacy.');
}
// verify required parameter 'segmentId' is not null or undefined
if (segmentId === null || segmentId === undefined) {
throw new Error('Required parameter segmentId was null or undefined when calling getHlsVideoSegmentLegacy.');
}
// verify required parameter 'segmentContainer' is not null or undefined
if (segmentContainer === null || segmentContainer === undefined) {
throw new Error('Required parameter segmentContainer was null or undefined when calling getHlsVideoSegmentLegacy.');
}
(<any>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) {
(<any>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 Stops an active encoding.
* @param deviceId The device id of the client requesting. Used to stop encoding processes when needed.
* @param playSessionId The play session id.
*/
public async stopEncodingProcess (deviceId: string, playSessionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
const localVarPath = this.basePath + '/Videos/ActiveEncodings';
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
let localVarFormParams: any = {};
// verify required parameter 'deviceId' is not null or undefined
if (deviceId === null || deviceId === undefined) {
throw new Error('Required parameter deviceId was null or undefined when calling stopEncodingProcess.');
}
// verify required parameter 'playSessionId' is not null or undefined
if (playSessionId === null || playSessionId === undefined) {
throw new Error('Required parameter playSessionId was null or undefined when calling stopEncodingProcess.');
}
if (deviceId !== undefined) {
localVarQueryParameters['deviceId'] = ObjectSerializer.serialize(deviceId, "string");
}
if (playSessionId !== undefined) {
localVarQueryParameters['playSessionId'] = ObjectSerializer.serialize(playSessionId, "string");
}
(<any>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) {
(<any>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));
}
}
});
});
});
}
}