@redseat/api 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/library.d.ts +57 -1
- package/dist/library.js +87 -1
- package/package.json +1 -1
package/dist/library.d.ts
CHANGED
|
@@ -79,7 +79,9 @@ export declare class LibraryApi {
|
|
|
79
79
|
private library;
|
|
80
80
|
private key?;
|
|
81
81
|
private keyText?;
|
|
82
|
-
|
|
82
|
+
private baseUrl?;
|
|
83
|
+
constructor(client: LibraryHttpClient, libraryId: string, library: ILibrary, baseUrl?: string);
|
|
84
|
+
setBaseUrl(baseUrl: string): void;
|
|
83
85
|
setKey(passPhrase: string): Promise<void>;
|
|
84
86
|
private getUrl;
|
|
85
87
|
getTags(query?: {
|
|
@@ -176,7 +178,61 @@ export declare class LibraryApi {
|
|
|
176
178
|
updatePersonPortrait(personId: string, portrait: FormData): Promise<void>;
|
|
177
179
|
searchSeries(name: string): Promise<ISerie[]>;
|
|
178
180
|
setEpisodeWatched(serieId: string, season: number, number: number, date: number): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Searches for available media sources for a specific episode.
|
|
183
|
+
* @param serieId - The series identifier
|
|
184
|
+
* @param season - The season number
|
|
185
|
+
* @param episode - The episode number
|
|
186
|
+
* @returns Array of available media requests that can be used to download/stream the episode
|
|
187
|
+
*/
|
|
179
188
|
searchEpisodeMedias(serieId: string, season: number, episode: number): Promise<RsRequest[]>;
|
|
189
|
+
/**
|
|
190
|
+
* Adds a searched episode media to the database for download/storage.
|
|
191
|
+
* @param serieId - The series identifier
|
|
192
|
+
* @param season - The season number
|
|
193
|
+
* @param episode - The episode number
|
|
194
|
+
* @param request - The media request to add (typically from searchEpisodeMedias results)
|
|
195
|
+
* @returns The created media file entry
|
|
196
|
+
*/
|
|
197
|
+
addSearchedEpisodeMedia(serieId: string, season: number, episode: number, request: RsRequest): Promise<IFile>;
|
|
198
|
+
/**
|
|
199
|
+
* Checks if a request can be made permanent (saved for later use).
|
|
200
|
+
* Tests the availability of the URL and returns a permanent version if valid.
|
|
201
|
+
* @param request - The request to check for permanence
|
|
202
|
+
* @returns The request with `permanent: true` if the URL is valid and can be saved
|
|
203
|
+
* @throws Error if the URL is not available or cannot be made permanent
|
|
204
|
+
*/
|
|
205
|
+
checkRequestPermanent(request: RsRequest): Promise<RsRequest>;
|
|
206
|
+
/**
|
|
207
|
+
* Get a share token for a request URL.
|
|
208
|
+
* The token can be used to stream/download the resource without authentication.
|
|
209
|
+
* @param url - The request URL to get a share token for
|
|
210
|
+
* @returns A temporary share token valid for 6 hours
|
|
211
|
+
*/
|
|
212
|
+
getRequestShareToken(url: string): Promise<string>;
|
|
213
|
+
/**
|
|
214
|
+
* Get a share token for a media file.
|
|
215
|
+
* The token can be used to access the media without authentication.
|
|
216
|
+
* @param mediaId - The media ID to get a share token for
|
|
217
|
+
* @returns A temporary share token valid for 6 hours
|
|
218
|
+
*/
|
|
219
|
+
getMediaShareToken(mediaId: string): Promise<string>;
|
|
220
|
+
/**
|
|
221
|
+
* Get a shareable URL for streaming a request.
|
|
222
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
223
|
+
* @param url - The request URL to create a share link for
|
|
224
|
+
* @returns A complete URL with sharetoken that can be used to stream the content
|
|
225
|
+
* @throws Error if baseUrl is not set
|
|
226
|
+
*/
|
|
227
|
+
getRequestShareUrl(url: string): Promise<string>;
|
|
228
|
+
/**
|
|
229
|
+
* Get a shareable URL for a media file.
|
|
230
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
231
|
+
* @param mediaId - The media ID to create a share link for
|
|
232
|
+
* @returns A complete URL with sharetoken that can be used to access the media
|
|
233
|
+
* @throws Error if baseUrl is not set
|
|
234
|
+
*/
|
|
235
|
+
getMediaShareUrl(mediaId: string): Promise<string>;
|
|
180
236
|
getUnassignedFaces(params?: Map<string, string>): Promise<any>;
|
|
181
237
|
getClusters(): Promise<any>;
|
|
182
238
|
assignFaces(request: any): Promise<any>;
|
package/dist/library.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { deriveKey, encryptText as encryptTextUtil, decryptText as decryptTextUtil, encryptBuffer, decryptBuffer, encryptFile as encryptFileUtil, decryptFile as decryptFileUtil, decryptFileThumb, encryptFilename as encryptFilenameUtil, getRandomIV as getRandomIVUtil } from './encryption.js';
|
|
2
2
|
import { uint8ArrayFromBase64 } from './crypto.js';
|
|
3
3
|
export class LibraryApi {
|
|
4
|
-
constructor(client, libraryId, library) {
|
|
4
|
+
constructor(client, libraryId, library, baseUrl) {
|
|
5
5
|
this.client = client;
|
|
6
6
|
this.libraryId = libraryId;
|
|
7
7
|
this.library = library;
|
|
8
|
+
this.baseUrl = baseUrl;
|
|
9
|
+
}
|
|
10
|
+
setBaseUrl(baseUrl) {
|
|
11
|
+
this.baseUrl = baseUrl;
|
|
8
12
|
}
|
|
9
13
|
async setKey(passPhrase) {
|
|
10
14
|
// Derive keys
|
|
@@ -425,10 +429,92 @@ export class LibraryApi {
|
|
|
425
429
|
async setEpisodeWatched(serieId, season, number, date) {
|
|
426
430
|
await this.client.post(this.getUrl(`/series/${serieId}/seasons/${season}/episodes/${number}/watched`), { date });
|
|
427
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Searches for available media sources for a specific episode.
|
|
434
|
+
* @param serieId - The series identifier
|
|
435
|
+
* @param season - The season number
|
|
436
|
+
* @param episode - The episode number
|
|
437
|
+
* @returns Array of available media requests that can be used to download/stream the episode
|
|
438
|
+
*/
|
|
428
439
|
async searchEpisodeMedias(serieId, season, episode) {
|
|
429
440
|
const res = await this.client.get(this.getUrl(`/series/${serieId}/seasons/${season}/episodes/${episode}/search`));
|
|
430
441
|
return res.data;
|
|
431
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* Adds a searched episode media to the database for download/storage.
|
|
445
|
+
* @param serieId - The series identifier
|
|
446
|
+
* @param season - The season number
|
|
447
|
+
* @param episode - The episode number
|
|
448
|
+
* @param request - The media request to add (typically from searchEpisodeMedias results)
|
|
449
|
+
* @returns The created media file entry
|
|
450
|
+
*/
|
|
451
|
+
async addSearchedEpisodeMedia(serieId, season, episode, request) {
|
|
452
|
+
const res = await this.client.post(this.getUrl(`/series/${serieId}/seasons/${season}/episodes/${episode}/search`), request);
|
|
453
|
+
return res.data;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Checks if a request can be made permanent (saved for later use).
|
|
457
|
+
* Tests the availability of the URL and returns a permanent version if valid.
|
|
458
|
+
* @param request - The request to check for permanence
|
|
459
|
+
* @returns The request with `permanent: true` if the URL is valid and can be saved
|
|
460
|
+
* @throws Error if the URL is not available or cannot be made permanent
|
|
461
|
+
*/
|
|
462
|
+
async checkRequestPermanent(request) {
|
|
463
|
+
const res = await this.client.post(this.getUrl('/plugins/requests/permanent'), request);
|
|
464
|
+
return res.data;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Get a share token for a request URL.
|
|
468
|
+
* The token can be used to stream/download the resource without authentication.
|
|
469
|
+
* @param url - The request URL to get a share token for
|
|
470
|
+
* @returns A temporary share token valid for 6 hours
|
|
471
|
+
*/
|
|
472
|
+
async getRequestShareToken(url) {
|
|
473
|
+
const res = await this.client.get(this.getUrl('/plugins/requests/url/sharetoken'), {
|
|
474
|
+
params: { url }
|
|
475
|
+
});
|
|
476
|
+
return res.data;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Get a share token for a media file.
|
|
480
|
+
* The token can be used to access the media without authentication.
|
|
481
|
+
* @param mediaId - The media ID to get a share token for
|
|
482
|
+
* @returns A temporary share token valid for 6 hours
|
|
483
|
+
*/
|
|
484
|
+
async getMediaShareToken(mediaId) {
|
|
485
|
+
const res = await this.client.get(this.getUrl(`/medias/${mediaId}/sharetoken`));
|
|
486
|
+
return res.data;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Get a shareable URL for streaming a request.
|
|
490
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
491
|
+
* @param url - The request URL to create a share link for
|
|
492
|
+
* @returns A complete URL with sharetoken that can be used to stream the content
|
|
493
|
+
* @throws Error if baseUrl is not set
|
|
494
|
+
*/
|
|
495
|
+
async getRequestShareUrl(url) {
|
|
496
|
+
if (!this.baseUrl) {
|
|
497
|
+
throw new Error('baseUrl must be set to generate share URLs. Call setBaseUrl() first.');
|
|
498
|
+
}
|
|
499
|
+
const shareToken = await this.getRequestShareToken(url);
|
|
500
|
+
const params = new URLSearchParams({ sharetoken: shareToken, url });
|
|
501
|
+
return `${this.baseUrl}${this.getUrl('/plugins/requests/url/stream')}?${params.toString()}`;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Get a shareable URL for a media file.
|
|
505
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
506
|
+
* @param mediaId - The media ID to create a share link for
|
|
507
|
+
* @returns A complete URL with sharetoken that can be used to access the media
|
|
508
|
+
* @throws Error if baseUrl is not set
|
|
509
|
+
*/
|
|
510
|
+
async getMediaShareUrl(mediaId) {
|
|
511
|
+
if (!this.baseUrl) {
|
|
512
|
+
throw new Error('baseUrl must be set to generate share URLs. Call setBaseUrl() first.');
|
|
513
|
+
}
|
|
514
|
+
const shareToken = await this.getMediaShareToken(mediaId);
|
|
515
|
+
const params = new URLSearchParams({ sharetoken: shareToken });
|
|
516
|
+
return `${this.baseUrl}${this.getUrl(`/medias/${mediaId}`)}?${params.toString()}`;
|
|
517
|
+
}
|
|
432
518
|
async getUnassignedFaces(params) {
|
|
433
519
|
const queryParams = {};
|
|
434
520
|
if (params) {
|