@redseat/api 0.0.11 → 0.0.12
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/README.md +132 -132
- package/agents.md +275 -275
- package/client.md +318 -288
- package/dist/client.d.ts +1 -0
- package/dist/client.js +3 -0
- package/dist/library.d.ts +3 -0
- package/dist/library.js +1 -1
- package/encryption.md +533 -533
- package/firebase.md +602 -602
- package/libraries.md +1652 -1652
- package/package.json +49 -49
- package/server.md +196 -196
- package/test.md +291 -291
package/libraries.md
CHANGED
|
@@ -1,1652 +1,1652 @@
|
|
|
1
|
-
# LibraryApi
|
|
2
|
-
|
|
3
|
-
The `LibraryApi` class provides comprehensive operations for managing media, tags, people, series, movies, and more within a specific library.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
`LibraryApi` handles all library-specific operations including:
|
|
8
|
-
- Media management (upload, download, update, delete)
|
|
9
|
-
- Tags, people, series, and movies
|
|
10
|
-
- Face recognition and clustering
|
|
11
|
-
- Encryption support for encrypted libraries
|
|
12
|
-
- Plugin integration
|
|
13
|
-
|
|
14
|
-
## Constructor
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
new LibraryApi(client: RedseatClient, libraryId: string, library: ILibrary)
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
**Parameters:**
|
|
21
|
-
- `client`: An initialized `RedseatClient` instance
|
|
22
|
-
- `libraryId`: The ID of the library
|
|
23
|
-
- `library`: The `ILibrary` object with library configuration
|
|
24
|
-
|
|
25
|
-
**Example:**
|
|
26
|
-
```typescript
|
|
27
|
-
import { RedseatClient, LibraryApi, ServerApi } from '@redseat/api';
|
|
28
|
-
|
|
29
|
-
const client = new RedseatClient({ /* ... */ });
|
|
30
|
-
const serverApi = new ServerApi(client);
|
|
31
|
-
const libraries = await serverApi.getLibraries();
|
|
32
|
-
const library = libraries[0];
|
|
33
|
-
|
|
34
|
-
const libraryApi = new LibraryApi(client, library.id!, library);
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Initialization
|
|
38
|
-
|
|
39
|
-
### `setKey(passPhrase: string): Promise<void>`
|
|
40
|
-
|
|
41
|
-
Sets the encryption key for encrypted libraries. Must be called before any operations on encrypted libraries.
|
|
42
|
-
|
|
43
|
-
**Parameters:**
|
|
44
|
-
- `passPhrase`: The passphrase to derive encryption keys from
|
|
45
|
-
|
|
46
|
-
**Throws:** Error if the passphrase is incorrect (for encrypted libraries)
|
|
47
|
-
|
|
48
|
-
**Example:**
|
|
49
|
-
```typescript
|
|
50
|
-
if (library.crypt) {
|
|
51
|
-
try {
|
|
52
|
-
await libraryApi.setKey('my-secure-password');
|
|
53
|
-
console.log('Encryption key set successfully');
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error('Invalid encryption key:', error.message);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**Note:** This method verifies the key by attempting to decrypt a media thumbnail. If decryption fails, it throws an error.
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## Tags
|
|
65
|
-
|
|
66
|
-
### `getTags(): Promise<ITag[]>`
|
|
67
|
-
|
|
68
|
-
Retrieves all tags in the library.
|
|
69
|
-
|
|
70
|
-
**Returns:** Promise resolving to an array of `ITag` objects
|
|
71
|
-
|
|
72
|
-
**Example:**
|
|
73
|
-
```typescript
|
|
74
|
-
const tags = await libraryApi.getTags();
|
|
75
|
-
tags.forEach(tag => console.log(tag.name));
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### `createTag(tag: Partial<ITag>): Promise<ITag>`
|
|
79
|
-
|
|
80
|
-
Creates a new tag.
|
|
81
|
-
|
|
82
|
-
**Parameters:**
|
|
83
|
-
- `tag`: Partial tag object with at least `name` property
|
|
84
|
-
|
|
85
|
-
**Returns:** Promise resolving to the created `ITag` object
|
|
86
|
-
|
|
87
|
-
**Example:**
|
|
88
|
-
```typescript
|
|
89
|
-
const newTag = await libraryApi.createTag({ name: 'Vacation' });
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### `removeTag(tagId: string): Promise<void>`
|
|
93
|
-
|
|
94
|
-
Deletes a tag.
|
|
95
|
-
|
|
96
|
-
**Parameters:**
|
|
97
|
-
- `tagId`: The ID of the tag to remove
|
|
98
|
-
|
|
99
|
-
**Example:**
|
|
100
|
-
```typescript
|
|
101
|
-
await libraryApi.removeTag('tag-id-123');
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### `renameTag(tagId: string, newName: string): Promise<ITag>`
|
|
105
|
-
|
|
106
|
-
Renames a tag.
|
|
107
|
-
|
|
108
|
-
**Parameters:**
|
|
109
|
-
- `tagId`: The ID of the tag
|
|
110
|
-
- `newName`: The new name for the tag
|
|
111
|
-
|
|
112
|
-
**Returns:** Promise resolving to the updated `ITag` object
|
|
113
|
-
|
|
114
|
-
**Example:**
|
|
115
|
-
```typescript
|
|
116
|
-
const updated = await libraryApi.renameTag('tag-id', 'New Tag Name');
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### `tagChangeParent(tagId: string, newParent?: string): Promise<ITag>`
|
|
120
|
-
|
|
121
|
-
Changes the parent tag (for tag hierarchy).
|
|
122
|
-
|
|
123
|
-
**Parameters:**
|
|
124
|
-
- `tagId`: The ID of the tag
|
|
125
|
-
- `newParent`: Optional parent tag ID (undefined to remove parent)
|
|
126
|
-
|
|
127
|
-
**Returns:** Promise resolving to the updated `ITag` object
|
|
128
|
-
|
|
129
|
-
**Example:**
|
|
130
|
-
```typescript
|
|
131
|
-
// Set parent
|
|
132
|
-
await libraryApi.tagChangeParent('child-tag-id', 'parent-tag-id');
|
|
133
|
-
|
|
134
|
-
// Remove parent
|
|
135
|
-
await libraryApi.tagChangeParent('tag-id', undefined);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### `tagMerge(fromId: string, intoId: string): Promise<ITag>`
|
|
139
|
-
|
|
140
|
-
Merges one tag into another.
|
|
141
|
-
|
|
142
|
-
**Parameters:**
|
|
143
|
-
- `fromId`: The tag ID to merge from (will be deleted)
|
|
144
|
-
- `intoId`: The tag ID to merge into
|
|
145
|
-
|
|
146
|
-
**Returns:** Promise resolving to the merged `ITag` object
|
|
147
|
-
|
|
148
|
-
**Example:**
|
|
149
|
-
```typescript
|
|
150
|
-
await libraryApi.tagMerge('old-tag-id', 'new-tag-id');
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### `tagAddAlt(tagId: string, alt: string): Promise<ITag>`
|
|
154
|
-
|
|
155
|
-
Adds an alternative name to a tag.
|
|
156
|
-
|
|
157
|
-
**Parameters:**
|
|
158
|
-
- `tagId`: The ID of the tag
|
|
159
|
-
- `alt`: Alternative name to add
|
|
160
|
-
|
|
161
|
-
**Returns:** Promise resolving to the updated `ITag` object
|
|
162
|
-
|
|
163
|
-
**Example:**
|
|
164
|
-
```typescript
|
|
165
|
-
await libraryApi.tagAddAlt('tag-id', 'alternative-name');
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### `tagRemoveAlt(tagId: string, alt: string): Promise<ITag>`
|
|
169
|
-
|
|
170
|
-
Removes an alternative name from a tag.
|
|
171
|
-
|
|
172
|
-
**Parameters:**
|
|
173
|
-
- `tagId`: The ID of the tag
|
|
174
|
-
- `alt`: Alternative name to remove
|
|
175
|
-
|
|
176
|
-
**Returns:** Promise resolving to the updated `ITag` object
|
|
177
|
-
|
|
178
|
-
**Example:**
|
|
179
|
-
```typescript
|
|
180
|
-
await libraryApi.tagRemoveAlt('tag-id', 'alternative-name');
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
## People
|
|
186
|
-
|
|
187
|
-
### `getPeople(): Promise<IPerson[]>`
|
|
188
|
-
|
|
189
|
-
Retrieves all people in the library.
|
|
190
|
-
|
|
191
|
-
**Returns:** Promise resolving to an array of `IPerson` objects
|
|
192
|
-
|
|
193
|
-
**Example:**
|
|
194
|
-
```typescript
|
|
195
|
-
const people = await libraryApi.getPeople();
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### `createPerson(person: Partial<IPerson>): Promise<IPerson>`
|
|
199
|
-
|
|
200
|
-
Creates a new person.
|
|
201
|
-
|
|
202
|
-
**Parameters:**
|
|
203
|
-
- `person`: Partial person object with at least `name` property
|
|
204
|
-
|
|
205
|
-
**Returns:** Promise resolving to the created `IPerson` object
|
|
206
|
-
|
|
207
|
-
**Example:**
|
|
208
|
-
```typescript
|
|
209
|
-
const person = await libraryApi.createPerson({ name: 'John Doe' });
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### `removePerson(personId: string): Promise<void>`
|
|
213
|
-
|
|
214
|
-
Deletes a person.
|
|
215
|
-
|
|
216
|
-
**Parameters:**
|
|
217
|
-
- `personId`: The ID of the person to remove
|
|
218
|
-
|
|
219
|
-
**Example:**
|
|
220
|
-
```typescript
|
|
221
|
-
await libraryApi.removePerson('person-id');
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### `updatePerson(personId: string, updates: Partial<IPerson>): Promise<IPerson>`
|
|
225
|
-
|
|
226
|
-
Updates a person's information.
|
|
227
|
-
|
|
228
|
-
**Parameters:**
|
|
229
|
-
- `personId`: The ID of the person
|
|
230
|
-
- `updates`: Partial person object with fields to update
|
|
231
|
-
|
|
232
|
-
**Returns:** Promise resolving to the updated `IPerson` object
|
|
233
|
-
|
|
234
|
-
**Example:**
|
|
235
|
-
```typescript
|
|
236
|
-
await libraryApi.updatePerson('person-id', { birthday: 1234567890 });
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### `personRename(personId: string, newName: string): Promise<IPerson>`
|
|
240
|
-
|
|
241
|
-
Renames a person.
|
|
242
|
-
|
|
243
|
-
**Parameters:**
|
|
244
|
-
- `personId`: The ID of the person
|
|
245
|
-
- `newName`: The new name
|
|
246
|
-
|
|
247
|
-
**Returns:** Promise resolving to the updated `IPerson` object
|
|
248
|
-
|
|
249
|
-
**Example:**
|
|
250
|
-
```typescript
|
|
251
|
-
await libraryApi.personRename('person-id', 'Jane Doe');
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
### `personAddAlt(personId: string, alt: string): Promise<IPerson>`
|
|
255
|
-
|
|
256
|
-
Adds an alternative name to a person.
|
|
257
|
-
|
|
258
|
-
**Parameters:**
|
|
259
|
-
- `personId`: The ID of the person
|
|
260
|
-
- `alt`: Alternative name to add
|
|
261
|
-
|
|
262
|
-
**Returns:** Promise resolving to the updated `IPerson` object
|
|
263
|
-
|
|
264
|
-
**Example:**
|
|
265
|
-
```typescript
|
|
266
|
-
await libraryApi.personAddAlt('person-id', 'nickname');
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### `personRemoveAlt(personId: string, alt: string): Promise<IPerson>`
|
|
270
|
-
|
|
271
|
-
Removes an alternative name from a person.
|
|
272
|
-
|
|
273
|
-
**Parameters:**
|
|
274
|
-
- `personId`: The ID of the person
|
|
275
|
-
- `alt`: Alternative name to remove
|
|
276
|
-
|
|
277
|
-
**Returns:** Promise resolving to the updated `IPerson` object
|
|
278
|
-
|
|
279
|
-
**Example:**
|
|
280
|
-
```typescript
|
|
281
|
-
await libraryApi.personRemoveAlt('person-id', 'nickname');
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
### `personAddSocial(personId: string, social: any): Promise<IPerson>`
|
|
285
|
-
|
|
286
|
-
Adds a social media link to a person.
|
|
287
|
-
|
|
288
|
-
**Parameters:**
|
|
289
|
-
- `personId`: The ID of the person
|
|
290
|
-
- `social`: Social media object with `id`, `type`, and `platform`
|
|
291
|
-
|
|
292
|
-
**Returns:** Promise resolving to the updated `IPerson` object
|
|
293
|
-
|
|
294
|
-
**Example:**
|
|
295
|
-
```typescript
|
|
296
|
-
await libraryApi.personAddSocial('person-id', {
|
|
297
|
-
id: 'username',
|
|
298
|
-
type: 'profile',
|
|
299
|
-
platform: 'instagram'
|
|
300
|
-
});
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### `personRemoveSocial(personId: string, social: any): Promise<IPerson>`
|
|
304
|
-
|
|
305
|
-
Removes a social media link from a person.
|
|
306
|
-
|
|
307
|
-
**Parameters:**
|
|
308
|
-
- `personId`: The ID of the person
|
|
309
|
-
- `social`: Social media object to remove
|
|
310
|
-
|
|
311
|
-
**Returns:** Promise resolving to the updated `IPerson` object
|
|
312
|
-
|
|
313
|
-
**Example:**
|
|
314
|
-
```typescript
|
|
315
|
-
await libraryApi.personRemoveSocial('person-id', socialObject);
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### `updatePersonPortrait(personId: string, portrait: FormData): Promise<void>`
|
|
319
|
-
|
|
320
|
-
Updates a person's portrait image.
|
|
321
|
-
|
|
322
|
-
**Parameters:**
|
|
323
|
-
- `personId`: The ID of the person
|
|
324
|
-
- `portrait`: FormData containing the portrait image
|
|
325
|
-
|
|
326
|
-
**Example:**
|
|
327
|
-
```typescript
|
|
328
|
-
const formData = new FormData();
|
|
329
|
-
formData.append('file', imageBlob);
|
|
330
|
-
await libraryApi.updatePersonPortrait('person-id', formData);
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
---
|
|
334
|
-
|
|
335
|
-
## Series
|
|
336
|
-
|
|
337
|
-
### `getSeries(): Promise<ISerie[]>`
|
|
338
|
-
|
|
339
|
-
Retrieves all series in the library, sorted by name.
|
|
340
|
-
|
|
341
|
-
**Returns:** Promise resolving to an array of `ISerie` objects
|
|
342
|
-
|
|
343
|
-
**Example:**
|
|
344
|
-
```typescript
|
|
345
|
-
const series = await libraryApi.getSeries();
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
### `createSerie(serie: Partial<ISerie>): Promise<ISerie>`
|
|
349
|
-
|
|
350
|
-
Creates a new series.
|
|
351
|
-
|
|
352
|
-
**Parameters:**
|
|
353
|
-
- `serie`: Partial series object
|
|
354
|
-
|
|
355
|
-
**Returns:** Promise resolving to the created `ISerie` object
|
|
356
|
-
|
|
357
|
-
**Example:**
|
|
358
|
-
```typescript
|
|
359
|
-
const serie = await libraryApi.createSerie({ name: 'Breaking Bad' });
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
### `createEpisode(episode: Partial<IEpisode>): Promise<IEpisode>`
|
|
363
|
-
|
|
364
|
-
Creates a new episode.
|
|
365
|
-
|
|
366
|
-
**Parameters:**
|
|
367
|
-
- `episode`: Partial episode object
|
|
368
|
-
|
|
369
|
-
**Returns:** Promise resolving to the created `IEpisode` object
|
|
370
|
-
|
|
371
|
-
**Example:**
|
|
372
|
-
```typescript
|
|
373
|
-
const episode = await libraryApi.createEpisode({
|
|
374
|
-
serie: 'serie-id',
|
|
375
|
-
season: 1,
|
|
376
|
-
number: 1,
|
|
377
|
-
name: 'Pilot'
|
|
378
|
-
});
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### `serieScrap(serieId: string, date?: number): Promise<void>`
|
|
382
|
-
|
|
383
|
-
Triggers metadata scraping for a series.
|
|
384
|
-
|
|
385
|
-
**Parameters:**
|
|
386
|
-
- `serieId`: The ID of the series
|
|
387
|
-
- `date`: Optional date parameter
|
|
388
|
-
|
|
389
|
-
**Example:**
|
|
390
|
-
```typescript
|
|
391
|
-
await libraryApi.serieScrap('serie-id');
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
### `removeSerie(serieId: string): Promise<void>`
|
|
395
|
-
|
|
396
|
-
Deletes a series.
|
|
397
|
-
|
|
398
|
-
**Parameters:**
|
|
399
|
-
- `serieId`: The ID of the series to remove
|
|
400
|
-
|
|
401
|
-
**Example:**
|
|
402
|
-
```typescript
|
|
403
|
-
await libraryApi.removeSerie('serie-id');
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
### `updateSerie(serieId: string, updates: Partial<ISerie>): Promise<ISerie>`
|
|
407
|
-
|
|
408
|
-
Updates a series.
|
|
409
|
-
|
|
410
|
-
**Parameters:**
|
|
411
|
-
- `serieId`: The ID of the series
|
|
412
|
-
- `updates`: Partial series object with fields to update
|
|
413
|
-
|
|
414
|
-
**Returns:** Promise resolving to the updated `ISerie` object
|
|
415
|
-
|
|
416
|
-
**Example:**
|
|
417
|
-
```typescript
|
|
418
|
-
await libraryApi.updateSerie('serie-id', { description: 'New description' });
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
### `getSerieImages(serieId: string): Promise<ExternalImage[]>`
|
|
422
|
-
|
|
423
|
-
Gets available images for a series from external sources.
|
|
424
|
-
|
|
425
|
-
**Parameters:**
|
|
426
|
-
- `serieId`: The ID of the series
|
|
427
|
-
|
|
428
|
-
**Returns:** Promise resolving to an array of `ExternalImage` objects
|
|
429
|
-
|
|
430
|
-
**Example:**
|
|
431
|
-
```typescript
|
|
432
|
-
const images = await libraryApi.getSerieImages('serie-id');
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
### `updateSeriePoster(serieId: string, poster: FormData, type: string): Promise<void>`
|
|
436
|
-
|
|
437
|
-
Updates a series poster image.
|
|
438
|
-
|
|
439
|
-
**Parameters:**
|
|
440
|
-
- `serieId`: The ID of the series
|
|
441
|
-
- `poster`: FormData containing the poster image
|
|
442
|
-
- `type`: Poster type (e.g., 'poster', 'backdrop')
|
|
443
|
-
|
|
444
|
-
**Example:**
|
|
445
|
-
```typescript
|
|
446
|
-
const formData = new FormData();
|
|
447
|
-
formData.append('file', posterBlob);
|
|
448
|
-
await libraryApi.updateSeriePoster('serie-id', formData, 'poster');
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
### `updateSeriePosterWithMediaThumb(serieId: string, mediaId: string, type: string): Promise<ISerie>`
|
|
452
|
-
|
|
453
|
-
Sets a series poster using a media thumbnail.
|
|
454
|
-
|
|
455
|
-
**Parameters:**
|
|
456
|
-
- `serieId`: The ID of the series
|
|
457
|
-
- `mediaId`: The ID of the media to use as poster
|
|
458
|
-
- `type`: Poster type
|
|
459
|
-
|
|
460
|
-
**Returns:** Promise resolving to the updated `ISerie` object
|
|
461
|
-
|
|
462
|
-
**Example:**
|
|
463
|
-
```typescript
|
|
464
|
-
await libraryApi.updateSeriePosterWithMediaThumb('serie-id', 'media-id', 'poster');
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
### `updateSerieImageFetch(serieId: string, image: ExternalImage): Promise<void>`
|
|
468
|
-
|
|
469
|
-
Fetches and sets an external image as series poster.
|
|
470
|
-
|
|
471
|
-
**Parameters:**
|
|
472
|
-
- `serieId`: The ID of the series
|
|
473
|
-
- `image`: External image object to fetch
|
|
474
|
-
|
|
475
|
-
**Example:**
|
|
476
|
-
```typescript
|
|
477
|
-
await libraryApi.updateSerieImageFetch('serie-id', externalImage);
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
### `serieRename(serieId: string, newName: string): Promise<ISerie>`
|
|
481
|
-
|
|
482
|
-
Renames a series.
|
|
483
|
-
|
|
484
|
-
**Parameters:**
|
|
485
|
-
- `serieId`: The ID of the series
|
|
486
|
-
- `newName`: The new name
|
|
487
|
-
|
|
488
|
-
**Returns:** Promise resolving to the updated `ISerie` object
|
|
489
|
-
|
|
490
|
-
**Example:**
|
|
491
|
-
```typescript
|
|
492
|
-
await libraryApi.serieRename('serie-id', 'New Series Name');
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
### `serieAddAlt(serieId: string, alt: string): Promise<ISerie>`
|
|
496
|
-
|
|
497
|
-
Adds an alternative name to a series.
|
|
498
|
-
|
|
499
|
-
**Parameters:**
|
|
500
|
-
- `serieId`: The ID of the series
|
|
501
|
-
- `alt`: Alternative name to add
|
|
502
|
-
|
|
503
|
-
**Returns:** Promise resolving to the updated `ISerie` object
|
|
504
|
-
|
|
505
|
-
**Example:**
|
|
506
|
-
```typescript
|
|
507
|
-
await libraryApi.serieAddAlt('serie-id', 'alternative-name');
|
|
508
|
-
```
|
|
509
|
-
|
|
510
|
-
### `serieRemoveAlt(serieId: string, alt: string): Promise<ISerie>`
|
|
511
|
-
|
|
512
|
-
Removes an alternative name from a series.
|
|
513
|
-
|
|
514
|
-
**Parameters:**
|
|
515
|
-
- `serieId`: The ID of the series
|
|
516
|
-
- `alt`: Alternative name to remove
|
|
517
|
-
|
|
518
|
-
**Returns:** Promise resolving to the updated `ISerie` object
|
|
519
|
-
|
|
520
|
-
**Example:**
|
|
521
|
-
```typescript
|
|
522
|
-
await libraryApi.serieRemoveAlt('serie-id', 'alternative-name');
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
### `searchSeries(name: string): Promise<ISerie[]>`
|
|
526
|
-
|
|
527
|
-
Searches for series by name.
|
|
528
|
-
|
|
529
|
-
**Parameters:**
|
|
530
|
-
- `name`: Search query
|
|
531
|
-
|
|
532
|
-
**Returns:** Promise resolving to an array of matching `ISerie` objects
|
|
533
|
-
|
|
534
|
-
**Example:**
|
|
535
|
-
```typescript
|
|
536
|
-
const results = await libraryApi.searchSeries('Breaking');
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
### `setEpisodeWatched(serieId: string, season: number, number: number, date: number): Promise<void>`
|
|
540
|
-
|
|
541
|
-
Marks an episode as watched.
|
|
542
|
-
|
|
543
|
-
**Parameters:**
|
|
544
|
-
- `serieId`: The ID of the series
|
|
545
|
-
- `season`: Season number
|
|
546
|
-
- `number`: Episode number
|
|
547
|
-
- `date`: Timestamp of when it was watched
|
|
548
|
-
|
|
549
|
-
**Example:**
|
|
550
|
-
```typescript
|
|
551
|
-
await libraryApi.setEpisodeWatched('serie-id', 1, 1, Date.now());
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
---
|
|
555
|
-
|
|
556
|
-
## Movies
|
|
557
|
-
|
|
558
|
-
### `getMovies(): Promise<IMovie[]>`
|
|
559
|
-
|
|
560
|
-
Retrieves all movies in the library.
|
|
561
|
-
|
|
562
|
-
**Returns:** Promise resolving to an array of `IMovie` objects
|
|
563
|
-
|
|
564
|
-
**Example:**
|
|
565
|
-
```typescript
|
|
566
|
-
const movies = await libraryApi.getMovies();
|
|
567
|
-
```
|
|
568
|
-
|
|
569
|
-
### `createMovie(movie: Partial<IMovie>): Promise<IMovie>`
|
|
570
|
-
|
|
571
|
-
Creates a new movie.
|
|
572
|
-
|
|
573
|
-
**Parameters:**
|
|
574
|
-
- `movie`: Partial movie object
|
|
575
|
-
|
|
576
|
-
**Returns:** Promise resolving to the created `IMovie` object
|
|
577
|
-
|
|
578
|
-
**Example:**
|
|
579
|
-
```typescript
|
|
580
|
-
const movie = await libraryApi.createMovie({ name: 'The Matrix' });
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
### `movieScrap(movieId: string, date?: number): Promise<void>`
|
|
584
|
-
|
|
585
|
-
Triggers metadata scraping for a movie.
|
|
586
|
-
|
|
587
|
-
**Parameters:**
|
|
588
|
-
- `movieId`: The ID of the movie
|
|
589
|
-
- `date`: Optional date parameter
|
|
590
|
-
|
|
591
|
-
**Example:**
|
|
592
|
-
```typescript
|
|
593
|
-
await libraryApi.movieScrap('movie-id');
|
|
594
|
-
```
|
|
595
|
-
|
|
596
|
-
### `removeMovie(movieId: string): Promise<void>`
|
|
597
|
-
|
|
598
|
-
Deletes a movie.
|
|
599
|
-
|
|
600
|
-
**Parameters:**
|
|
601
|
-
- `movieId`: The ID of the movie to remove
|
|
602
|
-
|
|
603
|
-
**Example:**
|
|
604
|
-
```typescript
|
|
605
|
-
await libraryApi.removeMovie('movie-id');
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
### `updateMovie(movieId: string, updates: Partial<IMovie>): Promise<IMovie>`
|
|
609
|
-
|
|
610
|
-
Updates a movie.
|
|
611
|
-
|
|
612
|
-
**Parameters:**
|
|
613
|
-
- `movieId`: The ID of the movie
|
|
614
|
-
- `updates`: Partial movie object with fields to update
|
|
615
|
-
|
|
616
|
-
**Returns:** Promise resolving to the updated `IMovie` object
|
|
617
|
-
|
|
618
|
-
**Example:**
|
|
619
|
-
```typescript
|
|
620
|
-
await libraryApi.updateMovie('movie-id', { description: 'New description' });
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
### `getMovieImages(movieId: string): Promise<ExternalImage[]>`
|
|
624
|
-
|
|
625
|
-
Gets available images for a movie from external sources.
|
|
626
|
-
|
|
627
|
-
**Parameters:**
|
|
628
|
-
- `movieId`: The ID of the movie
|
|
629
|
-
|
|
630
|
-
**Returns:** Promise resolving to an array of `ExternalImage` objects
|
|
631
|
-
|
|
632
|
-
**Example:**
|
|
633
|
-
```typescript
|
|
634
|
-
const images = await libraryApi.getMovieImages('movie-id');
|
|
635
|
-
```
|
|
636
|
-
|
|
637
|
-
### `setMovieWatched(movieId: string, date: number): Promise<void>`
|
|
638
|
-
|
|
639
|
-
Marks a movie as watched.
|
|
640
|
-
|
|
641
|
-
**Parameters:**
|
|
642
|
-
- `movieId`: The ID of the movie
|
|
643
|
-
- `date`: Timestamp of when it was watched
|
|
644
|
-
|
|
645
|
-
**Example:**
|
|
646
|
-
```typescript
|
|
647
|
-
await libraryApi.setMovieWatched('movie-id', Date.now());
|
|
648
|
-
```
|
|
649
|
-
|
|
650
|
-
### `searchMovies(name: string): Promise<IMovie[]>`
|
|
651
|
-
|
|
652
|
-
Searches for movies by name.
|
|
653
|
-
|
|
654
|
-
**Parameters:**
|
|
655
|
-
- `name`: Search query
|
|
656
|
-
|
|
657
|
-
**Returns:** Promise resolving to an array of matching `IMovie` objects
|
|
658
|
-
|
|
659
|
-
**Example:**
|
|
660
|
-
```typescript
|
|
661
|
-
const results = await libraryApi.searchMovies('Matrix');
|
|
662
|
-
```
|
|
663
|
-
|
|
664
|
-
### `movieRename(movieId: string, newName: string): Promise<IMovie>`
|
|
665
|
-
|
|
666
|
-
Renames a movie.
|
|
667
|
-
|
|
668
|
-
**Parameters:**
|
|
669
|
-
- `movieId`: The ID of the movie
|
|
670
|
-
- `newName`: The new name
|
|
671
|
-
|
|
672
|
-
**Returns:** Promise resolving to the updated `IMovie` object
|
|
673
|
-
|
|
674
|
-
**Example:**
|
|
675
|
-
```typescript
|
|
676
|
-
await libraryApi.movieRename('movie-id', 'New Movie Name');
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
### `updateMoviePoster(movieId: string, poster: FormData, type: string): Promise<void>`
|
|
680
|
-
|
|
681
|
-
Updates a movie poster image.
|
|
682
|
-
|
|
683
|
-
**Parameters:**
|
|
684
|
-
- `movieId`: The ID of the movie
|
|
685
|
-
- `poster`: FormData containing the poster image
|
|
686
|
-
- `type`: Poster type
|
|
687
|
-
|
|
688
|
-
**Example:**
|
|
689
|
-
```typescript
|
|
690
|
-
const formData = new FormData();
|
|
691
|
-
formData.append('file', posterBlob);
|
|
692
|
-
await libraryApi.updateMoviePoster('movie-id', formData, 'poster');
|
|
693
|
-
```
|
|
694
|
-
|
|
695
|
-
### `updateMovieImageFetch(movieId: string, image: ExternalImage): Promise<void>`
|
|
696
|
-
|
|
697
|
-
Fetches and sets an external image as movie poster.
|
|
698
|
-
|
|
699
|
-
**Parameters:**
|
|
700
|
-
- `movieId`: The ID of the movie
|
|
701
|
-
- `image`: External image object to fetch
|
|
702
|
-
|
|
703
|
-
**Example:**
|
|
704
|
-
```typescript
|
|
705
|
-
await libraryApi.updateMovieImageFetch('movie-id', externalImage);
|
|
706
|
-
```
|
|
707
|
-
|
|
708
|
-
---
|
|
709
|
-
|
|
710
|
-
## Media
|
|
711
|
-
|
|
712
|
-
### `getMedias(filter?: MediaRequest): Promise<IFile[]>`
|
|
713
|
-
|
|
714
|
-
Retrieves media files with optional filtering.
|
|
715
|
-
|
|
716
|
-
**Parameters:**
|
|
717
|
-
- `filter`: Optional `MediaRequest` object for filtering/sorting
|
|
718
|
-
|
|
719
|
-
**Returns:** Promise resolving to an array of `IFile` objects
|
|
720
|
-
|
|
721
|
-
**Example:**
|
|
722
|
-
```typescript
|
|
723
|
-
// Get all media
|
|
724
|
-
const allMedias = await libraryApi.getMedias();
|
|
725
|
-
|
|
726
|
-
// Get filtered media
|
|
727
|
-
const photos = await libraryApi.getMedias({
|
|
728
|
-
type: 'photo',
|
|
729
|
-
limit: 50,
|
|
730
|
-
offset: 0
|
|
731
|
-
});
|
|
732
|
-
```
|
|
733
|
-
|
|
734
|
-
### `getMedia(mediaId: string, options?: { type?: 'stream' | 'arraybuffer' | 'blob' }): Promise<ReadableStream | ArrayBuffer | Blob>`
|
|
735
|
-
|
|
736
|
-
Downloads a media file.
|
|
737
|
-
|
|
738
|
-
**Parameters:**
|
|
739
|
-
- `mediaId`: The ID of the media
|
|
740
|
-
- `options`: Optional object with `type` property ('stream', 'arraybuffer', or 'blob')
|
|
741
|
-
|
|
742
|
-
**Returns:** Promise resolving to the media data in the requested format
|
|
743
|
-
|
|
744
|
-
**Example:**
|
|
745
|
-
```typescript
|
|
746
|
-
// Get as blob
|
|
747
|
-
const blob = await libraryApi.getMedia('media-id', { type: 'blob' });
|
|
748
|
-
|
|
749
|
-
// Get as stream
|
|
750
|
-
const stream = await libraryApi.getMedia('media-id', { type: 'stream' });
|
|
751
|
-
|
|
752
|
-
// For encrypted libraries, decrypt after getting
|
|
753
|
-
if (library.crypt) {
|
|
754
|
-
const encryptedBlob = await libraryApi.getMedia('media-id', { type: 'arraybuffer' });
|
|
755
|
-
const decrypted = await libraryApi.decryptFile('passphrase', encryptedBlob);
|
|
756
|
-
}
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
### `getThumb(mediaId: string, options?: { type?: 'stream' | 'arraybuffer' | 'blob' }): Promise<ReadableStream | ArrayBuffer | Blob>`
|
|
760
|
-
|
|
761
|
-
Gets a media thumbnail.
|
|
762
|
-
|
|
763
|
-
**Parameters:**
|
|
764
|
-
- `mediaId`: The ID of the media
|
|
765
|
-
- `options`: Optional object with `type` property
|
|
766
|
-
|
|
767
|
-
**Returns:** Promise resolving to the thumbnail data
|
|
768
|
-
|
|
769
|
-
**Example:**
|
|
770
|
-
```typescript
|
|
771
|
-
// Get thumbnail as blob
|
|
772
|
-
const thumbBlob = await libraryApi.getThumb('media-id', { type: 'blob' });
|
|
773
|
-
|
|
774
|
-
// For encrypted libraries, decrypt thumbnail
|
|
775
|
-
if (library.crypt) {
|
|
776
|
-
const media = await libraryApi.getMediaMetadata('media-id');
|
|
777
|
-
const iv = uint8ArrayFromBase64(media.iv!);
|
|
778
|
-
const encryptedThumb = await libraryApi.getThumb('media-id', { type: 'arraybuffer' });
|
|
779
|
-
const decryptedThumb = await libraryApi.decryptMedia('passphrase', encryptedThumb, iv);
|
|
780
|
-
}
|
|
781
|
-
```
|
|
782
|
-
|
|
783
|
-
### `getMediaMetadata(mediaId: string): Promise<IFile>`
|
|
784
|
-
|
|
785
|
-
Gets metadata for a media file.
|
|
786
|
-
|
|
787
|
-
**Parameters:**
|
|
788
|
-
- `mediaId`: The ID of the media
|
|
789
|
-
|
|
790
|
-
**Returns:** Promise resolving to `IFile` object with metadata
|
|
791
|
-
|
|
792
|
-
**Example:**
|
|
793
|
-
```typescript
|
|
794
|
-
const metadata = await libraryApi.getMediaMetadata('media-id');
|
|
795
|
-
console.log(`File: ${metadata.name}, Size: ${metadata.size}`);
|
|
796
|
-
```
|
|
797
|
-
|
|
798
|
-
### `getMediaBackupMetadatas(mediaId: string): Promise<IBackupFile[]>`
|
|
799
|
-
|
|
800
|
-
Gets backup metadata for a media file.
|
|
801
|
-
|
|
802
|
-
**Parameters:**
|
|
803
|
-
- `mediaId`: The ID of the media
|
|
804
|
-
|
|
805
|
-
**Returns:** Promise resolving to an array of `IBackupFile` objects
|
|
806
|
-
|
|
807
|
-
**Example:**
|
|
808
|
-
```typescript
|
|
809
|
-
const backups = await libraryApi.getMediaBackupMetadatas('media-id');
|
|
810
|
-
```
|
|
811
|
-
|
|
812
|
-
### `uploadMedia(data: ArrayBuffer | Uint8Array, options: UploadMediaOptions): Promise<IFile>`
|
|
813
|
-
|
|
814
|
-
Uploads a media file to the library.
|
|
815
|
-
|
|
816
|
-
**Parameters:**
|
|
817
|
-
- `data`: File data as `ArrayBuffer` or `Uint8Array`
|
|
818
|
-
- `options`: Upload options object:
|
|
819
|
-
- `thumb?`: Optional thumbnail data (`ArrayBuffer` or `Uint8Array`) - only for encrypted libraries
|
|
820
|
-
- `metadata`: Media metadata (see `MediaForUpdate` interface)
|
|
821
|
-
- `fileMime`: MIME type of the file (e.g., 'image/jpeg')
|
|
822
|
-
- `thumbMime?`: Optional MIME type of thumbnail (default: 'image/jpeg')
|
|
823
|
-
- `progressCallback?`: Optional callback for upload progress `(loaded: number, total: number) => void`
|
|
824
|
-
|
|
825
|
-
**Returns:** Promise resolving to the created `IFile` object
|
|
826
|
-
|
|
827
|
-
**Throws:** Error if encryption key not set for encrypted libraries, or if thumbnail provided for non-encrypted libraries
|
|
828
|
-
|
|
829
|
-
**Example:**
|
|
830
|
-
```typescript
|
|
831
|
-
// Upload to non-encrypted library
|
|
832
|
-
const fileData = await file.arrayBuffer();
|
|
833
|
-
const uploaded = await libraryApi.uploadMedia(fileData, {
|
|
834
|
-
metadata: {
|
|
835
|
-
name: 'photo.jpg',
|
|
836
|
-
description: 'My photo'
|
|
837
|
-
},
|
|
838
|
-
fileMime: 'image/jpeg',
|
|
839
|
-
progressCallback: (loaded, total) => {
|
|
840
|
-
console.log(`Upload: ${(loaded / total * 100).toFixed(1)}%`);
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
// Upload to encrypted library
|
|
845
|
-
if (library.crypt) {
|
|
846
|
-
await libraryApi.setKey('passphrase');
|
|
847
|
-
const fileData = await file.arrayBuffer();
|
|
848
|
-
const thumbData = await thumbnail.arrayBuffer();
|
|
849
|
-
|
|
850
|
-
const uploaded = await libraryApi.uploadMedia(fileData, {
|
|
851
|
-
thumb: thumbData,
|
|
852
|
-
metadata: {
|
|
853
|
-
name: 'photo.jpg'
|
|
854
|
-
},
|
|
855
|
-
fileMime: 'image/jpeg',
|
|
856
|
-
thumbMime: 'image/jpeg'
|
|
857
|
-
});
|
|
858
|
-
// uploaded.iv contains the IV for decryption
|
|
859
|
-
}
|
|
860
|
-
```
|
|
861
|
-
|
|
862
|
-
### `removeMedias(mediaIds: string[]): Promise<void>`
|
|
863
|
-
|
|
864
|
-
Deletes multiple media files.
|
|
865
|
-
|
|
866
|
-
**Parameters:**
|
|
867
|
-
- `mediaIds`: Array of media IDs to delete
|
|
868
|
-
|
|
869
|
-
**Example:**
|
|
870
|
-
```typescript
|
|
871
|
-
await libraryApi.removeMedias(['media-1', 'media-2', 'media-3']);
|
|
872
|
-
```
|
|
873
|
-
|
|
874
|
-
### `mediaTransfer(formData: FormData): Promise<void>`
|
|
875
|
-
|
|
876
|
-
Transfers media using FormData (legacy method).
|
|
877
|
-
|
|
878
|
-
**Parameters:**
|
|
879
|
-
- `formData`: FormData containing transfer information
|
|
880
|
-
|
|
881
|
-
**Example:**
|
|
882
|
-
```typescript
|
|
883
|
-
const formData = new FormData();
|
|
884
|
-
formData.append('ids', JSON.stringify(['media-1', 'media-2']));
|
|
885
|
-
formData.append('toLibrary', 'target-library-id');
|
|
886
|
-
await libraryApi.mediaTransfer(formData);
|
|
887
|
-
```
|
|
888
|
-
|
|
889
|
-
### `mediaTransferMany(medias: string[], deleteOriginal: boolean, toLibraryId: string): Promise<void>`
|
|
890
|
-
|
|
891
|
-
Transfers multiple media files to another library.
|
|
892
|
-
|
|
893
|
-
**Parameters:**
|
|
894
|
-
- `medias`: Array of media IDs to transfer
|
|
895
|
-
- `deleteOriginal`: Whether to delete originals after transfer
|
|
896
|
-
- `toLibraryId`: Target library ID
|
|
897
|
-
|
|
898
|
-
**Example:**
|
|
899
|
-
```typescript
|
|
900
|
-
await libraryApi.mediaTransferMany(
|
|
901
|
-
['media-1', 'media-2'],
|
|
902
|
-
false, // Keep originals
|
|
903
|
-
'target-library-id'
|
|
904
|
-
);
|
|
905
|
-
```
|
|
906
|
-
|
|
907
|
-
### `mediaTransferSingle(mediaId: string, toLibraryId: string, formData: FormData, params?: Map<string, string>): Promise<void>`
|
|
908
|
-
|
|
909
|
-
Transfers a single media file to another library.
|
|
910
|
-
|
|
911
|
-
**Parameters:**
|
|
912
|
-
- `mediaId`: The ID of the media to transfer
|
|
913
|
-
- `toLibraryId`: Target library ID
|
|
914
|
-
- `formData`: FormData with additional transfer data
|
|
915
|
-
- `params`: Optional query parameters
|
|
916
|
-
|
|
917
|
-
**Example:**
|
|
918
|
-
```typescript
|
|
919
|
-
const formData = new FormData();
|
|
920
|
-
formData.append('option', 'value');
|
|
921
|
-
await libraryApi.mediaTransferSingle('media-id', 'target-library-id', formData);
|
|
922
|
-
```
|
|
923
|
-
|
|
924
|
-
### `addTagToMedia(mediaId: string, tagId: string): Promise<void>`
|
|
925
|
-
|
|
926
|
-
Adds a tag to a media file.
|
|
927
|
-
|
|
928
|
-
**Parameters:**
|
|
929
|
-
- `mediaId`: The ID of the media
|
|
930
|
-
- `tagId`: The ID of the tag to add
|
|
931
|
-
|
|
932
|
-
**Example:**
|
|
933
|
-
```typescript
|
|
934
|
-
await libraryApi.addTagToMedia('media-id', 'tag-id');
|
|
935
|
-
```
|
|
936
|
-
|
|
937
|
-
### `removeTagFromMedia(mediaId: string, tagId: string): Promise<void>`
|
|
938
|
-
|
|
939
|
-
Removes a tag from a media file.
|
|
940
|
-
|
|
941
|
-
**Parameters:**
|
|
942
|
-
- `mediaId`: The ID of the media
|
|
943
|
-
- `tagId`: The ID of the tag to remove
|
|
944
|
-
|
|
945
|
-
**Example:**
|
|
946
|
-
```typescript
|
|
947
|
-
await libraryApi.removeTagFromMedia('media-id', 'tag-id');
|
|
948
|
-
```
|
|
949
|
-
|
|
950
|
-
### `mediaUpdate(mediaId: string, update: any): Promise<IFile[]>`
|
|
951
|
-
|
|
952
|
-
Updates a media file's metadata.
|
|
953
|
-
|
|
954
|
-
**Parameters:**
|
|
955
|
-
- `mediaId`: The ID of the media
|
|
956
|
-
- `update`: Update object (see `MediaForUpdate` interface)
|
|
957
|
-
|
|
958
|
-
**Returns:** Promise resolving to an array of updated `IFile` objects
|
|
959
|
-
|
|
960
|
-
**Example:**
|
|
961
|
-
```typescript
|
|
962
|
-
await libraryApi.mediaUpdate('media-id', {
|
|
963
|
-
description: 'New description',
|
|
964
|
-
rating: 5
|
|
965
|
-
});
|
|
966
|
-
```
|
|
967
|
-
|
|
968
|
-
### `mediaUpdateMany(update: any, ids: string[]): Promise<IFile[]>`
|
|
969
|
-
|
|
970
|
-
Updates multiple media files.
|
|
971
|
-
|
|
972
|
-
**Parameters:**
|
|
973
|
-
- `update`: Update object
|
|
974
|
-
- `ids`: Array of media IDs to update
|
|
975
|
-
|
|
976
|
-
**Returns:** Promise resolving to an array of updated `IFile` objects
|
|
977
|
-
|
|
978
|
-
**Example:**
|
|
979
|
-
```typescript
|
|
980
|
-
await libraryApi.mediaUpdateMany(
|
|
981
|
-
{ rating: 5 },
|
|
982
|
-
['media-1', 'media-2', 'media-3']
|
|
983
|
-
);
|
|
984
|
-
```
|
|
985
|
-
|
|
986
|
-
### `mediaUpdateProgress(mediaId: string, progress: number): Promise<{ progress: number }>`
|
|
987
|
-
|
|
988
|
-
Updates the watch progress for a media file.
|
|
989
|
-
|
|
990
|
-
**Parameters:**
|
|
991
|
-
- `mediaId`: The ID of the media
|
|
992
|
-
- `progress`: Progress value (0-100 or time-based)
|
|
993
|
-
|
|
994
|
-
**Returns:** Promise resolving to object with updated progress
|
|
995
|
-
|
|
996
|
-
**Example:**
|
|
997
|
-
```typescript
|
|
998
|
-
await libraryApi.mediaUpdateProgress('media-id', 50);
|
|
999
|
-
```
|
|
1000
|
-
|
|
1001
|
-
### `mediaUpdateChannel(mediaId: string, update: any): Promise<IFile[]>`
|
|
1002
|
-
|
|
1003
|
-
Updates channel information for a media file.
|
|
1004
|
-
|
|
1005
|
-
**Parameters:**
|
|
1006
|
-
- `mediaId`: The ID of the media
|
|
1007
|
-
- `update`: Channel update object
|
|
1008
|
-
|
|
1009
|
-
**Returns:** Promise resolving to an array of updated `IFile` objects
|
|
1010
|
-
|
|
1011
|
-
**Example:**
|
|
1012
|
-
```typescript
|
|
1013
|
-
await libraryApi.mediaUpdateChannel('media-id', { channel: 'new-channel' });
|
|
1014
|
-
```
|
|
1015
|
-
|
|
1016
|
-
### `refreshMedia(mediaId: string): Promise<IFile[]>`
|
|
1017
|
-
|
|
1018
|
-
Refreshes metadata for a media file.
|
|
1019
|
-
|
|
1020
|
-
**Parameters:**
|
|
1021
|
-
- `mediaId`: The ID of the media
|
|
1022
|
-
|
|
1023
|
-
**Returns:** Promise resolving to an array of updated `IFile` objects
|
|
1024
|
-
|
|
1025
|
-
**Example:**
|
|
1026
|
-
```typescript
|
|
1027
|
-
await libraryApi.refreshMedia('media-id');
|
|
1028
|
-
```
|
|
1029
|
-
|
|
1030
|
-
### `aiTagMedia(mediaId: string): Promise<IFile[]>`
|
|
1031
|
-
|
|
1032
|
-
Triggers AI tagging for a media file.
|
|
1033
|
-
|
|
1034
|
-
**Parameters:**
|
|
1035
|
-
- `mediaId`: The ID of the media
|
|
1036
|
-
|
|
1037
|
-
**Returns:** Promise resolving to an array of updated `IFile` objects with new tags
|
|
1038
|
-
|
|
1039
|
-
**Example:**
|
|
1040
|
-
```typescript
|
|
1041
|
-
await libraryApi.aiTagMedia('media-id');
|
|
1042
|
-
```
|
|
1043
|
-
|
|
1044
|
-
### `splitZip(mediaId: string, from: number, to: number): Promise<IFile>`
|
|
1045
|
-
|
|
1046
|
-
Splits a ZIP archive into a new archive containing pages from `from` to `to`.
|
|
1047
|
-
|
|
1048
|
-
**Parameters:**
|
|
1049
|
-
- `mediaId`: The ID of the ZIP media
|
|
1050
|
-
- `from`: Starting page number
|
|
1051
|
-
- `to`: Ending page number
|
|
1052
|
-
|
|
1053
|
-
**Returns:** Promise resolving to the new `IFile` object
|
|
1054
|
-
|
|
1055
|
-
**Example:**
|
|
1056
|
-
```typescript
|
|
1057
|
-
const newZip = await libraryApi.splitZip('zip-id', 1, 10);
|
|
1058
|
-
```
|
|
1059
|
-
|
|
1060
|
-
### `deleteFromZip(mediaId: string, pages: number[]): Promise<IFile>`
|
|
1061
|
-
|
|
1062
|
-
Deletes pages from a ZIP archive.
|
|
1063
|
-
|
|
1064
|
-
**Parameters:**
|
|
1065
|
-
- `mediaId`: The ID of the ZIP media
|
|
1066
|
-
- `pages`: Array of page numbers to delete
|
|
1067
|
-
|
|
1068
|
-
**Returns:** Promise resolving to the updated `IFile` object
|
|
1069
|
-
|
|
1070
|
-
**Example:**
|
|
1071
|
-
```typescript
|
|
1072
|
-
await libraryApi.deleteFromZip('zip-id', [5, 6, 7]);
|
|
1073
|
-
```
|
|
1074
|
-
|
|
1075
|
-
### `updateMediaThumb(mediaId: string, thumb: FormData): Promise<void>`
|
|
1076
|
-
|
|
1077
|
-
Updates the thumbnail for a media file.
|
|
1078
|
-
|
|
1079
|
-
**Parameters:**
|
|
1080
|
-
- `mediaId`: The ID of the media
|
|
1081
|
-
- `thumb`: FormData containing the thumbnail image
|
|
1082
|
-
|
|
1083
|
-
**Example:**
|
|
1084
|
-
```typescript
|
|
1085
|
-
const formData = new FormData();
|
|
1086
|
-
formData.append('file', thumbBlob);
|
|
1087
|
-
await libraryApi.updateMediaThumb('media-id', formData);
|
|
1088
|
-
```
|
|
1089
|
-
|
|
1090
|
-
### `getMediaShares(mediaId: string): Promise<any>`
|
|
1091
|
-
|
|
1092
|
-
Gets sharing information for a media file.
|
|
1093
|
-
|
|
1094
|
-
**Parameters:**
|
|
1095
|
-
- `mediaId`: The ID of the media
|
|
1096
|
-
|
|
1097
|
-
**Returns:** Promise resolving to sharing information
|
|
1098
|
-
|
|
1099
|
-
**Example:**
|
|
1100
|
-
```typescript
|
|
1101
|
-
const shares = await libraryApi.getMediaShares('media-id');
|
|
1102
|
-
```
|
|
1103
|
-
|
|
1104
|
-
### `shareMediaToProvider(mediaId: string, provider: string, formData?: FormData): Promise<any>`
|
|
1105
|
-
|
|
1106
|
-
Shares a media file to an external provider.
|
|
1107
|
-
|
|
1108
|
-
**Parameters:**
|
|
1109
|
-
- `mediaId`: The ID of the media
|
|
1110
|
-
- `provider`: Provider name (e.g., 'instagram', 'twitter')
|
|
1111
|
-
- `formData`: Optional FormData with additional sharing data
|
|
1112
|
-
|
|
1113
|
-
**Returns:** Promise resolving to sharing result
|
|
1114
|
-
|
|
1115
|
-
**Example:**
|
|
1116
|
-
```typescript
|
|
1117
|
-
const result = await libraryApi.shareMediaToProvider('media-id', 'instagram');
|
|
1118
|
-
```
|
|
1119
|
-
|
|
1120
|
-
---
|
|
1121
|
-
|
|
1122
|
-
## Faces
|
|
1123
|
-
|
|
1124
|
-
### `getUnassignedFaces(params?: Map<string, string>): Promise<any>`
|
|
1125
|
-
|
|
1126
|
-
Gets unassigned faces (faces not yet linked to a person).
|
|
1127
|
-
|
|
1128
|
-
**Parameters:**
|
|
1129
|
-
- `params`: Optional query parameters
|
|
1130
|
-
|
|
1131
|
-
**Returns:** Promise resolving to unassigned faces data
|
|
1132
|
-
|
|
1133
|
-
**Example:**
|
|
1134
|
-
```typescript
|
|
1135
|
-
const params = new Map([['limit', '50']]);
|
|
1136
|
-
const faces = await libraryApi.getUnassignedFaces(params);
|
|
1137
|
-
```
|
|
1138
|
-
|
|
1139
|
-
### `getClusters(): Promise<any>`
|
|
1140
|
-
|
|
1141
|
-
Gets face clusters (groups of similar faces).
|
|
1142
|
-
|
|
1143
|
-
**Returns:** Promise resolving to clusters data
|
|
1144
|
-
|
|
1145
|
-
**Example:**
|
|
1146
|
-
```typescript
|
|
1147
|
-
const clusters = await libraryApi.getClusters();
|
|
1148
|
-
```
|
|
1149
|
-
|
|
1150
|
-
### `assignFaces(request: any): Promise<any>`
|
|
1151
|
-
|
|
1152
|
-
Assigns faces to a person.
|
|
1153
|
-
|
|
1154
|
-
**Parameters:**
|
|
1155
|
-
- `request`: Assignment request object with face IDs and person ID
|
|
1156
|
-
|
|
1157
|
-
**Returns:** Promise resolving to assignment result
|
|
1158
|
-
|
|
1159
|
-
**Example:**
|
|
1160
|
-
```typescript
|
|
1161
|
-
await libraryApi.assignFaces({
|
|
1162
|
-
faceIds: ['face-1', 'face-2'],
|
|
1163
|
-
personId: 'person-id'
|
|
1164
|
-
});
|
|
1165
|
-
```
|
|
1166
|
-
|
|
1167
|
-
### `createPersonFromCluster(request: any): Promise<any>`
|
|
1168
|
-
|
|
1169
|
-
Creates a new person from a face cluster.
|
|
1170
|
-
|
|
1171
|
-
**Parameters:**
|
|
1172
|
-
- `request`: Request object with cluster ID and person name
|
|
1173
|
-
|
|
1174
|
-
**Returns:** Promise resolving to created person
|
|
1175
|
-
|
|
1176
|
-
**Example:**
|
|
1177
|
-
```typescript
|
|
1178
|
-
await libraryApi.createPersonFromCluster({
|
|
1179
|
-
clusterId: 'cluster-id',
|
|
1180
|
-
name: 'John Doe'
|
|
1181
|
-
});
|
|
1182
|
-
```
|
|
1183
|
-
|
|
1184
|
-
### `splitCluster(request: any): Promise<any>`
|
|
1185
|
-
|
|
1186
|
-
Splits a face cluster into multiple clusters.
|
|
1187
|
-
|
|
1188
|
-
**Parameters:**
|
|
1189
|
-
- `request`: Split request object
|
|
1190
|
-
|
|
1191
|
-
**Returns:** Promise resolving to split result
|
|
1192
|
-
|
|
1193
|
-
**Example:**
|
|
1194
|
-
```typescript
|
|
1195
|
-
await libraryApi.splitCluster({
|
|
1196
|
-
clusterId: 'cluster-id',
|
|
1197
|
-
faceIds: ['face-1', 'face-2']
|
|
1198
|
-
});
|
|
1199
|
-
```
|
|
1200
|
-
|
|
1201
|
-
### `unassignFace(request: any): Promise<any>`
|
|
1202
|
-
|
|
1203
|
-
Unassigns a face from a person.
|
|
1204
|
-
|
|
1205
|
-
**Parameters:**
|
|
1206
|
-
- `request`: Unassign request object with face ID
|
|
1207
|
-
|
|
1208
|
-
**Returns:** Promise resolving to unassign result
|
|
1209
|
-
|
|
1210
|
-
**Example:**
|
|
1211
|
-
```typescript
|
|
1212
|
-
await libraryApi.unassignFace({ faceId: 'face-id' });
|
|
1213
|
-
```
|
|
1214
|
-
|
|
1215
|
-
### `deleteFace(faceId: string): Promise<any>`
|
|
1216
|
-
|
|
1217
|
-
Deletes a face.
|
|
1218
|
-
|
|
1219
|
-
**Parameters:**
|
|
1220
|
-
- `faceId`: The ID of the face to delete
|
|
1221
|
-
|
|
1222
|
-
**Returns:** Promise resolving to deletion result
|
|
1223
|
-
|
|
1224
|
-
**Example:**
|
|
1225
|
-
```typescript
|
|
1226
|
-
await libraryApi.deleteFace('face-id');
|
|
1227
|
-
```
|
|
1228
|
-
|
|
1229
|
-
### `getAssignedFaces(personId: string): Promise<any>`
|
|
1230
|
-
|
|
1231
|
-
Gets all faces assigned to a person.
|
|
1232
|
-
|
|
1233
|
-
**Parameters:**
|
|
1234
|
-
- `personId`: The ID of the person
|
|
1235
|
-
|
|
1236
|
-
**Returns:** Promise resolving to assigned faces
|
|
1237
|
-
|
|
1238
|
-
**Example:**
|
|
1239
|
-
```typescript
|
|
1240
|
-
const faces = await libraryApi.getAssignedFaces('person-id');
|
|
1241
|
-
```
|
|
1242
|
-
|
|
1243
|
-
### `faceClusterPerson(personId: string): Promise<void>`
|
|
1244
|
-
|
|
1245
|
-
Triggers face clustering for a person.
|
|
1246
|
-
|
|
1247
|
-
**Parameters:**
|
|
1248
|
-
- `personId`: The ID of the person
|
|
1249
|
-
|
|
1250
|
-
**Example:**
|
|
1251
|
-
```typescript
|
|
1252
|
-
await libraryApi.faceClusterPerson('person-id');
|
|
1253
|
-
```
|
|
1254
|
-
|
|
1255
|
-
### `mergePeople(request: any): Promise<any>`
|
|
1256
|
-
|
|
1257
|
-
Merges multiple people into one.
|
|
1258
|
-
|
|
1259
|
-
**Parameters:**
|
|
1260
|
-
- `request`: Merge request object with source and target person IDs
|
|
1261
|
-
|
|
1262
|
-
**Returns:** Promise resolving to merge result
|
|
1263
|
-
|
|
1264
|
-
**Example:**
|
|
1265
|
-
```typescript
|
|
1266
|
-
await libraryApi.mergePeople({
|
|
1267
|
-
fromIds: ['person-1', 'person-2'],
|
|
1268
|
-
intoId: 'person-3'
|
|
1269
|
-
});
|
|
1270
|
-
```
|
|
1271
|
-
|
|
1272
|
-
### `clusterFaces(personId: string): Promise<any>`
|
|
1273
|
-
|
|
1274
|
-
Clusters faces for a person.
|
|
1275
|
-
|
|
1276
|
-
**Parameters:**
|
|
1277
|
-
- `personId`: The ID of the person
|
|
1278
|
-
|
|
1279
|
-
**Returns:** Promise resolving to clustering result
|
|
1280
|
-
|
|
1281
|
-
**Example:**
|
|
1282
|
-
```typescript
|
|
1283
|
-
await libraryApi.clusterFaces('person-id');
|
|
1284
|
-
```
|
|
1285
|
-
|
|
1286
|
-
---
|
|
1287
|
-
|
|
1288
|
-
## Encryption
|
|
1289
|
-
|
|
1290
|
-
These methods are convenience wrappers around the encryption module. For detailed encryption documentation, see [encryption.md](encryption.md).
|
|
1291
|
-
|
|
1292
|
-
### `encryptText(passPhrase: string, text: string): Promise<string>`
|
|
1293
|
-
|
|
1294
|
-
Encrypts a text string using a passphrase.
|
|
1295
|
-
|
|
1296
|
-
**Parameters:**
|
|
1297
|
-
- `passPhrase`: The passphrase to derive the key from
|
|
1298
|
-
- `text`: The plaintext to encrypt
|
|
1299
|
-
|
|
1300
|
-
**Returns:** Promise resolving to encrypted string in format `${IV}.${encryptedData}` (base64url encoded)
|
|
1301
|
-
|
|
1302
|
-
**Example:**
|
|
1303
|
-
```typescript
|
|
1304
|
-
const encrypted = await libraryApi.encryptText('password', 'Hello World');
|
|
1305
|
-
```
|
|
1306
|
-
|
|
1307
|
-
### `decryptText(passPhrase: string, encryptedText: string): Promise<string>`
|
|
1308
|
-
|
|
1309
|
-
Decrypts a text string using a passphrase.
|
|
1310
|
-
|
|
1311
|
-
**Parameters:**
|
|
1312
|
-
- `passPhrase`: The passphrase to derive the key from
|
|
1313
|
-
- `encryptedText`: The encrypted text in format `${IV}.${encryptedData}`
|
|
1314
|
-
|
|
1315
|
-
**Returns:** Promise resolving to decrypted plaintext
|
|
1316
|
-
|
|
1317
|
-
**Example:**
|
|
1318
|
-
```typescript
|
|
1319
|
-
const decrypted = await libraryApi.decryptText('password', encryptedText);
|
|
1320
|
-
```
|
|
1321
|
-
|
|
1322
|
-
### `encryptMedia(passPhrase: string, buffer: ArrayBuffer | Uint8Array, iv?: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>`
|
|
1323
|
-
|
|
1324
|
-
Encrypts binary media data using a passphrase.
|
|
1325
|
-
|
|
1326
|
-
**Parameters:**
|
|
1327
|
-
- `passPhrase`: The passphrase to derive the key from
|
|
1328
|
-
- `buffer`: The binary data to encrypt
|
|
1329
|
-
- `iv`: Optional IV (if not provided, a random one is generated)
|
|
1330
|
-
|
|
1331
|
-
**Returns:** Promise resolving to encrypted ArrayBuffer
|
|
1332
|
-
|
|
1333
|
-
**Example:**
|
|
1334
|
-
```typescript
|
|
1335
|
-
const encrypted = await libraryApi.encryptMedia('password', fileBuffer);
|
|
1336
|
-
```
|
|
1337
|
-
|
|
1338
|
-
### `decryptMedia(passPhrase: string, buffer: ArrayBuffer | Uint8Array, iv: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>`
|
|
1339
|
-
|
|
1340
|
-
Decrypts binary media data using a passphrase.
|
|
1341
|
-
|
|
1342
|
-
**Parameters:**
|
|
1343
|
-
- `passPhrase`: The passphrase to derive the key from
|
|
1344
|
-
- `buffer`: The encrypted binary data
|
|
1345
|
-
- `iv`: The IV used during encryption
|
|
1346
|
-
|
|
1347
|
-
**Returns:** Promise resolving to decrypted ArrayBuffer
|
|
1348
|
-
|
|
1349
|
-
**Example:**
|
|
1350
|
-
```typescript
|
|
1351
|
-
const decrypted = await libraryApi.decryptMedia('password', encryptedBuffer, iv);
|
|
1352
|
-
```
|
|
1353
|
-
|
|
1354
|
-
### `encryptFile(passPhrase: string, options: EncryptFileOptions): Promise<EncryptedFile>`
|
|
1355
|
-
|
|
1356
|
-
Encrypts a complete file with thumbnail and metadata.
|
|
1357
|
-
|
|
1358
|
-
**Parameters:**
|
|
1359
|
-
- `passPhrase`: The passphrase to derive the key from
|
|
1360
|
-
- `options`: Encryption options (see `EncryptFileOptions` interface)
|
|
1361
|
-
|
|
1362
|
-
**Returns:** Promise resolving to `EncryptedFile` object
|
|
1363
|
-
|
|
1364
|
-
**Example:**
|
|
1365
|
-
```typescript
|
|
1366
|
-
const encrypted = await libraryApi.encryptFile('password', {
|
|
1367
|
-
filename: 'photo.jpg',
|
|
1368
|
-
buffer: fileBuffer,
|
|
1369
|
-
thumb: thumbBuffer,
|
|
1370
|
-
thumbMime: 'image/jpeg',
|
|
1371
|
-
mime: 'image/jpeg'
|
|
1372
|
-
});
|
|
1373
|
-
```
|
|
1374
|
-
|
|
1375
|
-
### `decryptFile(passPhrase: string, buffer: ArrayBuffer): Promise<ArrayBuffer>`
|
|
1376
|
-
|
|
1377
|
-
Decrypts file data from an encrypted file structure.
|
|
1378
|
-
|
|
1379
|
-
**Parameters:**
|
|
1380
|
-
- `passPhrase`: The passphrase to derive the key from
|
|
1381
|
-
- `buffer`: The complete encrypted file structure
|
|
1382
|
-
|
|
1383
|
-
**Returns:** Promise resolving to decrypted file ArrayBuffer
|
|
1384
|
-
|
|
1385
|
-
**Example:**
|
|
1386
|
-
```typescript
|
|
1387
|
-
const decrypted = await libraryApi.decryptFile('password', encryptedFileBlob);
|
|
1388
|
-
```
|
|
1389
|
-
|
|
1390
|
-
### `decryptMediaThumb(passPhrase: string, buffer: ArrayBuffer): Promise<ArrayBuffer>`
|
|
1391
|
-
|
|
1392
|
-
Decrypts thumbnail from an encrypted file structure.
|
|
1393
|
-
|
|
1394
|
-
**Parameters:**
|
|
1395
|
-
- `passPhrase`: The passphrase to derive the key from
|
|
1396
|
-
- `buffer`: The complete encrypted file structure
|
|
1397
|
-
|
|
1398
|
-
**Returns:** Promise resolving to decrypted thumbnail ArrayBuffer
|
|
1399
|
-
|
|
1400
|
-
**Example:**
|
|
1401
|
-
```typescript
|
|
1402
|
-
const decryptedThumb = await libraryApi.decryptMediaThumb('password', encryptedFileBlob);
|
|
1403
|
-
```
|
|
1404
|
-
|
|
1405
|
-
### `encryptFilename(passPhrase: string, filename: string, iv: ArrayBuffer | Uint8Array): Promise<string>`
|
|
1406
|
-
|
|
1407
|
-
Encrypts a filename using a passphrase and IV.
|
|
1408
|
-
|
|
1409
|
-
**Parameters:**
|
|
1410
|
-
- `passPhrase`: The passphrase to derive the key from
|
|
1411
|
-
- `filename`: The filename to encrypt
|
|
1412
|
-
- `iv`: The IV to use (should match the file's IV)
|
|
1413
|
-
|
|
1414
|
-
**Returns:** Promise resolving to base64url encoded encrypted filename
|
|
1415
|
-
|
|
1416
|
-
**Example:**
|
|
1417
|
-
```typescript
|
|
1418
|
-
const iv = libraryApi.getRandomIV();
|
|
1419
|
-
const encryptedFilename = await libraryApi.encryptFilename('password', 'photo.jpg', iv);
|
|
1420
|
-
```
|
|
1421
|
-
|
|
1422
|
-
### `getRandomIV(): Uint8Array`
|
|
1423
|
-
|
|
1424
|
-
Generates a random 16-byte IV (Initialization Vector).
|
|
1425
|
-
|
|
1426
|
-
**Returns:** `Uint8Array` of 16 random bytes
|
|
1427
|
-
|
|
1428
|
-
**Example:**
|
|
1429
|
-
```typescript
|
|
1430
|
-
const iv = libraryApi.getRandomIV();
|
|
1431
|
-
```
|
|
1432
|
-
|
|
1433
|
-
---
|
|
1434
|
-
|
|
1435
|
-
## Utilities
|
|
1436
|
-
|
|
1437
|
-
### `getCryptChallenge(): Promise<string>`
|
|
1438
|
-
|
|
1439
|
-
Gets a cryptographic challenge for encryption verification.
|
|
1440
|
-
|
|
1441
|
-
**Returns:** Promise resolving to challenge string
|
|
1442
|
-
|
|
1443
|
-
**Example:**
|
|
1444
|
-
```typescript
|
|
1445
|
-
const challenge = await libraryApi.getCryptChallenge();
|
|
1446
|
-
```
|
|
1447
|
-
|
|
1448
|
-
### `getChannels(): Promise<any[]>`
|
|
1449
|
-
|
|
1450
|
-
Gets all channels (for IPTV libraries).
|
|
1451
|
-
|
|
1452
|
-
**Returns:** Promise resolving to an array of channel objects
|
|
1453
|
-
|
|
1454
|
-
**Example:**
|
|
1455
|
-
```typescript
|
|
1456
|
-
const channels = await libraryApi.getChannels();
|
|
1457
|
-
```
|
|
1458
|
-
|
|
1459
|
-
### `getWatermarks(): Promise<string[]>`
|
|
1460
|
-
|
|
1461
|
-
Gets list of available watermark names.
|
|
1462
|
-
|
|
1463
|
-
**Returns:** Promise resolving to an array of watermark names
|
|
1464
|
-
|
|
1465
|
-
**Example:**
|
|
1466
|
-
```typescript
|
|
1467
|
-
const watermarks = await libraryApi.getWatermarks();
|
|
1468
|
-
```
|
|
1469
|
-
|
|
1470
|
-
### `getWatermark(watermark: string, options?: { type?: 'blob' | 'arraybuffer' }): Promise<Blob | ArrayBuffer>`
|
|
1471
|
-
|
|
1472
|
-
Gets a watermark image.
|
|
1473
|
-
|
|
1474
|
-
**Parameters:**
|
|
1475
|
-
- `watermark`: Watermark name (or 'default')
|
|
1476
|
-
- `options`: Optional object with `type` property
|
|
1477
|
-
|
|
1478
|
-
**Returns:** Promise resolving to watermark data
|
|
1479
|
-
|
|
1480
|
-
**Example:**
|
|
1481
|
-
```typescript
|
|
1482
|
-
const watermark = await libraryApi.getWatermark('default', { type: 'blob' });
|
|
1483
|
-
```
|
|
1484
|
-
|
|
1485
|
-
### `expandUrl(parsedUrl: any): Promise<string | undefined>`
|
|
1486
|
-
|
|
1487
|
-
Expands a parsed URL using plugins.
|
|
1488
|
-
|
|
1489
|
-
**Parameters:**
|
|
1490
|
-
- `parsedUrl`: Parsed URL object
|
|
1491
|
-
|
|
1492
|
-
**Returns:** Promise resolving to expanded URL or undefined
|
|
1493
|
-
|
|
1494
|
-
**Example:**
|
|
1495
|
-
```typescript
|
|
1496
|
-
const expanded = await libraryApi.expandUrl(parsedUrl);
|
|
1497
|
-
```
|
|
1498
|
-
|
|
1499
|
-
### `parseUrl(url: string): Promise<any>`
|
|
1500
|
-
|
|
1501
|
-
Parses a URL using plugins.
|
|
1502
|
-
|
|
1503
|
-
**Parameters:**
|
|
1504
|
-
- `url`: URL string to parse
|
|
1505
|
-
|
|
1506
|
-
**Returns:** Promise resolving to parsed URL object
|
|
1507
|
-
|
|
1508
|
-
**Example:**
|
|
1509
|
-
```typescript
|
|
1510
|
-
const parsed = await libraryApi.parseUrl('https://example.com/video');
|
|
1511
|
-
```
|
|
1512
|
-
|
|
1513
|
-
### `listVideoConvertPlugins(): Promise<any[]>`
|
|
1514
|
-
|
|
1515
|
-
Lists available video conversion plugins.
|
|
1516
|
-
|
|
1517
|
-
**Returns:** Promise resolving to an array of plugin objects
|
|
1518
|
-
|
|
1519
|
-
**Example:**
|
|
1520
|
-
```typescript
|
|
1521
|
-
const plugins = await libraryApi.listVideoConvertPlugins();
|
|
1522
|
-
```
|
|
1523
|
-
|
|
1524
|
-
### `clean(): Promise<string>`
|
|
1525
|
-
|
|
1526
|
-
Triggers library cleanup operation.
|
|
1527
|
-
|
|
1528
|
-
**Returns:** Promise resolving to cleanup result message
|
|
1529
|
-
|
|
1530
|
-
**Example:**
|
|
1531
|
-
```typescript
|
|
1532
|
-
const result = await libraryApi.clean();
|
|
1533
|
-
```
|
|
1534
|
-
|
|
1535
|
-
### `locs(): Promise<any>`
|
|
1536
|
-
|
|
1537
|
-
Gets location data.
|
|
1538
|
-
|
|
1539
|
-
**Returns:** Promise resolving to location data
|
|
1540
|
-
|
|
1541
|
-
**Example:**
|
|
1542
|
-
```typescript
|
|
1543
|
-
const locations = await libraryApi.locs();
|
|
1544
|
-
```
|
|
1545
|
-
|
|
1546
|
-
### `mergeMedias(request: any): Promise<IFile>`
|
|
1547
|
-
|
|
1548
|
-
Merges multiple media files into one.
|
|
1549
|
-
|
|
1550
|
-
**Parameters:**
|
|
1551
|
-
- `request`: Merge request object with media IDs
|
|
1552
|
-
|
|
1553
|
-
**Returns:** Promise resolving to merged `IFile` object
|
|
1554
|
-
|
|
1555
|
-
**Example:**
|
|
1556
|
-
```typescript
|
|
1557
|
-
const merged = await libraryApi.mergeMedias({
|
|
1558
|
-
ids: ['media-1', 'media-2']
|
|
1559
|
-
});
|
|
1560
|
-
```
|
|
1561
|
-
|
|
1562
|
-
---
|
|
1563
|
-
|
|
1564
|
-
## Common Workflows
|
|
1565
|
-
|
|
1566
|
-
### Uploading Media to Encrypted Library
|
|
1567
|
-
|
|
1568
|
-
```typescript
|
|
1569
|
-
// 1. Set encryption key
|
|
1570
|
-
await libraryApi.setKey('my-password');
|
|
1571
|
-
|
|
1572
|
-
// 2. Prepare file and thumbnail
|
|
1573
|
-
const fileData = await file.arrayBuffer();
|
|
1574
|
-
const thumbData = await thumbnail.arrayBuffer();
|
|
1575
|
-
|
|
1576
|
-
// 3. Upload with progress tracking
|
|
1577
|
-
const uploaded = await libraryApi.uploadMedia(fileData, {
|
|
1578
|
-
thumb: thumbData,
|
|
1579
|
-
metadata: {
|
|
1580
|
-
name: 'photo.jpg',
|
|
1581
|
-
description: 'My encrypted photo'
|
|
1582
|
-
},
|
|
1583
|
-
fileMime: 'image/jpeg',
|
|
1584
|
-
thumbMime: 'image/jpeg',
|
|
1585
|
-
progressCallback: (loaded, total) => {
|
|
1586
|
-
console.log(`Upload: ${(loaded / total * 100).toFixed(1)}%`);
|
|
1587
|
-
}
|
|
1588
|
-
});
|
|
1589
|
-
|
|
1590
|
-
console.log(`Uploaded with IV: ${uploaded.iv}`);
|
|
1591
|
-
```
|
|
1592
|
-
|
|
1593
|
-
### Downloading and Decrypting Media
|
|
1594
|
-
|
|
1595
|
-
```typescript
|
|
1596
|
-
// 1. Set encryption key
|
|
1597
|
-
await libraryApi.setKey('my-password');
|
|
1598
|
-
|
|
1599
|
-
// 2. Get media metadata
|
|
1600
|
-
const metadata = await libraryApi.getMediaMetadata('media-id');
|
|
1601
|
-
|
|
1602
|
-
// 3. Download encrypted file
|
|
1603
|
-
const encryptedBlob = await libraryApi.getMedia('media-id', { type: 'arraybuffer' });
|
|
1604
|
-
|
|
1605
|
-
// 4. Decrypt file
|
|
1606
|
-
const decrypted = await libraryApi.decryptFile('my-password', encryptedBlob);
|
|
1607
|
-
|
|
1608
|
-
// 5. Use decrypted data
|
|
1609
|
-
const blob = new Blob([decrypted], { type: metadata.mimetype });
|
|
1610
|
-
const url = URL.createObjectURL(blob);
|
|
1611
|
-
```
|
|
1612
|
-
|
|
1613
|
-
### Tagging Media
|
|
1614
|
-
|
|
1615
|
-
```typescript
|
|
1616
|
-
// 1. Get or create tags
|
|
1617
|
-
const tags = await libraryApi.getTags();
|
|
1618
|
-
let vacationTag = tags.find(t => t.name === 'Vacation');
|
|
1619
|
-
if (!vacationTag) {
|
|
1620
|
-
vacationTag = await libraryApi.createTag({ name: 'Vacation' });
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
// 2. Add tag to media
|
|
1624
|
-
await libraryApi.addTagToMedia('media-id', vacationTag.id!);
|
|
1625
|
-
```
|
|
1626
|
-
|
|
1627
|
-
### Managing People and Faces
|
|
1628
|
-
|
|
1629
|
-
```typescript
|
|
1630
|
-
// 1. Create person
|
|
1631
|
-
const person = await libraryApi.createPerson({ name: 'John Doe' });
|
|
1632
|
-
|
|
1633
|
-
// 2. Get unassigned faces
|
|
1634
|
-
const faces = await libraryApi.getUnassignedFaces();
|
|
1635
|
-
|
|
1636
|
-
// 3. Assign faces to person
|
|
1637
|
-
await libraryApi.assignFaces({
|
|
1638
|
-
faceIds: ['face-1', 'face-2'],
|
|
1639
|
-
personId: person.id!
|
|
1640
|
-
});
|
|
1641
|
-
|
|
1642
|
-
// 4. Cluster faces for better organization
|
|
1643
|
-
await libraryApi.faceClusterPerson(person.id!);
|
|
1644
|
-
```
|
|
1645
|
-
|
|
1646
|
-
## Related Documentation
|
|
1647
|
-
|
|
1648
|
-
- [RedseatClient Documentation](client.md) - HTTP client used by LibraryApi
|
|
1649
|
-
- [ServerApi Documentation](server.md) - Server-level operations
|
|
1650
|
-
- [Encryption Documentation](encryption.md) - Detailed encryption module documentation
|
|
1651
|
-
- [README](README.md) - Package overview
|
|
1652
|
-
|
|
1
|
+
# LibraryApi
|
|
2
|
+
|
|
3
|
+
The `LibraryApi` class provides comprehensive operations for managing media, tags, people, series, movies, and more within a specific library.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`LibraryApi` handles all library-specific operations including:
|
|
8
|
+
- Media management (upload, download, update, delete)
|
|
9
|
+
- Tags, people, series, and movies
|
|
10
|
+
- Face recognition and clustering
|
|
11
|
+
- Encryption support for encrypted libraries
|
|
12
|
+
- Plugin integration
|
|
13
|
+
|
|
14
|
+
## Constructor
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
new LibraryApi(client: RedseatClient, libraryId: string, library: ILibrary)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Parameters:**
|
|
21
|
+
- `client`: An initialized `RedseatClient` instance
|
|
22
|
+
- `libraryId`: The ID of the library
|
|
23
|
+
- `library`: The `ILibrary` object with library configuration
|
|
24
|
+
|
|
25
|
+
**Example:**
|
|
26
|
+
```typescript
|
|
27
|
+
import { RedseatClient, LibraryApi, ServerApi } from '@redseat/api';
|
|
28
|
+
|
|
29
|
+
const client = new RedseatClient({ /* ... */ });
|
|
30
|
+
const serverApi = new ServerApi(client);
|
|
31
|
+
const libraries = await serverApi.getLibraries();
|
|
32
|
+
const library = libraries[0];
|
|
33
|
+
|
|
34
|
+
const libraryApi = new LibraryApi(client, library.id!, library);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Initialization
|
|
38
|
+
|
|
39
|
+
### `setKey(passPhrase: string): Promise<void>`
|
|
40
|
+
|
|
41
|
+
Sets the encryption key for encrypted libraries. Must be called before any operations on encrypted libraries.
|
|
42
|
+
|
|
43
|
+
**Parameters:**
|
|
44
|
+
- `passPhrase`: The passphrase to derive encryption keys from
|
|
45
|
+
|
|
46
|
+
**Throws:** Error if the passphrase is incorrect (for encrypted libraries)
|
|
47
|
+
|
|
48
|
+
**Example:**
|
|
49
|
+
```typescript
|
|
50
|
+
if (library.crypt) {
|
|
51
|
+
try {
|
|
52
|
+
await libraryApi.setKey('my-secure-password');
|
|
53
|
+
console.log('Encryption key set successfully');
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('Invalid encryption key:', error.message);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Note:** This method verifies the key by attempting to decrypt a media thumbnail. If decryption fails, it throws an error.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Tags
|
|
65
|
+
|
|
66
|
+
### `getTags(): Promise<ITag[]>`
|
|
67
|
+
|
|
68
|
+
Retrieves all tags in the library.
|
|
69
|
+
|
|
70
|
+
**Returns:** Promise resolving to an array of `ITag` objects
|
|
71
|
+
|
|
72
|
+
**Example:**
|
|
73
|
+
```typescript
|
|
74
|
+
const tags = await libraryApi.getTags();
|
|
75
|
+
tags.forEach(tag => console.log(tag.name));
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `createTag(tag: Partial<ITag>): Promise<ITag>`
|
|
79
|
+
|
|
80
|
+
Creates a new tag.
|
|
81
|
+
|
|
82
|
+
**Parameters:**
|
|
83
|
+
- `tag`: Partial tag object with at least `name` property
|
|
84
|
+
|
|
85
|
+
**Returns:** Promise resolving to the created `ITag` object
|
|
86
|
+
|
|
87
|
+
**Example:**
|
|
88
|
+
```typescript
|
|
89
|
+
const newTag = await libraryApi.createTag({ name: 'Vacation' });
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### `removeTag(tagId: string): Promise<void>`
|
|
93
|
+
|
|
94
|
+
Deletes a tag.
|
|
95
|
+
|
|
96
|
+
**Parameters:**
|
|
97
|
+
- `tagId`: The ID of the tag to remove
|
|
98
|
+
|
|
99
|
+
**Example:**
|
|
100
|
+
```typescript
|
|
101
|
+
await libraryApi.removeTag('tag-id-123');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### `renameTag(tagId: string, newName: string): Promise<ITag>`
|
|
105
|
+
|
|
106
|
+
Renames a tag.
|
|
107
|
+
|
|
108
|
+
**Parameters:**
|
|
109
|
+
- `tagId`: The ID of the tag
|
|
110
|
+
- `newName`: The new name for the tag
|
|
111
|
+
|
|
112
|
+
**Returns:** Promise resolving to the updated `ITag` object
|
|
113
|
+
|
|
114
|
+
**Example:**
|
|
115
|
+
```typescript
|
|
116
|
+
const updated = await libraryApi.renameTag('tag-id', 'New Tag Name');
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `tagChangeParent(tagId: string, newParent?: string): Promise<ITag>`
|
|
120
|
+
|
|
121
|
+
Changes the parent tag (for tag hierarchy).
|
|
122
|
+
|
|
123
|
+
**Parameters:**
|
|
124
|
+
- `tagId`: The ID of the tag
|
|
125
|
+
- `newParent`: Optional parent tag ID (undefined to remove parent)
|
|
126
|
+
|
|
127
|
+
**Returns:** Promise resolving to the updated `ITag` object
|
|
128
|
+
|
|
129
|
+
**Example:**
|
|
130
|
+
```typescript
|
|
131
|
+
// Set parent
|
|
132
|
+
await libraryApi.tagChangeParent('child-tag-id', 'parent-tag-id');
|
|
133
|
+
|
|
134
|
+
// Remove parent
|
|
135
|
+
await libraryApi.tagChangeParent('tag-id', undefined);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### `tagMerge(fromId: string, intoId: string): Promise<ITag>`
|
|
139
|
+
|
|
140
|
+
Merges one tag into another.
|
|
141
|
+
|
|
142
|
+
**Parameters:**
|
|
143
|
+
- `fromId`: The tag ID to merge from (will be deleted)
|
|
144
|
+
- `intoId`: The tag ID to merge into
|
|
145
|
+
|
|
146
|
+
**Returns:** Promise resolving to the merged `ITag` object
|
|
147
|
+
|
|
148
|
+
**Example:**
|
|
149
|
+
```typescript
|
|
150
|
+
await libraryApi.tagMerge('old-tag-id', 'new-tag-id');
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `tagAddAlt(tagId: string, alt: string): Promise<ITag>`
|
|
154
|
+
|
|
155
|
+
Adds an alternative name to a tag.
|
|
156
|
+
|
|
157
|
+
**Parameters:**
|
|
158
|
+
- `tagId`: The ID of the tag
|
|
159
|
+
- `alt`: Alternative name to add
|
|
160
|
+
|
|
161
|
+
**Returns:** Promise resolving to the updated `ITag` object
|
|
162
|
+
|
|
163
|
+
**Example:**
|
|
164
|
+
```typescript
|
|
165
|
+
await libraryApi.tagAddAlt('tag-id', 'alternative-name');
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### `tagRemoveAlt(tagId: string, alt: string): Promise<ITag>`
|
|
169
|
+
|
|
170
|
+
Removes an alternative name from a tag.
|
|
171
|
+
|
|
172
|
+
**Parameters:**
|
|
173
|
+
- `tagId`: The ID of the tag
|
|
174
|
+
- `alt`: Alternative name to remove
|
|
175
|
+
|
|
176
|
+
**Returns:** Promise resolving to the updated `ITag` object
|
|
177
|
+
|
|
178
|
+
**Example:**
|
|
179
|
+
```typescript
|
|
180
|
+
await libraryApi.tagRemoveAlt('tag-id', 'alternative-name');
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## People
|
|
186
|
+
|
|
187
|
+
### `getPeople(): Promise<IPerson[]>`
|
|
188
|
+
|
|
189
|
+
Retrieves all people in the library.
|
|
190
|
+
|
|
191
|
+
**Returns:** Promise resolving to an array of `IPerson` objects
|
|
192
|
+
|
|
193
|
+
**Example:**
|
|
194
|
+
```typescript
|
|
195
|
+
const people = await libraryApi.getPeople();
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### `createPerson(person: Partial<IPerson>): Promise<IPerson>`
|
|
199
|
+
|
|
200
|
+
Creates a new person.
|
|
201
|
+
|
|
202
|
+
**Parameters:**
|
|
203
|
+
- `person`: Partial person object with at least `name` property
|
|
204
|
+
|
|
205
|
+
**Returns:** Promise resolving to the created `IPerson` object
|
|
206
|
+
|
|
207
|
+
**Example:**
|
|
208
|
+
```typescript
|
|
209
|
+
const person = await libraryApi.createPerson({ name: 'John Doe' });
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### `removePerson(personId: string): Promise<void>`
|
|
213
|
+
|
|
214
|
+
Deletes a person.
|
|
215
|
+
|
|
216
|
+
**Parameters:**
|
|
217
|
+
- `personId`: The ID of the person to remove
|
|
218
|
+
|
|
219
|
+
**Example:**
|
|
220
|
+
```typescript
|
|
221
|
+
await libraryApi.removePerson('person-id');
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### `updatePerson(personId: string, updates: Partial<IPerson>): Promise<IPerson>`
|
|
225
|
+
|
|
226
|
+
Updates a person's information.
|
|
227
|
+
|
|
228
|
+
**Parameters:**
|
|
229
|
+
- `personId`: The ID of the person
|
|
230
|
+
- `updates`: Partial person object with fields to update
|
|
231
|
+
|
|
232
|
+
**Returns:** Promise resolving to the updated `IPerson` object
|
|
233
|
+
|
|
234
|
+
**Example:**
|
|
235
|
+
```typescript
|
|
236
|
+
await libraryApi.updatePerson('person-id', { birthday: 1234567890 });
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### `personRename(personId: string, newName: string): Promise<IPerson>`
|
|
240
|
+
|
|
241
|
+
Renames a person.
|
|
242
|
+
|
|
243
|
+
**Parameters:**
|
|
244
|
+
- `personId`: The ID of the person
|
|
245
|
+
- `newName`: The new name
|
|
246
|
+
|
|
247
|
+
**Returns:** Promise resolving to the updated `IPerson` object
|
|
248
|
+
|
|
249
|
+
**Example:**
|
|
250
|
+
```typescript
|
|
251
|
+
await libraryApi.personRename('person-id', 'Jane Doe');
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### `personAddAlt(personId: string, alt: string): Promise<IPerson>`
|
|
255
|
+
|
|
256
|
+
Adds an alternative name to a person.
|
|
257
|
+
|
|
258
|
+
**Parameters:**
|
|
259
|
+
- `personId`: The ID of the person
|
|
260
|
+
- `alt`: Alternative name to add
|
|
261
|
+
|
|
262
|
+
**Returns:** Promise resolving to the updated `IPerson` object
|
|
263
|
+
|
|
264
|
+
**Example:**
|
|
265
|
+
```typescript
|
|
266
|
+
await libraryApi.personAddAlt('person-id', 'nickname');
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### `personRemoveAlt(personId: string, alt: string): Promise<IPerson>`
|
|
270
|
+
|
|
271
|
+
Removes an alternative name from a person.
|
|
272
|
+
|
|
273
|
+
**Parameters:**
|
|
274
|
+
- `personId`: The ID of the person
|
|
275
|
+
- `alt`: Alternative name to remove
|
|
276
|
+
|
|
277
|
+
**Returns:** Promise resolving to the updated `IPerson` object
|
|
278
|
+
|
|
279
|
+
**Example:**
|
|
280
|
+
```typescript
|
|
281
|
+
await libraryApi.personRemoveAlt('person-id', 'nickname');
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### `personAddSocial(personId: string, social: any): Promise<IPerson>`
|
|
285
|
+
|
|
286
|
+
Adds a social media link to a person.
|
|
287
|
+
|
|
288
|
+
**Parameters:**
|
|
289
|
+
- `personId`: The ID of the person
|
|
290
|
+
- `social`: Social media object with `id`, `type`, and `platform`
|
|
291
|
+
|
|
292
|
+
**Returns:** Promise resolving to the updated `IPerson` object
|
|
293
|
+
|
|
294
|
+
**Example:**
|
|
295
|
+
```typescript
|
|
296
|
+
await libraryApi.personAddSocial('person-id', {
|
|
297
|
+
id: 'username',
|
|
298
|
+
type: 'profile',
|
|
299
|
+
platform: 'instagram'
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### `personRemoveSocial(personId: string, social: any): Promise<IPerson>`
|
|
304
|
+
|
|
305
|
+
Removes a social media link from a person.
|
|
306
|
+
|
|
307
|
+
**Parameters:**
|
|
308
|
+
- `personId`: The ID of the person
|
|
309
|
+
- `social`: Social media object to remove
|
|
310
|
+
|
|
311
|
+
**Returns:** Promise resolving to the updated `IPerson` object
|
|
312
|
+
|
|
313
|
+
**Example:**
|
|
314
|
+
```typescript
|
|
315
|
+
await libraryApi.personRemoveSocial('person-id', socialObject);
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### `updatePersonPortrait(personId: string, portrait: FormData): Promise<void>`
|
|
319
|
+
|
|
320
|
+
Updates a person's portrait image.
|
|
321
|
+
|
|
322
|
+
**Parameters:**
|
|
323
|
+
- `personId`: The ID of the person
|
|
324
|
+
- `portrait`: FormData containing the portrait image
|
|
325
|
+
|
|
326
|
+
**Example:**
|
|
327
|
+
```typescript
|
|
328
|
+
const formData = new FormData();
|
|
329
|
+
formData.append('file', imageBlob);
|
|
330
|
+
await libraryApi.updatePersonPortrait('person-id', formData);
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Series
|
|
336
|
+
|
|
337
|
+
### `getSeries(): Promise<ISerie[]>`
|
|
338
|
+
|
|
339
|
+
Retrieves all series in the library, sorted by name.
|
|
340
|
+
|
|
341
|
+
**Returns:** Promise resolving to an array of `ISerie` objects
|
|
342
|
+
|
|
343
|
+
**Example:**
|
|
344
|
+
```typescript
|
|
345
|
+
const series = await libraryApi.getSeries();
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### `createSerie(serie: Partial<ISerie>): Promise<ISerie>`
|
|
349
|
+
|
|
350
|
+
Creates a new series.
|
|
351
|
+
|
|
352
|
+
**Parameters:**
|
|
353
|
+
- `serie`: Partial series object
|
|
354
|
+
|
|
355
|
+
**Returns:** Promise resolving to the created `ISerie` object
|
|
356
|
+
|
|
357
|
+
**Example:**
|
|
358
|
+
```typescript
|
|
359
|
+
const serie = await libraryApi.createSerie({ name: 'Breaking Bad' });
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### `createEpisode(episode: Partial<IEpisode>): Promise<IEpisode>`
|
|
363
|
+
|
|
364
|
+
Creates a new episode.
|
|
365
|
+
|
|
366
|
+
**Parameters:**
|
|
367
|
+
- `episode`: Partial episode object
|
|
368
|
+
|
|
369
|
+
**Returns:** Promise resolving to the created `IEpisode` object
|
|
370
|
+
|
|
371
|
+
**Example:**
|
|
372
|
+
```typescript
|
|
373
|
+
const episode = await libraryApi.createEpisode({
|
|
374
|
+
serie: 'serie-id',
|
|
375
|
+
season: 1,
|
|
376
|
+
number: 1,
|
|
377
|
+
name: 'Pilot'
|
|
378
|
+
});
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### `serieScrap(serieId: string, date?: number): Promise<void>`
|
|
382
|
+
|
|
383
|
+
Triggers metadata scraping for a series.
|
|
384
|
+
|
|
385
|
+
**Parameters:**
|
|
386
|
+
- `serieId`: The ID of the series
|
|
387
|
+
- `date`: Optional date parameter
|
|
388
|
+
|
|
389
|
+
**Example:**
|
|
390
|
+
```typescript
|
|
391
|
+
await libraryApi.serieScrap('serie-id');
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### `removeSerie(serieId: string): Promise<void>`
|
|
395
|
+
|
|
396
|
+
Deletes a series.
|
|
397
|
+
|
|
398
|
+
**Parameters:**
|
|
399
|
+
- `serieId`: The ID of the series to remove
|
|
400
|
+
|
|
401
|
+
**Example:**
|
|
402
|
+
```typescript
|
|
403
|
+
await libraryApi.removeSerie('serie-id');
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### `updateSerie(serieId: string, updates: Partial<ISerie>): Promise<ISerie>`
|
|
407
|
+
|
|
408
|
+
Updates a series.
|
|
409
|
+
|
|
410
|
+
**Parameters:**
|
|
411
|
+
- `serieId`: The ID of the series
|
|
412
|
+
- `updates`: Partial series object with fields to update
|
|
413
|
+
|
|
414
|
+
**Returns:** Promise resolving to the updated `ISerie` object
|
|
415
|
+
|
|
416
|
+
**Example:**
|
|
417
|
+
```typescript
|
|
418
|
+
await libraryApi.updateSerie('serie-id', { description: 'New description' });
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### `getSerieImages(serieId: string): Promise<ExternalImage[]>`
|
|
422
|
+
|
|
423
|
+
Gets available images for a series from external sources.
|
|
424
|
+
|
|
425
|
+
**Parameters:**
|
|
426
|
+
- `serieId`: The ID of the series
|
|
427
|
+
|
|
428
|
+
**Returns:** Promise resolving to an array of `ExternalImage` objects
|
|
429
|
+
|
|
430
|
+
**Example:**
|
|
431
|
+
```typescript
|
|
432
|
+
const images = await libraryApi.getSerieImages('serie-id');
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### `updateSeriePoster(serieId: string, poster: FormData, type: string): Promise<void>`
|
|
436
|
+
|
|
437
|
+
Updates a series poster image.
|
|
438
|
+
|
|
439
|
+
**Parameters:**
|
|
440
|
+
- `serieId`: The ID of the series
|
|
441
|
+
- `poster`: FormData containing the poster image
|
|
442
|
+
- `type`: Poster type (e.g., 'poster', 'backdrop')
|
|
443
|
+
|
|
444
|
+
**Example:**
|
|
445
|
+
```typescript
|
|
446
|
+
const formData = new FormData();
|
|
447
|
+
formData.append('file', posterBlob);
|
|
448
|
+
await libraryApi.updateSeriePoster('serie-id', formData, 'poster');
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### `updateSeriePosterWithMediaThumb(serieId: string, mediaId: string, type: string): Promise<ISerie>`
|
|
452
|
+
|
|
453
|
+
Sets a series poster using a media thumbnail.
|
|
454
|
+
|
|
455
|
+
**Parameters:**
|
|
456
|
+
- `serieId`: The ID of the series
|
|
457
|
+
- `mediaId`: The ID of the media to use as poster
|
|
458
|
+
- `type`: Poster type
|
|
459
|
+
|
|
460
|
+
**Returns:** Promise resolving to the updated `ISerie` object
|
|
461
|
+
|
|
462
|
+
**Example:**
|
|
463
|
+
```typescript
|
|
464
|
+
await libraryApi.updateSeriePosterWithMediaThumb('serie-id', 'media-id', 'poster');
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### `updateSerieImageFetch(serieId: string, image: ExternalImage): Promise<void>`
|
|
468
|
+
|
|
469
|
+
Fetches and sets an external image as series poster.
|
|
470
|
+
|
|
471
|
+
**Parameters:**
|
|
472
|
+
- `serieId`: The ID of the series
|
|
473
|
+
- `image`: External image object to fetch
|
|
474
|
+
|
|
475
|
+
**Example:**
|
|
476
|
+
```typescript
|
|
477
|
+
await libraryApi.updateSerieImageFetch('serie-id', externalImage);
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### `serieRename(serieId: string, newName: string): Promise<ISerie>`
|
|
481
|
+
|
|
482
|
+
Renames a series.
|
|
483
|
+
|
|
484
|
+
**Parameters:**
|
|
485
|
+
- `serieId`: The ID of the series
|
|
486
|
+
- `newName`: The new name
|
|
487
|
+
|
|
488
|
+
**Returns:** Promise resolving to the updated `ISerie` object
|
|
489
|
+
|
|
490
|
+
**Example:**
|
|
491
|
+
```typescript
|
|
492
|
+
await libraryApi.serieRename('serie-id', 'New Series Name');
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### `serieAddAlt(serieId: string, alt: string): Promise<ISerie>`
|
|
496
|
+
|
|
497
|
+
Adds an alternative name to a series.
|
|
498
|
+
|
|
499
|
+
**Parameters:**
|
|
500
|
+
- `serieId`: The ID of the series
|
|
501
|
+
- `alt`: Alternative name to add
|
|
502
|
+
|
|
503
|
+
**Returns:** Promise resolving to the updated `ISerie` object
|
|
504
|
+
|
|
505
|
+
**Example:**
|
|
506
|
+
```typescript
|
|
507
|
+
await libraryApi.serieAddAlt('serie-id', 'alternative-name');
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### `serieRemoveAlt(serieId: string, alt: string): Promise<ISerie>`
|
|
511
|
+
|
|
512
|
+
Removes an alternative name from a series.
|
|
513
|
+
|
|
514
|
+
**Parameters:**
|
|
515
|
+
- `serieId`: The ID of the series
|
|
516
|
+
- `alt`: Alternative name to remove
|
|
517
|
+
|
|
518
|
+
**Returns:** Promise resolving to the updated `ISerie` object
|
|
519
|
+
|
|
520
|
+
**Example:**
|
|
521
|
+
```typescript
|
|
522
|
+
await libraryApi.serieRemoveAlt('serie-id', 'alternative-name');
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
### `searchSeries(name: string): Promise<ISerie[]>`
|
|
526
|
+
|
|
527
|
+
Searches for series by name.
|
|
528
|
+
|
|
529
|
+
**Parameters:**
|
|
530
|
+
- `name`: Search query
|
|
531
|
+
|
|
532
|
+
**Returns:** Promise resolving to an array of matching `ISerie` objects
|
|
533
|
+
|
|
534
|
+
**Example:**
|
|
535
|
+
```typescript
|
|
536
|
+
const results = await libraryApi.searchSeries('Breaking');
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### `setEpisodeWatched(serieId: string, season: number, number: number, date: number): Promise<void>`
|
|
540
|
+
|
|
541
|
+
Marks an episode as watched.
|
|
542
|
+
|
|
543
|
+
**Parameters:**
|
|
544
|
+
- `serieId`: The ID of the series
|
|
545
|
+
- `season`: Season number
|
|
546
|
+
- `number`: Episode number
|
|
547
|
+
- `date`: Timestamp of when it was watched
|
|
548
|
+
|
|
549
|
+
**Example:**
|
|
550
|
+
```typescript
|
|
551
|
+
await libraryApi.setEpisodeWatched('serie-id', 1, 1, Date.now());
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|
|
556
|
+
## Movies
|
|
557
|
+
|
|
558
|
+
### `getMovies(): Promise<IMovie[]>`
|
|
559
|
+
|
|
560
|
+
Retrieves all movies in the library.
|
|
561
|
+
|
|
562
|
+
**Returns:** Promise resolving to an array of `IMovie` objects
|
|
563
|
+
|
|
564
|
+
**Example:**
|
|
565
|
+
```typescript
|
|
566
|
+
const movies = await libraryApi.getMovies();
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
### `createMovie(movie: Partial<IMovie>): Promise<IMovie>`
|
|
570
|
+
|
|
571
|
+
Creates a new movie.
|
|
572
|
+
|
|
573
|
+
**Parameters:**
|
|
574
|
+
- `movie`: Partial movie object
|
|
575
|
+
|
|
576
|
+
**Returns:** Promise resolving to the created `IMovie` object
|
|
577
|
+
|
|
578
|
+
**Example:**
|
|
579
|
+
```typescript
|
|
580
|
+
const movie = await libraryApi.createMovie({ name: 'The Matrix' });
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### `movieScrap(movieId: string, date?: number): Promise<void>`
|
|
584
|
+
|
|
585
|
+
Triggers metadata scraping for a movie.
|
|
586
|
+
|
|
587
|
+
**Parameters:**
|
|
588
|
+
- `movieId`: The ID of the movie
|
|
589
|
+
- `date`: Optional date parameter
|
|
590
|
+
|
|
591
|
+
**Example:**
|
|
592
|
+
```typescript
|
|
593
|
+
await libraryApi.movieScrap('movie-id');
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
### `removeMovie(movieId: string): Promise<void>`
|
|
597
|
+
|
|
598
|
+
Deletes a movie.
|
|
599
|
+
|
|
600
|
+
**Parameters:**
|
|
601
|
+
- `movieId`: The ID of the movie to remove
|
|
602
|
+
|
|
603
|
+
**Example:**
|
|
604
|
+
```typescript
|
|
605
|
+
await libraryApi.removeMovie('movie-id');
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
### `updateMovie(movieId: string, updates: Partial<IMovie>): Promise<IMovie>`
|
|
609
|
+
|
|
610
|
+
Updates a movie.
|
|
611
|
+
|
|
612
|
+
**Parameters:**
|
|
613
|
+
- `movieId`: The ID of the movie
|
|
614
|
+
- `updates`: Partial movie object with fields to update
|
|
615
|
+
|
|
616
|
+
**Returns:** Promise resolving to the updated `IMovie` object
|
|
617
|
+
|
|
618
|
+
**Example:**
|
|
619
|
+
```typescript
|
|
620
|
+
await libraryApi.updateMovie('movie-id', { description: 'New description' });
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
### `getMovieImages(movieId: string): Promise<ExternalImage[]>`
|
|
624
|
+
|
|
625
|
+
Gets available images for a movie from external sources.
|
|
626
|
+
|
|
627
|
+
**Parameters:**
|
|
628
|
+
- `movieId`: The ID of the movie
|
|
629
|
+
|
|
630
|
+
**Returns:** Promise resolving to an array of `ExternalImage` objects
|
|
631
|
+
|
|
632
|
+
**Example:**
|
|
633
|
+
```typescript
|
|
634
|
+
const images = await libraryApi.getMovieImages('movie-id');
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### `setMovieWatched(movieId: string, date: number): Promise<void>`
|
|
638
|
+
|
|
639
|
+
Marks a movie as watched.
|
|
640
|
+
|
|
641
|
+
**Parameters:**
|
|
642
|
+
- `movieId`: The ID of the movie
|
|
643
|
+
- `date`: Timestamp of when it was watched
|
|
644
|
+
|
|
645
|
+
**Example:**
|
|
646
|
+
```typescript
|
|
647
|
+
await libraryApi.setMovieWatched('movie-id', Date.now());
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
### `searchMovies(name: string): Promise<IMovie[]>`
|
|
651
|
+
|
|
652
|
+
Searches for movies by name.
|
|
653
|
+
|
|
654
|
+
**Parameters:**
|
|
655
|
+
- `name`: Search query
|
|
656
|
+
|
|
657
|
+
**Returns:** Promise resolving to an array of matching `IMovie` objects
|
|
658
|
+
|
|
659
|
+
**Example:**
|
|
660
|
+
```typescript
|
|
661
|
+
const results = await libraryApi.searchMovies('Matrix');
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
### `movieRename(movieId: string, newName: string): Promise<IMovie>`
|
|
665
|
+
|
|
666
|
+
Renames a movie.
|
|
667
|
+
|
|
668
|
+
**Parameters:**
|
|
669
|
+
- `movieId`: The ID of the movie
|
|
670
|
+
- `newName`: The new name
|
|
671
|
+
|
|
672
|
+
**Returns:** Promise resolving to the updated `IMovie` object
|
|
673
|
+
|
|
674
|
+
**Example:**
|
|
675
|
+
```typescript
|
|
676
|
+
await libraryApi.movieRename('movie-id', 'New Movie Name');
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
### `updateMoviePoster(movieId: string, poster: FormData, type: string): Promise<void>`
|
|
680
|
+
|
|
681
|
+
Updates a movie poster image.
|
|
682
|
+
|
|
683
|
+
**Parameters:**
|
|
684
|
+
- `movieId`: The ID of the movie
|
|
685
|
+
- `poster`: FormData containing the poster image
|
|
686
|
+
- `type`: Poster type
|
|
687
|
+
|
|
688
|
+
**Example:**
|
|
689
|
+
```typescript
|
|
690
|
+
const formData = new FormData();
|
|
691
|
+
formData.append('file', posterBlob);
|
|
692
|
+
await libraryApi.updateMoviePoster('movie-id', formData, 'poster');
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
### `updateMovieImageFetch(movieId: string, image: ExternalImage): Promise<void>`
|
|
696
|
+
|
|
697
|
+
Fetches and sets an external image as movie poster.
|
|
698
|
+
|
|
699
|
+
**Parameters:**
|
|
700
|
+
- `movieId`: The ID of the movie
|
|
701
|
+
- `image`: External image object to fetch
|
|
702
|
+
|
|
703
|
+
**Example:**
|
|
704
|
+
```typescript
|
|
705
|
+
await libraryApi.updateMovieImageFetch('movie-id', externalImage);
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
---
|
|
709
|
+
|
|
710
|
+
## Media
|
|
711
|
+
|
|
712
|
+
### `getMedias(filter?: MediaRequest): Promise<IFile[]>`
|
|
713
|
+
|
|
714
|
+
Retrieves media files with optional filtering.
|
|
715
|
+
|
|
716
|
+
**Parameters:**
|
|
717
|
+
- `filter`: Optional `MediaRequest` object for filtering/sorting
|
|
718
|
+
|
|
719
|
+
**Returns:** Promise resolving to an array of `IFile` objects
|
|
720
|
+
|
|
721
|
+
**Example:**
|
|
722
|
+
```typescript
|
|
723
|
+
// Get all media
|
|
724
|
+
const allMedias = await libraryApi.getMedias();
|
|
725
|
+
|
|
726
|
+
// Get filtered media
|
|
727
|
+
const photos = await libraryApi.getMedias({
|
|
728
|
+
type: 'photo',
|
|
729
|
+
limit: 50,
|
|
730
|
+
offset: 0
|
|
731
|
+
});
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
### `getMedia(mediaId: string, options?: { type?: 'stream' | 'arraybuffer' | 'blob' }): Promise<ReadableStream | ArrayBuffer | Blob>`
|
|
735
|
+
|
|
736
|
+
Downloads a media file.
|
|
737
|
+
|
|
738
|
+
**Parameters:**
|
|
739
|
+
- `mediaId`: The ID of the media
|
|
740
|
+
- `options`: Optional object with `type` property ('stream', 'arraybuffer', or 'blob')
|
|
741
|
+
|
|
742
|
+
**Returns:** Promise resolving to the media data in the requested format
|
|
743
|
+
|
|
744
|
+
**Example:**
|
|
745
|
+
```typescript
|
|
746
|
+
// Get as blob
|
|
747
|
+
const blob = await libraryApi.getMedia('media-id', { type: 'blob' });
|
|
748
|
+
|
|
749
|
+
// Get as stream
|
|
750
|
+
const stream = await libraryApi.getMedia('media-id', { type: 'stream' });
|
|
751
|
+
|
|
752
|
+
// For encrypted libraries, decrypt after getting
|
|
753
|
+
if (library.crypt) {
|
|
754
|
+
const encryptedBlob = await libraryApi.getMedia('media-id', { type: 'arraybuffer' });
|
|
755
|
+
const decrypted = await libraryApi.decryptFile('passphrase', encryptedBlob);
|
|
756
|
+
}
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
### `getThumb(mediaId: string, options?: { type?: 'stream' | 'arraybuffer' | 'blob' }): Promise<ReadableStream | ArrayBuffer | Blob>`
|
|
760
|
+
|
|
761
|
+
Gets a media thumbnail.
|
|
762
|
+
|
|
763
|
+
**Parameters:**
|
|
764
|
+
- `mediaId`: The ID of the media
|
|
765
|
+
- `options`: Optional object with `type` property
|
|
766
|
+
|
|
767
|
+
**Returns:** Promise resolving to the thumbnail data
|
|
768
|
+
|
|
769
|
+
**Example:**
|
|
770
|
+
```typescript
|
|
771
|
+
// Get thumbnail as blob
|
|
772
|
+
const thumbBlob = await libraryApi.getThumb('media-id', { type: 'blob' });
|
|
773
|
+
|
|
774
|
+
// For encrypted libraries, decrypt thumbnail
|
|
775
|
+
if (library.crypt) {
|
|
776
|
+
const media = await libraryApi.getMediaMetadata('media-id');
|
|
777
|
+
const iv = uint8ArrayFromBase64(media.iv!);
|
|
778
|
+
const encryptedThumb = await libraryApi.getThumb('media-id', { type: 'arraybuffer' });
|
|
779
|
+
const decryptedThumb = await libraryApi.decryptMedia('passphrase', encryptedThumb, iv);
|
|
780
|
+
}
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
### `getMediaMetadata(mediaId: string): Promise<IFile>`
|
|
784
|
+
|
|
785
|
+
Gets metadata for a media file.
|
|
786
|
+
|
|
787
|
+
**Parameters:**
|
|
788
|
+
- `mediaId`: The ID of the media
|
|
789
|
+
|
|
790
|
+
**Returns:** Promise resolving to `IFile` object with metadata
|
|
791
|
+
|
|
792
|
+
**Example:**
|
|
793
|
+
```typescript
|
|
794
|
+
const metadata = await libraryApi.getMediaMetadata('media-id');
|
|
795
|
+
console.log(`File: ${metadata.name}, Size: ${metadata.size}`);
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
### `getMediaBackupMetadatas(mediaId: string): Promise<IBackupFile[]>`
|
|
799
|
+
|
|
800
|
+
Gets backup metadata for a media file.
|
|
801
|
+
|
|
802
|
+
**Parameters:**
|
|
803
|
+
- `mediaId`: The ID of the media
|
|
804
|
+
|
|
805
|
+
**Returns:** Promise resolving to an array of `IBackupFile` objects
|
|
806
|
+
|
|
807
|
+
**Example:**
|
|
808
|
+
```typescript
|
|
809
|
+
const backups = await libraryApi.getMediaBackupMetadatas('media-id');
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
### `uploadMedia(data: ArrayBuffer | Uint8Array, options: UploadMediaOptions): Promise<IFile>`
|
|
813
|
+
|
|
814
|
+
Uploads a media file to the library.
|
|
815
|
+
|
|
816
|
+
**Parameters:**
|
|
817
|
+
- `data`: File data as `ArrayBuffer` or `Uint8Array`
|
|
818
|
+
- `options`: Upload options object:
|
|
819
|
+
- `thumb?`: Optional thumbnail data (`ArrayBuffer` or `Uint8Array`) - only for encrypted libraries
|
|
820
|
+
- `metadata`: Media metadata (see `MediaForUpdate` interface)
|
|
821
|
+
- `fileMime`: MIME type of the file (e.g., 'image/jpeg')
|
|
822
|
+
- `thumbMime?`: Optional MIME type of thumbnail (default: 'image/jpeg')
|
|
823
|
+
- `progressCallback?`: Optional callback for upload progress `(loaded: number, total: number) => void`
|
|
824
|
+
|
|
825
|
+
**Returns:** Promise resolving to the created `IFile` object
|
|
826
|
+
|
|
827
|
+
**Throws:** Error if encryption key not set for encrypted libraries, or if thumbnail provided for non-encrypted libraries
|
|
828
|
+
|
|
829
|
+
**Example:**
|
|
830
|
+
```typescript
|
|
831
|
+
// Upload to non-encrypted library
|
|
832
|
+
const fileData = await file.arrayBuffer();
|
|
833
|
+
const uploaded = await libraryApi.uploadMedia(fileData, {
|
|
834
|
+
metadata: {
|
|
835
|
+
name: 'photo.jpg',
|
|
836
|
+
description: 'My photo'
|
|
837
|
+
},
|
|
838
|
+
fileMime: 'image/jpeg',
|
|
839
|
+
progressCallback: (loaded, total) => {
|
|
840
|
+
console.log(`Upload: ${(loaded / total * 100).toFixed(1)}%`);
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
// Upload to encrypted library
|
|
845
|
+
if (library.crypt) {
|
|
846
|
+
await libraryApi.setKey('passphrase');
|
|
847
|
+
const fileData = await file.arrayBuffer();
|
|
848
|
+
const thumbData = await thumbnail.arrayBuffer();
|
|
849
|
+
|
|
850
|
+
const uploaded = await libraryApi.uploadMedia(fileData, {
|
|
851
|
+
thumb: thumbData,
|
|
852
|
+
metadata: {
|
|
853
|
+
name: 'photo.jpg'
|
|
854
|
+
},
|
|
855
|
+
fileMime: 'image/jpeg',
|
|
856
|
+
thumbMime: 'image/jpeg'
|
|
857
|
+
});
|
|
858
|
+
// uploaded.iv contains the IV for decryption
|
|
859
|
+
}
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
### `removeMedias(mediaIds: string[]): Promise<void>`
|
|
863
|
+
|
|
864
|
+
Deletes multiple media files.
|
|
865
|
+
|
|
866
|
+
**Parameters:**
|
|
867
|
+
- `mediaIds`: Array of media IDs to delete
|
|
868
|
+
|
|
869
|
+
**Example:**
|
|
870
|
+
```typescript
|
|
871
|
+
await libraryApi.removeMedias(['media-1', 'media-2', 'media-3']);
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
### `mediaTransfer(formData: FormData): Promise<void>`
|
|
875
|
+
|
|
876
|
+
Transfers media using FormData (legacy method).
|
|
877
|
+
|
|
878
|
+
**Parameters:**
|
|
879
|
+
- `formData`: FormData containing transfer information
|
|
880
|
+
|
|
881
|
+
**Example:**
|
|
882
|
+
```typescript
|
|
883
|
+
const formData = new FormData();
|
|
884
|
+
formData.append('ids', JSON.stringify(['media-1', 'media-2']));
|
|
885
|
+
formData.append('toLibrary', 'target-library-id');
|
|
886
|
+
await libraryApi.mediaTransfer(formData);
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
### `mediaTransferMany(medias: string[], deleteOriginal: boolean, toLibraryId: string): Promise<void>`
|
|
890
|
+
|
|
891
|
+
Transfers multiple media files to another library.
|
|
892
|
+
|
|
893
|
+
**Parameters:**
|
|
894
|
+
- `medias`: Array of media IDs to transfer
|
|
895
|
+
- `deleteOriginal`: Whether to delete originals after transfer
|
|
896
|
+
- `toLibraryId`: Target library ID
|
|
897
|
+
|
|
898
|
+
**Example:**
|
|
899
|
+
```typescript
|
|
900
|
+
await libraryApi.mediaTransferMany(
|
|
901
|
+
['media-1', 'media-2'],
|
|
902
|
+
false, // Keep originals
|
|
903
|
+
'target-library-id'
|
|
904
|
+
);
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
### `mediaTransferSingle(mediaId: string, toLibraryId: string, formData: FormData, params?: Map<string, string>): Promise<void>`
|
|
908
|
+
|
|
909
|
+
Transfers a single media file to another library.
|
|
910
|
+
|
|
911
|
+
**Parameters:**
|
|
912
|
+
- `mediaId`: The ID of the media to transfer
|
|
913
|
+
- `toLibraryId`: Target library ID
|
|
914
|
+
- `formData`: FormData with additional transfer data
|
|
915
|
+
- `params`: Optional query parameters
|
|
916
|
+
|
|
917
|
+
**Example:**
|
|
918
|
+
```typescript
|
|
919
|
+
const formData = new FormData();
|
|
920
|
+
formData.append('option', 'value');
|
|
921
|
+
await libraryApi.mediaTransferSingle('media-id', 'target-library-id', formData);
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
### `addTagToMedia(mediaId: string, tagId: string): Promise<void>`
|
|
925
|
+
|
|
926
|
+
Adds a tag to a media file.
|
|
927
|
+
|
|
928
|
+
**Parameters:**
|
|
929
|
+
- `mediaId`: The ID of the media
|
|
930
|
+
- `tagId`: The ID of the tag to add
|
|
931
|
+
|
|
932
|
+
**Example:**
|
|
933
|
+
```typescript
|
|
934
|
+
await libraryApi.addTagToMedia('media-id', 'tag-id');
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
### `removeTagFromMedia(mediaId: string, tagId: string): Promise<void>`
|
|
938
|
+
|
|
939
|
+
Removes a tag from a media file.
|
|
940
|
+
|
|
941
|
+
**Parameters:**
|
|
942
|
+
- `mediaId`: The ID of the media
|
|
943
|
+
- `tagId`: The ID of the tag to remove
|
|
944
|
+
|
|
945
|
+
**Example:**
|
|
946
|
+
```typescript
|
|
947
|
+
await libraryApi.removeTagFromMedia('media-id', 'tag-id');
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
### `mediaUpdate(mediaId: string, update: any): Promise<IFile[]>`
|
|
951
|
+
|
|
952
|
+
Updates a media file's metadata.
|
|
953
|
+
|
|
954
|
+
**Parameters:**
|
|
955
|
+
- `mediaId`: The ID of the media
|
|
956
|
+
- `update`: Update object (see `MediaForUpdate` interface)
|
|
957
|
+
|
|
958
|
+
**Returns:** Promise resolving to an array of updated `IFile` objects
|
|
959
|
+
|
|
960
|
+
**Example:**
|
|
961
|
+
```typescript
|
|
962
|
+
await libraryApi.mediaUpdate('media-id', {
|
|
963
|
+
description: 'New description',
|
|
964
|
+
rating: 5
|
|
965
|
+
});
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
### `mediaUpdateMany(update: any, ids: string[]): Promise<IFile[]>`
|
|
969
|
+
|
|
970
|
+
Updates multiple media files.
|
|
971
|
+
|
|
972
|
+
**Parameters:**
|
|
973
|
+
- `update`: Update object
|
|
974
|
+
- `ids`: Array of media IDs to update
|
|
975
|
+
|
|
976
|
+
**Returns:** Promise resolving to an array of updated `IFile` objects
|
|
977
|
+
|
|
978
|
+
**Example:**
|
|
979
|
+
```typescript
|
|
980
|
+
await libraryApi.mediaUpdateMany(
|
|
981
|
+
{ rating: 5 },
|
|
982
|
+
['media-1', 'media-2', 'media-3']
|
|
983
|
+
);
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
### `mediaUpdateProgress(mediaId: string, progress: number): Promise<{ progress: number }>`
|
|
987
|
+
|
|
988
|
+
Updates the watch progress for a media file.
|
|
989
|
+
|
|
990
|
+
**Parameters:**
|
|
991
|
+
- `mediaId`: The ID of the media
|
|
992
|
+
- `progress`: Progress value (0-100 or time-based)
|
|
993
|
+
|
|
994
|
+
**Returns:** Promise resolving to object with updated progress
|
|
995
|
+
|
|
996
|
+
**Example:**
|
|
997
|
+
```typescript
|
|
998
|
+
await libraryApi.mediaUpdateProgress('media-id', 50);
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
### `mediaUpdateChannel(mediaId: string, update: any): Promise<IFile[]>`
|
|
1002
|
+
|
|
1003
|
+
Updates channel information for a media file.
|
|
1004
|
+
|
|
1005
|
+
**Parameters:**
|
|
1006
|
+
- `mediaId`: The ID of the media
|
|
1007
|
+
- `update`: Channel update object
|
|
1008
|
+
|
|
1009
|
+
**Returns:** Promise resolving to an array of updated `IFile` objects
|
|
1010
|
+
|
|
1011
|
+
**Example:**
|
|
1012
|
+
```typescript
|
|
1013
|
+
await libraryApi.mediaUpdateChannel('media-id', { channel: 'new-channel' });
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
### `refreshMedia(mediaId: string): Promise<IFile[]>`
|
|
1017
|
+
|
|
1018
|
+
Refreshes metadata for a media file.
|
|
1019
|
+
|
|
1020
|
+
**Parameters:**
|
|
1021
|
+
- `mediaId`: The ID of the media
|
|
1022
|
+
|
|
1023
|
+
**Returns:** Promise resolving to an array of updated `IFile` objects
|
|
1024
|
+
|
|
1025
|
+
**Example:**
|
|
1026
|
+
```typescript
|
|
1027
|
+
await libraryApi.refreshMedia('media-id');
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
### `aiTagMedia(mediaId: string): Promise<IFile[]>`
|
|
1031
|
+
|
|
1032
|
+
Triggers AI tagging for a media file.
|
|
1033
|
+
|
|
1034
|
+
**Parameters:**
|
|
1035
|
+
- `mediaId`: The ID of the media
|
|
1036
|
+
|
|
1037
|
+
**Returns:** Promise resolving to an array of updated `IFile` objects with new tags
|
|
1038
|
+
|
|
1039
|
+
**Example:**
|
|
1040
|
+
```typescript
|
|
1041
|
+
await libraryApi.aiTagMedia('media-id');
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
### `splitZip(mediaId: string, from: number, to: number): Promise<IFile>`
|
|
1045
|
+
|
|
1046
|
+
Splits a ZIP archive into a new archive containing pages from `from` to `to`.
|
|
1047
|
+
|
|
1048
|
+
**Parameters:**
|
|
1049
|
+
- `mediaId`: The ID of the ZIP media
|
|
1050
|
+
- `from`: Starting page number
|
|
1051
|
+
- `to`: Ending page number
|
|
1052
|
+
|
|
1053
|
+
**Returns:** Promise resolving to the new `IFile` object
|
|
1054
|
+
|
|
1055
|
+
**Example:**
|
|
1056
|
+
```typescript
|
|
1057
|
+
const newZip = await libraryApi.splitZip('zip-id', 1, 10);
|
|
1058
|
+
```
|
|
1059
|
+
|
|
1060
|
+
### `deleteFromZip(mediaId: string, pages: number[]): Promise<IFile>`
|
|
1061
|
+
|
|
1062
|
+
Deletes pages from a ZIP archive.
|
|
1063
|
+
|
|
1064
|
+
**Parameters:**
|
|
1065
|
+
- `mediaId`: The ID of the ZIP media
|
|
1066
|
+
- `pages`: Array of page numbers to delete
|
|
1067
|
+
|
|
1068
|
+
**Returns:** Promise resolving to the updated `IFile` object
|
|
1069
|
+
|
|
1070
|
+
**Example:**
|
|
1071
|
+
```typescript
|
|
1072
|
+
await libraryApi.deleteFromZip('zip-id', [5, 6, 7]);
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
### `updateMediaThumb(mediaId: string, thumb: FormData): Promise<void>`
|
|
1076
|
+
|
|
1077
|
+
Updates the thumbnail for a media file.
|
|
1078
|
+
|
|
1079
|
+
**Parameters:**
|
|
1080
|
+
- `mediaId`: The ID of the media
|
|
1081
|
+
- `thumb`: FormData containing the thumbnail image
|
|
1082
|
+
|
|
1083
|
+
**Example:**
|
|
1084
|
+
```typescript
|
|
1085
|
+
const formData = new FormData();
|
|
1086
|
+
formData.append('file', thumbBlob);
|
|
1087
|
+
await libraryApi.updateMediaThumb('media-id', formData);
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
### `getMediaShares(mediaId: string): Promise<any>`
|
|
1091
|
+
|
|
1092
|
+
Gets sharing information for a media file.
|
|
1093
|
+
|
|
1094
|
+
**Parameters:**
|
|
1095
|
+
- `mediaId`: The ID of the media
|
|
1096
|
+
|
|
1097
|
+
**Returns:** Promise resolving to sharing information
|
|
1098
|
+
|
|
1099
|
+
**Example:**
|
|
1100
|
+
```typescript
|
|
1101
|
+
const shares = await libraryApi.getMediaShares('media-id');
|
|
1102
|
+
```
|
|
1103
|
+
|
|
1104
|
+
### `shareMediaToProvider(mediaId: string, provider: string, formData?: FormData): Promise<any>`
|
|
1105
|
+
|
|
1106
|
+
Shares a media file to an external provider.
|
|
1107
|
+
|
|
1108
|
+
**Parameters:**
|
|
1109
|
+
- `mediaId`: The ID of the media
|
|
1110
|
+
- `provider`: Provider name (e.g., 'instagram', 'twitter')
|
|
1111
|
+
- `formData`: Optional FormData with additional sharing data
|
|
1112
|
+
|
|
1113
|
+
**Returns:** Promise resolving to sharing result
|
|
1114
|
+
|
|
1115
|
+
**Example:**
|
|
1116
|
+
```typescript
|
|
1117
|
+
const result = await libraryApi.shareMediaToProvider('media-id', 'instagram');
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
---
|
|
1121
|
+
|
|
1122
|
+
## Faces
|
|
1123
|
+
|
|
1124
|
+
### `getUnassignedFaces(params?: Map<string, string>): Promise<any>`
|
|
1125
|
+
|
|
1126
|
+
Gets unassigned faces (faces not yet linked to a person).
|
|
1127
|
+
|
|
1128
|
+
**Parameters:**
|
|
1129
|
+
- `params`: Optional query parameters
|
|
1130
|
+
|
|
1131
|
+
**Returns:** Promise resolving to unassigned faces data
|
|
1132
|
+
|
|
1133
|
+
**Example:**
|
|
1134
|
+
```typescript
|
|
1135
|
+
const params = new Map([['limit', '50']]);
|
|
1136
|
+
const faces = await libraryApi.getUnassignedFaces(params);
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
### `getClusters(): Promise<any>`
|
|
1140
|
+
|
|
1141
|
+
Gets face clusters (groups of similar faces).
|
|
1142
|
+
|
|
1143
|
+
**Returns:** Promise resolving to clusters data
|
|
1144
|
+
|
|
1145
|
+
**Example:**
|
|
1146
|
+
```typescript
|
|
1147
|
+
const clusters = await libraryApi.getClusters();
|
|
1148
|
+
```
|
|
1149
|
+
|
|
1150
|
+
### `assignFaces(request: any): Promise<any>`
|
|
1151
|
+
|
|
1152
|
+
Assigns faces to a person.
|
|
1153
|
+
|
|
1154
|
+
**Parameters:**
|
|
1155
|
+
- `request`: Assignment request object with face IDs and person ID
|
|
1156
|
+
|
|
1157
|
+
**Returns:** Promise resolving to assignment result
|
|
1158
|
+
|
|
1159
|
+
**Example:**
|
|
1160
|
+
```typescript
|
|
1161
|
+
await libraryApi.assignFaces({
|
|
1162
|
+
faceIds: ['face-1', 'face-2'],
|
|
1163
|
+
personId: 'person-id'
|
|
1164
|
+
});
|
|
1165
|
+
```
|
|
1166
|
+
|
|
1167
|
+
### `createPersonFromCluster(request: any): Promise<any>`
|
|
1168
|
+
|
|
1169
|
+
Creates a new person from a face cluster.
|
|
1170
|
+
|
|
1171
|
+
**Parameters:**
|
|
1172
|
+
- `request`: Request object with cluster ID and person name
|
|
1173
|
+
|
|
1174
|
+
**Returns:** Promise resolving to created person
|
|
1175
|
+
|
|
1176
|
+
**Example:**
|
|
1177
|
+
```typescript
|
|
1178
|
+
await libraryApi.createPersonFromCluster({
|
|
1179
|
+
clusterId: 'cluster-id',
|
|
1180
|
+
name: 'John Doe'
|
|
1181
|
+
});
|
|
1182
|
+
```
|
|
1183
|
+
|
|
1184
|
+
### `splitCluster(request: any): Promise<any>`
|
|
1185
|
+
|
|
1186
|
+
Splits a face cluster into multiple clusters.
|
|
1187
|
+
|
|
1188
|
+
**Parameters:**
|
|
1189
|
+
- `request`: Split request object
|
|
1190
|
+
|
|
1191
|
+
**Returns:** Promise resolving to split result
|
|
1192
|
+
|
|
1193
|
+
**Example:**
|
|
1194
|
+
```typescript
|
|
1195
|
+
await libraryApi.splitCluster({
|
|
1196
|
+
clusterId: 'cluster-id',
|
|
1197
|
+
faceIds: ['face-1', 'face-2']
|
|
1198
|
+
});
|
|
1199
|
+
```
|
|
1200
|
+
|
|
1201
|
+
### `unassignFace(request: any): Promise<any>`
|
|
1202
|
+
|
|
1203
|
+
Unassigns a face from a person.
|
|
1204
|
+
|
|
1205
|
+
**Parameters:**
|
|
1206
|
+
- `request`: Unassign request object with face ID
|
|
1207
|
+
|
|
1208
|
+
**Returns:** Promise resolving to unassign result
|
|
1209
|
+
|
|
1210
|
+
**Example:**
|
|
1211
|
+
```typescript
|
|
1212
|
+
await libraryApi.unassignFace({ faceId: 'face-id' });
|
|
1213
|
+
```
|
|
1214
|
+
|
|
1215
|
+
### `deleteFace(faceId: string): Promise<any>`
|
|
1216
|
+
|
|
1217
|
+
Deletes a face.
|
|
1218
|
+
|
|
1219
|
+
**Parameters:**
|
|
1220
|
+
- `faceId`: The ID of the face to delete
|
|
1221
|
+
|
|
1222
|
+
**Returns:** Promise resolving to deletion result
|
|
1223
|
+
|
|
1224
|
+
**Example:**
|
|
1225
|
+
```typescript
|
|
1226
|
+
await libraryApi.deleteFace('face-id');
|
|
1227
|
+
```
|
|
1228
|
+
|
|
1229
|
+
### `getAssignedFaces(personId: string): Promise<any>`
|
|
1230
|
+
|
|
1231
|
+
Gets all faces assigned to a person.
|
|
1232
|
+
|
|
1233
|
+
**Parameters:**
|
|
1234
|
+
- `personId`: The ID of the person
|
|
1235
|
+
|
|
1236
|
+
**Returns:** Promise resolving to assigned faces
|
|
1237
|
+
|
|
1238
|
+
**Example:**
|
|
1239
|
+
```typescript
|
|
1240
|
+
const faces = await libraryApi.getAssignedFaces('person-id');
|
|
1241
|
+
```
|
|
1242
|
+
|
|
1243
|
+
### `faceClusterPerson(personId: string): Promise<void>`
|
|
1244
|
+
|
|
1245
|
+
Triggers face clustering for a person.
|
|
1246
|
+
|
|
1247
|
+
**Parameters:**
|
|
1248
|
+
- `personId`: The ID of the person
|
|
1249
|
+
|
|
1250
|
+
**Example:**
|
|
1251
|
+
```typescript
|
|
1252
|
+
await libraryApi.faceClusterPerson('person-id');
|
|
1253
|
+
```
|
|
1254
|
+
|
|
1255
|
+
### `mergePeople(request: any): Promise<any>`
|
|
1256
|
+
|
|
1257
|
+
Merges multiple people into one.
|
|
1258
|
+
|
|
1259
|
+
**Parameters:**
|
|
1260
|
+
- `request`: Merge request object with source and target person IDs
|
|
1261
|
+
|
|
1262
|
+
**Returns:** Promise resolving to merge result
|
|
1263
|
+
|
|
1264
|
+
**Example:**
|
|
1265
|
+
```typescript
|
|
1266
|
+
await libraryApi.mergePeople({
|
|
1267
|
+
fromIds: ['person-1', 'person-2'],
|
|
1268
|
+
intoId: 'person-3'
|
|
1269
|
+
});
|
|
1270
|
+
```
|
|
1271
|
+
|
|
1272
|
+
### `clusterFaces(personId: string): Promise<any>`
|
|
1273
|
+
|
|
1274
|
+
Clusters faces for a person.
|
|
1275
|
+
|
|
1276
|
+
**Parameters:**
|
|
1277
|
+
- `personId`: The ID of the person
|
|
1278
|
+
|
|
1279
|
+
**Returns:** Promise resolving to clustering result
|
|
1280
|
+
|
|
1281
|
+
**Example:**
|
|
1282
|
+
```typescript
|
|
1283
|
+
await libraryApi.clusterFaces('person-id');
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
---
|
|
1287
|
+
|
|
1288
|
+
## Encryption
|
|
1289
|
+
|
|
1290
|
+
These methods are convenience wrappers around the encryption module. For detailed encryption documentation, see [encryption.md](encryption.md).
|
|
1291
|
+
|
|
1292
|
+
### `encryptText(passPhrase: string, text: string): Promise<string>`
|
|
1293
|
+
|
|
1294
|
+
Encrypts a text string using a passphrase.
|
|
1295
|
+
|
|
1296
|
+
**Parameters:**
|
|
1297
|
+
- `passPhrase`: The passphrase to derive the key from
|
|
1298
|
+
- `text`: The plaintext to encrypt
|
|
1299
|
+
|
|
1300
|
+
**Returns:** Promise resolving to encrypted string in format `${IV}.${encryptedData}` (base64url encoded)
|
|
1301
|
+
|
|
1302
|
+
**Example:**
|
|
1303
|
+
```typescript
|
|
1304
|
+
const encrypted = await libraryApi.encryptText('password', 'Hello World');
|
|
1305
|
+
```
|
|
1306
|
+
|
|
1307
|
+
### `decryptText(passPhrase: string, encryptedText: string): Promise<string>`
|
|
1308
|
+
|
|
1309
|
+
Decrypts a text string using a passphrase.
|
|
1310
|
+
|
|
1311
|
+
**Parameters:**
|
|
1312
|
+
- `passPhrase`: The passphrase to derive the key from
|
|
1313
|
+
- `encryptedText`: The encrypted text in format `${IV}.${encryptedData}`
|
|
1314
|
+
|
|
1315
|
+
**Returns:** Promise resolving to decrypted plaintext
|
|
1316
|
+
|
|
1317
|
+
**Example:**
|
|
1318
|
+
```typescript
|
|
1319
|
+
const decrypted = await libraryApi.decryptText('password', encryptedText);
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1322
|
+
### `encryptMedia(passPhrase: string, buffer: ArrayBuffer | Uint8Array, iv?: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>`
|
|
1323
|
+
|
|
1324
|
+
Encrypts binary media data using a passphrase.
|
|
1325
|
+
|
|
1326
|
+
**Parameters:**
|
|
1327
|
+
- `passPhrase`: The passphrase to derive the key from
|
|
1328
|
+
- `buffer`: The binary data to encrypt
|
|
1329
|
+
- `iv`: Optional IV (if not provided, a random one is generated)
|
|
1330
|
+
|
|
1331
|
+
**Returns:** Promise resolving to encrypted ArrayBuffer
|
|
1332
|
+
|
|
1333
|
+
**Example:**
|
|
1334
|
+
```typescript
|
|
1335
|
+
const encrypted = await libraryApi.encryptMedia('password', fileBuffer);
|
|
1336
|
+
```
|
|
1337
|
+
|
|
1338
|
+
### `decryptMedia(passPhrase: string, buffer: ArrayBuffer | Uint8Array, iv: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>`
|
|
1339
|
+
|
|
1340
|
+
Decrypts binary media data using a passphrase.
|
|
1341
|
+
|
|
1342
|
+
**Parameters:**
|
|
1343
|
+
- `passPhrase`: The passphrase to derive the key from
|
|
1344
|
+
- `buffer`: The encrypted binary data
|
|
1345
|
+
- `iv`: The IV used during encryption
|
|
1346
|
+
|
|
1347
|
+
**Returns:** Promise resolving to decrypted ArrayBuffer
|
|
1348
|
+
|
|
1349
|
+
**Example:**
|
|
1350
|
+
```typescript
|
|
1351
|
+
const decrypted = await libraryApi.decryptMedia('password', encryptedBuffer, iv);
|
|
1352
|
+
```
|
|
1353
|
+
|
|
1354
|
+
### `encryptFile(passPhrase: string, options: EncryptFileOptions): Promise<EncryptedFile>`
|
|
1355
|
+
|
|
1356
|
+
Encrypts a complete file with thumbnail and metadata.
|
|
1357
|
+
|
|
1358
|
+
**Parameters:**
|
|
1359
|
+
- `passPhrase`: The passphrase to derive the key from
|
|
1360
|
+
- `options`: Encryption options (see `EncryptFileOptions` interface)
|
|
1361
|
+
|
|
1362
|
+
**Returns:** Promise resolving to `EncryptedFile` object
|
|
1363
|
+
|
|
1364
|
+
**Example:**
|
|
1365
|
+
```typescript
|
|
1366
|
+
const encrypted = await libraryApi.encryptFile('password', {
|
|
1367
|
+
filename: 'photo.jpg',
|
|
1368
|
+
buffer: fileBuffer,
|
|
1369
|
+
thumb: thumbBuffer,
|
|
1370
|
+
thumbMime: 'image/jpeg',
|
|
1371
|
+
mime: 'image/jpeg'
|
|
1372
|
+
});
|
|
1373
|
+
```
|
|
1374
|
+
|
|
1375
|
+
### `decryptFile(passPhrase: string, buffer: ArrayBuffer): Promise<ArrayBuffer>`
|
|
1376
|
+
|
|
1377
|
+
Decrypts file data from an encrypted file structure.
|
|
1378
|
+
|
|
1379
|
+
**Parameters:**
|
|
1380
|
+
- `passPhrase`: The passphrase to derive the key from
|
|
1381
|
+
- `buffer`: The complete encrypted file structure
|
|
1382
|
+
|
|
1383
|
+
**Returns:** Promise resolving to decrypted file ArrayBuffer
|
|
1384
|
+
|
|
1385
|
+
**Example:**
|
|
1386
|
+
```typescript
|
|
1387
|
+
const decrypted = await libraryApi.decryptFile('password', encryptedFileBlob);
|
|
1388
|
+
```
|
|
1389
|
+
|
|
1390
|
+
### `decryptMediaThumb(passPhrase: string, buffer: ArrayBuffer): Promise<ArrayBuffer>`
|
|
1391
|
+
|
|
1392
|
+
Decrypts thumbnail from an encrypted file structure.
|
|
1393
|
+
|
|
1394
|
+
**Parameters:**
|
|
1395
|
+
- `passPhrase`: The passphrase to derive the key from
|
|
1396
|
+
- `buffer`: The complete encrypted file structure
|
|
1397
|
+
|
|
1398
|
+
**Returns:** Promise resolving to decrypted thumbnail ArrayBuffer
|
|
1399
|
+
|
|
1400
|
+
**Example:**
|
|
1401
|
+
```typescript
|
|
1402
|
+
const decryptedThumb = await libraryApi.decryptMediaThumb('password', encryptedFileBlob);
|
|
1403
|
+
```
|
|
1404
|
+
|
|
1405
|
+
### `encryptFilename(passPhrase: string, filename: string, iv: ArrayBuffer | Uint8Array): Promise<string>`
|
|
1406
|
+
|
|
1407
|
+
Encrypts a filename using a passphrase and IV.
|
|
1408
|
+
|
|
1409
|
+
**Parameters:**
|
|
1410
|
+
- `passPhrase`: The passphrase to derive the key from
|
|
1411
|
+
- `filename`: The filename to encrypt
|
|
1412
|
+
- `iv`: The IV to use (should match the file's IV)
|
|
1413
|
+
|
|
1414
|
+
**Returns:** Promise resolving to base64url encoded encrypted filename
|
|
1415
|
+
|
|
1416
|
+
**Example:**
|
|
1417
|
+
```typescript
|
|
1418
|
+
const iv = libraryApi.getRandomIV();
|
|
1419
|
+
const encryptedFilename = await libraryApi.encryptFilename('password', 'photo.jpg', iv);
|
|
1420
|
+
```
|
|
1421
|
+
|
|
1422
|
+
### `getRandomIV(): Uint8Array`
|
|
1423
|
+
|
|
1424
|
+
Generates a random 16-byte IV (Initialization Vector).
|
|
1425
|
+
|
|
1426
|
+
**Returns:** `Uint8Array` of 16 random bytes
|
|
1427
|
+
|
|
1428
|
+
**Example:**
|
|
1429
|
+
```typescript
|
|
1430
|
+
const iv = libraryApi.getRandomIV();
|
|
1431
|
+
```
|
|
1432
|
+
|
|
1433
|
+
---
|
|
1434
|
+
|
|
1435
|
+
## Utilities
|
|
1436
|
+
|
|
1437
|
+
### `getCryptChallenge(): Promise<string>`
|
|
1438
|
+
|
|
1439
|
+
Gets a cryptographic challenge for encryption verification.
|
|
1440
|
+
|
|
1441
|
+
**Returns:** Promise resolving to challenge string
|
|
1442
|
+
|
|
1443
|
+
**Example:**
|
|
1444
|
+
```typescript
|
|
1445
|
+
const challenge = await libraryApi.getCryptChallenge();
|
|
1446
|
+
```
|
|
1447
|
+
|
|
1448
|
+
### `getChannels(): Promise<any[]>`
|
|
1449
|
+
|
|
1450
|
+
Gets all channels (for IPTV libraries).
|
|
1451
|
+
|
|
1452
|
+
**Returns:** Promise resolving to an array of channel objects
|
|
1453
|
+
|
|
1454
|
+
**Example:**
|
|
1455
|
+
```typescript
|
|
1456
|
+
const channels = await libraryApi.getChannels();
|
|
1457
|
+
```
|
|
1458
|
+
|
|
1459
|
+
### `getWatermarks(): Promise<string[]>`
|
|
1460
|
+
|
|
1461
|
+
Gets list of available watermark names.
|
|
1462
|
+
|
|
1463
|
+
**Returns:** Promise resolving to an array of watermark names
|
|
1464
|
+
|
|
1465
|
+
**Example:**
|
|
1466
|
+
```typescript
|
|
1467
|
+
const watermarks = await libraryApi.getWatermarks();
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
### `getWatermark(watermark: string, options?: { type?: 'blob' | 'arraybuffer' }): Promise<Blob | ArrayBuffer>`
|
|
1471
|
+
|
|
1472
|
+
Gets a watermark image.
|
|
1473
|
+
|
|
1474
|
+
**Parameters:**
|
|
1475
|
+
- `watermark`: Watermark name (or 'default')
|
|
1476
|
+
- `options`: Optional object with `type` property
|
|
1477
|
+
|
|
1478
|
+
**Returns:** Promise resolving to watermark data
|
|
1479
|
+
|
|
1480
|
+
**Example:**
|
|
1481
|
+
```typescript
|
|
1482
|
+
const watermark = await libraryApi.getWatermark('default', { type: 'blob' });
|
|
1483
|
+
```
|
|
1484
|
+
|
|
1485
|
+
### `expandUrl(parsedUrl: any): Promise<string | undefined>`
|
|
1486
|
+
|
|
1487
|
+
Expands a parsed URL using plugins.
|
|
1488
|
+
|
|
1489
|
+
**Parameters:**
|
|
1490
|
+
- `parsedUrl`: Parsed URL object
|
|
1491
|
+
|
|
1492
|
+
**Returns:** Promise resolving to expanded URL or undefined
|
|
1493
|
+
|
|
1494
|
+
**Example:**
|
|
1495
|
+
```typescript
|
|
1496
|
+
const expanded = await libraryApi.expandUrl(parsedUrl);
|
|
1497
|
+
```
|
|
1498
|
+
|
|
1499
|
+
### `parseUrl(url: string): Promise<any>`
|
|
1500
|
+
|
|
1501
|
+
Parses a URL using plugins.
|
|
1502
|
+
|
|
1503
|
+
**Parameters:**
|
|
1504
|
+
- `url`: URL string to parse
|
|
1505
|
+
|
|
1506
|
+
**Returns:** Promise resolving to parsed URL object
|
|
1507
|
+
|
|
1508
|
+
**Example:**
|
|
1509
|
+
```typescript
|
|
1510
|
+
const parsed = await libraryApi.parseUrl('https://example.com/video');
|
|
1511
|
+
```
|
|
1512
|
+
|
|
1513
|
+
### `listVideoConvertPlugins(): Promise<any[]>`
|
|
1514
|
+
|
|
1515
|
+
Lists available video conversion plugins.
|
|
1516
|
+
|
|
1517
|
+
**Returns:** Promise resolving to an array of plugin objects
|
|
1518
|
+
|
|
1519
|
+
**Example:**
|
|
1520
|
+
```typescript
|
|
1521
|
+
const plugins = await libraryApi.listVideoConvertPlugins();
|
|
1522
|
+
```
|
|
1523
|
+
|
|
1524
|
+
### `clean(): Promise<string>`
|
|
1525
|
+
|
|
1526
|
+
Triggers library cleanup operation.
|
|
1527
|
+
|
|
1528
|
+
**Returns:** Promise resolving to cleanup result message
|
|
1529
|
+
|
|
1530
|
+
**Example:**
|
|
1531
|
+
```typescript
|
|
1532
|
+
const result = await libraryApi.clean();
|
|
1533
|
+
```
|
|
1534
|
+
|
|
1535
|
+
### `locs(): Promise<any>`
|
|
1536
|
+
|
|
1537
|
+
Gets location data.
|
|
1538
|
+
|
|
1539
|
+
**Returns:** Promise resolving to location data
|
|
1540
|
+
|
|
1541
|
+
**Example:**
|
|
1542
|
+
```typescript
|
|
1543
|
+
const locations = await libraryApi.locs();
|
|
1544
|
+
```
|
|
1545
|
+
|
|
1546
|
+
### `mergeMedias(request: any): Promise<IFile>`
|
|
1547
|
+
|
|
1548
|
+
Merges multiple media files into one.
|
|
1549
|
+
|
|
1550
|
+
**Parameters:**
|
|
1551
|
+
- `request`: Merge request object with media IDs
|
|
1552
|
+
|
|
1553
|
+
**Returns:** Promise resolving to merged `IFile` object
|
|
1554
|
+
|
|
1555
|
+
**Example:**
|
|
1556
|
+
```typescript
|
|
1557
|
+
const merged = await libraryApi.mergeMedias({
|
|
1558
|
+
ids: ['media-1', 'media-2']
|
|
1559
|
+
});
|
|
1560
|
+
```
|
|
1561
|
+
|
|
1562
|
+
---
|
|
1563
|
+
|
|
1564
|
+
## Common Workflows
|
|
1565
|
+
|
|
1566
|
+
### Uploading Media to Encrypted Library
|
|
1567
|
+
|
|
1568
|
+
```typescript
|
|
1569
|
+
// 1. Set encryption key
|
|
1570
|
+
await libraryApi.setKey('my-password');
|
|
1571
|
+
|
|
1572
|
+
// 2. Prepare file and thumbnail
|
|
1573
|
+
const fileData = await file.arrayBuffer();
|
|
1574
|
+
const thumbData = await thumbnail.arrayBuffer();
|
|
1575
|
+
|
|
1576
|
+
// 3. Upload with progress tracking
|
|
1577
|
+
const uploaded = await libraryApi.uploadMedia(fileData, {
|
|
1578
|
+
thumb: thumbData,
|
|
1579
|
+
metadata: {
|
|
1580
|
+
name: 'photo.jpg',
|
|
1581
|
+
description: 'My encrypted photo'
|
|
1582
|
+
},
|
|
1583
|
+
fileMime: 'image/jpeg',
|
|
1584
|
+
thumbMime: 'image/jpeg',
|
|
1585
|
+
progressCallback: (loaded, total) => {
|
|
1586
|
+
console.log(`Upload: ${(loaded / total * 100).toFixed(1)}%`);
|
|
1587
|
+
}
|
|
1588
|
+
});
|
|
1589
|
+
|
|
1590
|
+
console.log(`Uploaded with IV: ${uploaded.iv}`);
|
|
1591
|
+
```
|
|
1592
|
+
|
|
1593
|
+
### Downloading and Decrypting Media
|
|
1594
|
+
|
|
1595
|
+
```typescript
|
|
1596
|
+
// 1. Set encryption key
|
|
1597
|
+
await libraryApi.setKey('my-password');
|
|
1598
|
+
|
|
1599
|
+
// 2. Get media metadata
|
|
1600
|
+
const metadata = await libraryApi.getMediaMetadata('media-id');
|
|
1601
|
+
|
|
1602
|
+
// 3. Download encrypted file
|
|
1603
|
+
const encryptedBlob = await libraryApi.getMedia('media-id', { type: 'arraybuffer' });
|
|
1604
|
+
|
|
1605
|
+
// 4. Decrypt file
|
|
1606
|
+
const decrypted = await libraryApi.decryptFile('my-password', encryptedBlob);
|
|
1607
|
+
|
|
1608
|
+
// 5. Use decrypted data
|
|
1609
|
+
const blob = new Blob([decrypted], { type: metadata.mimetype });
|
|
1610
|
+
const url = URL.createObjectURL(blob);
|
|
1611
|
+
```
|
|
1612
|
+
|
|
1613
|
+
### Tagging Media
|
|
1614
|
+
|
|
1615
|
+
```typescript
|
|
1616
|
+
// 1. Get or create tags
|
|
1617
|
+
const tags = await libraryApi.getTags();
|
|
1618
|
+
let vacationTag = tags.find(t => t.name === 'Vacation');
|
|
1619
|
+
if (!vacationTag) {
|
|
1620
|
+
vacationTag = await libraryApi.createTag({ name: 'Vacation' });
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
// 2. Add tag to media
|
|
1624
|
+
await libraryApi.addTagToMedia('media-id', vacationTag.id!);
|
|
1625
|
+
```
|
|
1626
|
+
|
|
1627
|
+
### Managing People and Faces
|
|
1628
|
+
|
|
1629
|
+
```typescript
|
|
1630
|
+
// 1. Create person
|
|
1631
|
+
const person = await libraryApi.createPerson({ name: 'John Doe' });
|
|
1632
|
+
|
|
1633
|
+
// 2. Get unassigned faces
|
|
1634
|
+
const faces = await libraryApi.getUnassignedFaces();
|
|
1635
|
+
|
|
1636
|
+
// 3. Assign faces to person
|
|
1637
|
+
await libraryApi.assignFaces({
|
|
1638
|
+
faceIds: ['face-1', 'face-2'],
|
|
1639
|
+
personId: person.id!
|
|
1640
|
+
});
|
|
1641
|
+
|
|
1642
|
+
// 4. Cluster faces for better organization
|
|
1643
|
+
await libraryApi.faceClusterPerson(person.id!);
|
|
1644
|
+
```
|
|
1645
|
+
|
|
1646
|
+
## Related Documentation
|
|
1647
|
+
|
|
1648
|
+
- [RedseatClient Documentation](client.md) - HTTP client used by LibraryApi
|
|
1649
|
+
- [ServerApi Documentation](server.md) - Server-level operations
|
|
1650
|
+
- [Encryption Documentation](encryption.md) - Detailed encryption module documentation
|
|
1651
|
+
- [README](README.md) - Package overview
|
|
1652
|
+
|