@redseat/api 0.3.6 → 0.3.11
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/CLAUDE.md +1 -1
- package/README.md +137 -132
- package/{AGENTS.md → agents.md} +275 -275
- package/client.md +670 -670
- package/dist/client.d.ts +4 -1
- package/dist/client.js +9 -0
- package/dist/interfaces.d.ts +181 -0
- package/dist/library.d.ts +42 -2
- package/dist/library.js +54 -0
- package/dist/sse-types.d.ts +28 -1
- package/encryption.md +533 -533
- package/firebase.md +602 -602
- package/libraries.md +207 -20
- package/package.json +49 -49
- package/server.md +538 -398
- package/test.md +291 -291
package/libraries.md
CHANGED
|
@@ -899,12 +899,19 @@ const results = await libraryApi.searchSeries('Breaking');
|
|
|
899
899
|
|
|
900
900
|
Marks an episode as watched.
|
|
901
901
|
|
|
902
|
+
**How it works:** This method uses the local series/episode IDs from the library. The server automatically resolves these to external IDs (IMDb, Trakt, etc.) and stores the watch entry in the **global history** system. This means:
|
|
903
|
+
- Watch status syncs across different servers
|
|
904
|
+
- Watch status is accessible via `ServerApi.getHistory()`
|
|
905
|
+
- External services can sync with your watch history
|
|
906
|
+
|
|
907
|
+
See [server.md - Watch History API](server.md#watch-history-api) for details on the global history system.
|
|
908
|
+
|
|
902
909
|
**Parameters:**
|
|
903
910
|
|
|
904
|
-
- `serieId`: The ID of the series
|
|
911
|
+
- `serieId`: The ID of the series (local library ID)
|
|
905
912
|
- `season`: Season number
|
|
906
913
|
- `number`: Episode number
|
|
907
|
-
- `date`: Timestamp of when it was watched
|
|
914
|
+
- `date`: Timestamp of when it was watched (unix milliseconds)
|
|
908
915
|
|
|
909
916
|
**Example:**
|
|
910
917
|
|
|
@@ -918,48 +925,59 @@ Gets the watched status for an episode.
|
|
|
918
925
|
|
|
919
926
|
**Parameters:**
|
|
920
927
|
|
|
921
|
-
- `serieId`: The ID of the series
|
|
928
|
+
- `serieId`: The ID of the series (local library ID)
|
|
922
929
|
- `season`: Season number
|
|
923
930
|
- `episode`: Episode number
|
|
924
931
|
|
|
925
|
-
**Returns:** Promise resolving to an `IWatched` object containing
|
|
932
|
+
**Returns:** Promise resolving to an `IWatched` object containing:
|
|
933
|
+
- `type`: Always `'episode'`
|
|
934
|
+
- `id`: External ID in format `provider:value` (e.g., `imdb:tt0959621`)
|
|
935
|
+
- `date`: Timestamp when watched
|
|
936
|
+
- `modified`: Timestamp when entry was modified
|
|
926
937
|
|
|
927
938
|
**Example:**
|
|
928
939
|
|
|
929
940
|
```typescript
|
|
930
941
|
const watched = await libraryApi.getEpisodeWatched('serie-id', 1, 1);
|
|
931
942
|
console.log(`Watched on: ${new Date(watched.date).toLocaleDateString()}`);
|
|
943
|
+
console.log(`External ID: ${watched.id}`); // e.g., "imdb:tt0959621"
|
|
932
944
|
```
|
|
933
945
|
|
|
934
946
|
### `getEpisodeProgress(serieId: string, season: number, episode: number): Promise<IViewProgress>`
|
|
935
947
|
|
|
936
|
-
Gets the view progress for an episode.
|
|
948
|
+
Gets the view progress for an episode. Progress is stored in the global history system.
|
|
937
949
|
|
|
938
950
|
**Parameters:**
|
|
939
951
|
|
|
940
|
-
- `serieId`: The ID of the series
|
|
952
|
+
- `serieId`: The ID of the series (local library ID)
|
|
941
953
|
- `season`: Season number
|
|
942
954
|
- `episode`: Episode number
|
|
943
955
|
|
|
944
|
-
**Returns:** Promise resolving to an `IViewProgress` object containing
|
|
956
|
+
**Returns:** Promise resolving to an `IViewProgress` object containing:
|
|
957
|
+
- `type`: Always `'episode'`
|
|
958
|
+
- `id`: External ID in format `provider:value`
|
|
959
|
+
- `progress`: Playback position in milliseconds
|
|
960
|
+
- `parent`: Series external ID (if available)
|
|
961
|
+
- `modified`: Timestamp when progress was last updated
|
|
945
962
|
|
|
946
963
|
**Example:**
|
|
947
964
|
|
|
948
965
|
```typescript
|
|
949
966
|
const progress = await libraryApi.getEpisodeProgress('serie-id', 1, 1);
|
|
950
967
|
console.log(`Progress: ${progress.progress}ms`);
|
|
968
|
+
console.log(`Episode ID: ${progress.id}`);
|
|
951
969
|
```
|
|
952
970
|
|
|
953
971
|
### `setEpisodeProgress(serieId: string, season: number, episode: number, progress: number): Promise<void>`
|
|
954
972
|
|
|
955
|
-
Sets the view progress for an episode.
|
|
973
|
+
Sets the view progress for an episode. Progress is stored in the global history system using external IDs.
|
|
956
974
|
|
|
957
975
|
**Parameters:**
|
|
958
976
|
|
|
959
|
-
- `serieId`: The ID of the series
|
|
977
|
+
- `serieId`: The ID of the series (local library ID)
|
|
960
978
|
- `season`: Season number
|
|
961
979
|
- `episode`: Episode number
|
|
962
|
-
- `progress`: Progress value
|
|
980
|
+
- `progress`: Progress value in milliseconds (video playback position)
|
|
963
981
|
|
|
964
982
|
**Example:**
|
|
965
983
|
|
|
@@ -1079,10 +1097,17 @@ const images = await libraryApi.getMovieImages('movie-id');
|
|
|
1079
1097
|
|
|
1080
1098
|
Marks a movie as watched.
|
|
1081
1099
|
|
|
1100
|
+
**How it works:** This method uses the local movie ID from the library. The server automatically resolves this to an external ID (IMDb, Trakt, TMDb, etc.) and stores the watch entry in the **global history** system. This means:
|
|
1101
|
+
- Watch status syncs across different servers
|
|
1102
|
+
- Watch status is accessible via `ServerApi.getHistory()`
|
|
1103
|
+
- External services can sync with your watch history
|
|
1104
|
+
|
|
1105
|
+
See [server.md - Watch History API](server.md#watch-history-api) for details on the global history system.
|
|
1106
|
+
|
|
1082
1107
|
**Parameters:**
|
|
1083
1108
|
|
|
1084
|
-
- `movieId`: The ID of the movie
|
|
1085
|
-
- `date`: Timestamp of when it was watched
|
|
1109
|
+
- `movieId`: The ID of the movie (local library ID)
|
|
1110
|
+
- `date`: Timestamp of when it was watched (unix milliseconds)
|
|
1086
1111
|
|
|
1087
1112
|
**Example:**
|
|
1088
1113
|
|
|
@@ -1096,42 +1121,52 @@ Gets the watched status for a movie.
|
|
|
1096
1121
|
|
|
1097
1122
|
**Parameters:**
|
|
1098
1123
|
|
|
1099
|
-
- `movieId`: The ID of the movie
|
|
1124
|
+
- `movieId`: The ID of the movie (local library ID)
|
|
1100
1125
|
|
|
1101
|
-
**Returns:** Promise resolving to an `IWatched` object containing
|
|
1126
|
+
**Returns:** Promise resolving to an `IWatched` object containing:
|
|
1127
|
+
- `type`: Always `'movie'`
|
|
1128
|
+
- `id`: External ID in format `provider:value` (e.g., `imdb:tt0111161`)
|
|
1129
|
+
- `date`: Timestamp when watched
|
|
1130
|
+
- `modified`: Timestamp when entry was modified
|
|
1102
1131
|
|
|
1103
1132
|
**Example:**
|
|
1104
1133
|
|
|
1105
1134
|
```typescript
|
|
1106
1135
|
const watched = await libraryApi.getMovieWatched('movie-id');
|
|
1107
1136
|
console.log(`Watched on: ${new Date(watched.date).toLocaleDateString()}`);
|
|
1137
|
+
console.log(`External ID: ${watched.id}`); // e.g., "imdb:tt0111161"
|
|
1108
1138
|
```
|
|
1109
1139
|
|
|
1110
1140
|
### `getMovieProgress(movieId: string): Promise<IViewProgress>`
|
|
1111
1141
|
|
|
1112
|
-
Gets the view progress for a movie.
|
|
1142
|
+
Gets the view progress for a movie. Progress is stored in the global history system.
|
|
1113
1143
|
|
|
1114
1144
|
**Parameters:**
|
|
1115
1145
|
|
|
1116
|
-
- `movieId`: The ID of the movie
|
|
1146
|
+
- `movieId`: The ID of the movie (local library ID)
|
|
1117
1147
|
|
|
1118
|
-
**Returns:** Promise resolving to an `IViewProgress` object containing
|
|
1148
|
+
**Returns:** Promise resolving to an `IViewProgress` object containing:
|
|
1149
|
+
- `type`: Always `'movie'`
|
|
1150
|
+
- `id`: External ID in format `provider:value`
|
|
1151
|
+
- `progress`: Playback position in milliseconds
|
|
1152
|
+
- `modified`: Timestamp when progress was last updated
|
|
1119
1153
|
|
|
1120
1154
|
**Example:**
|
|
1121
1155
|
|
|
1122
1156
|
```typescript
|
|
1123
1157
|
const progress = await libraryApi.getMovieProgress('movie-id');
|
|
1124
1158
|
console.log(`Progress: ${progress.progress}ms`);
|
|
1159
|
+
console.log(`External ID: ${progress.id}`);
|
|
1125
1160
|
```
|
|
1126
1161
|
|
|
1127
1162
|
### `setMovieProgress(movieId: string, progress: number): Promise<void>`
|
|
1128
1163
|
|
|
1129
|
-
Sets the view progress for a movie.
|
|
1164
|
+
Sets the view progress for a movie. Progress is stored in the global history system using external IDs.
|
|
1130
1165
|
|
|
1131
1166
|
**Parameters:**
|
|
1132
1167
|
|
|
1133
|
-
- `movieId`: The ID of the movie
|
|
1134
|
-
- `progress`: Progress value
|
|
1168
|
+
- `movieId`: The ID of the movie (local library ID)
|
|
1169
|
+
- `progress`: Progress value in milliseconds (video playback position)
|
|
1135
1170
|
|
|
1136
1171
|
**Example:**
|
|
1137
1172
|
|
|
@@ -1934,6 +1969,158 @@ await libraryApi.clusterFaces('person-id');
|
|
|
1934
1969
|
|
|
1935
1970
|
---
|
|
1936
1971
|
|
|
1972
|
+
## Request Processing
|
|
1973
|
+
|
|
1974
|
+
### `processRequest(request: RsRequest): Promise<RsRequest>`
|
|
1975
|
+
|
|
1976
|
+
Process an unprocessed RsRequest and return the processed result.
|
|
1977
|
+
Takes a raw request and runs it through the server's plugin processing pipeline.
|
|
1978
|
+
|
|
1979
|
+
**Parameters:**
|
|
1980
|
+
|
|
1981
|
+
- `request`: The unprocessed request to process
|
|
1982
|
+
|
|
1983
|
+
**Returns:** Promise resolving to the processed request with updated status and metadata
|
|
1984
|
+
|
|
1985
|
+
**Example:**
|
|
1986
|
+
|
|
1987
|
+
```typescript
|
|
1988
|
+
import { RsRequestStatus, RsRequestMethod } from '@redseat/api';
|
|
1989
|
+
|
|
1990
|
+
const unprocessedRequest: RsRequest = {
|
|
1991
|
+
url: 'https://example.com/video.mp4',
|
|
1992
|
+
method: RsRequestMethod.Get,
|
|
1993
|
+
status: RsRequestStatus.Unprocessed,
|
|
1994
|
+
permanent: false,
|
|
1995
|
+
ignoreOriginDuplicate: false
|
|
1996
|
+
};
|
|
1997
|
+
const processed = await libraryApi.processRequest(unprocessedRequest);
|
|
1998
|
+
console.log(processed.status); // RsRequestStatus.Processed
|
|
1999
|
+
```
|
|
2000
|
+
|
|
2001
|
+
### `processRequestStream(request: RsRequest): Promise<AxiosResponse>`
|
|
2002
|
+
|
|
2003
|
+
Process a request and return the raw HTTP stream response for direct streaming.
|
|
2004
|
+
|
|
2005
|
+
**Parameters:**
|
|
2006
|
+
|
|
2007
|
+
- `request`: The request to process and stream
|
|
2008
|
+
|
|
2009
|
+
**Returns:** Raw axios response - use `response.data` for the stream
|
|
2010
|
+
|
|
2011
|
+
**Example:**
|
|
2012
|
+
|
|
2013
|
+
```typescript
|
|
2014
|
+
const request: RsRequest = {
|
|
2015
|
+
url: 'https://example.com/video.mp4',
|
|
2016
|
+
method: RsRequestMethod.Get,
|
|
2017
|
+
status: RsRequestStatus.Processed,
|
|
2018
|
+
permanent: false,
|
|
2019
|
+
ignoreOriginDuplicate: false
|
|
2020
|
+
};
|
|
2021
|
+
const response = await libraryApi.processRequestStream(request);
|
|
2022
|
+
// response.data is the stream that can be piped directly
|
|
2023
|
+
```
|
|
2024
|
+
|
|
2025
|
+
### `addRequest(request: RsRequest, mediaRef?: string): Promise<IRsRequestProcessing>`
|
|
2026
|
+
|
|
2027
|
+
Add a request to the processing queue for background download/processing.
|
|
2028
|
+
|
|
2029
|
+
**Parameters:**
|
|
2030
|
+
|
|
2031
|
+
- `request`: The request to add for processing
|
|
2032
|
+
- `mediaRef`: Optional media reference to associate with the processing
|
|
2033
|
+
|
|
2034
|
+
**Returns:** Promise resolving to the created `IRsRequestProcessing` entry
|
|
2035
|
+
|
|
2036
|
+
**Example:**
|
|
2037
|
+
|
|
2038
|
+
```typescript
|
|
2039
|
+
import { RsRequestStatus, RsRequestMethod } from '@redseat/api';
|
|
2040
|
+
|
|
2041
|
+
const request: RsRequest = {
|
|
2042
|
+
url: 'https://example.com/large-video.mp4',
|
|
2043
|
+
method: RsRequestMethod.Get,
|
|
2044
|
+
status: RsRequestStatus.Unprocessed,
|
|
2045
|
+
permanent: false,
|
|
2046
|
+
ignoreOriginDuplicate: false
|
|
2047
|
+
};
|
|
2048
|
+
|
|
2049
|
+
// Add to processing queue
|
|
2050
|
+
const processing = await libraryApi.addRequest(request);
|
|
2051
|
+
console.log(processing.id); // Processing ID
|
|
2052
|
+
console.log(processing.status); // "pending" | "processing" | "paused" | "finished" | "error"
|
|
2053
|
+
console.log(processing.progress); // 0-100
|
|
2054
|
+
|
|
2055
|
+
// Associate with existing media
|
|
2056
|
+
const processingWithMedia = await libraryApi.addRequest(request, 'media-id');
|
|
2057
|
+
```
|
|
2058
|
+
|
|
2059
|
+
### `listRequestProcessing(): Promise<IRsRequestProcessing[]>`
|
|
2060
|
+
|
|
2061
|
+
List all active request processings for this library.
|
|
2062
|
+
|
|
2063
|
+
**Returns:** Promise resolving to an array of `IRsRequestProcessing` entries
|
|
2064
|
+
|
|
2065
|
+
**Example:**
|
|
2066
|
+
|
|
2067
|
+
```typescript
|
|
2068
|
+
const processings = await libraryApi.listRequestProcessing();
|
|
2069
|
+
for (const p of processings) {
|
|
2070
|
+
console.log(`${p.id}: ${p.status} (${p.progress}%)`);
|
|
2071
|
+
if (p.error) {
|
|
2072
|
+
console.log(` Error: ${p.error}`);
|
|
2073
|
+
}
|
|
2074
|
+
if (p.mediaRef) {
|
|
2075
|
+
console.log(` Media: ${p.mediaRef}`);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
```
|
|
2079
|
+
|
|
2080
|
+
### `pauseRequestProcessing(processingId: string): Promise<IRsRequestProcessing>`
|
|
2081
|
+
|
|
2082
|
+
Pause a request processing task. This stops the download/processing temporarily.
|
|
2083
|
+
|
|
2084
|
+
**Parameters:**
|
|
2085
|
+
|
|
2086
|
+
- `processingId`: The ID of the processing task to pause
|
|
2087
|
+
|
|
2088
|
+
**Returns:** Promise resolving to the updated `IRsRequestProcessing` entry with status "paused"
|
|
2089
|
+
|
|
2090
|
+
**Example:**
|
|
2091
|
+
|
|
2092
|
+
```typescript
|
|
2093
|
+
const processings = await libraryApi.listRequestProcessing();
|
|
2094
|
+
const activeProcessing = processings.find(p => p.status === 'processing');
|
|
2095
|
+
|
|
2096
|
+
if (activeProcessing) {
|
|
2097
|
+
const paused = await libraryApi.pauseRequestProcessing(activeProcessing.id);
|
|
2098
|
+
console.log(`Paused: ${paused.id}, status: ${paused.status}`); // status: "paused"
|
|
2099
|
+
}
|
|
2100
|
+
```
|
|
2101
|
+
|
|
2102
|
+
### `deleteRequestProcessing(processingId: string): Promise<void>`
|
|
2103
|
+
|
|
2104
|
+
Delete/remove a request processing task from the queue. This cancels and removes the processing entry.
|
|
2105
|
+
|
|
2106
|
+
**Parameters:**
|
|
2107
|
+
|
|
2108
|
+
- `processingId`: The ID of the processing task to delete
|
|
2109
|
+
|
|
2110
|
+
**Example:**
|
|
2111
|
+
|
|
2112
|
+
```typescript
|
|
2113
|
+
const processings = await libraryApi.listRequestProcessing();
|
|
2114
|
+
const processingToRemove = processings.find(p => p.status === 'error');
|
|
2115
|
+
|
|
2116
|
+
if (processingToRemove) {
|
|
2117
|
+
await libraryApi.deleteRequestProcessing(processingToRemove.id);
|
|
2118
|
+
console.log(`Removed processing: ${processingToRemove.id}`);
|
|
2119
|
+
}
|
|
2120
|
+
```
|
|
2121
|
+
|
|
2122
|
+
---
|
|
2123
|
+
|
|
1937
2124
|
## Encryption
|
|
1938
2125
|
|
|
1939
2126
|
These methods are convenience wrappers around the encryption module. For detailed encryption documentation, see [encryption.md](encryption.md).
|
package/package.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@redseat/api",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "TypeScript API client library for interacting with Redseat servers",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist/**/*",
|
|
17
|
-
"README.md",
|
|
18
|
-
"*.md"
|
|
19
|
-
],
|
|
20
|
-
"keywords": [
|
|
21
|
-
"redseat",
|
|
22
|
-
"api",
|
|
23
|
-
"client",
|
|
24
|
-
"typescript"
|
|
25
|
-
],
|
|
26
|
-
"author": "Arnaud JEZEQUEL <arnaud.jezequel@gmail.com>",
|
|
27
|
-
"license": "MIT",
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "https://github.com/yourusername/redseat-svelte.git",
|
|
31
|
-
"directory": "packages/api"
|
|
32
|
-
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"build": "tsc",
|
|
35
|
-
"test": "vitest run",
|
|
36
|
-
"test:watch": "vitest"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"axios": "^1.11.0",
|
|
40
|
-
"rxjs": "^7.8.2"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"typescript": "^5.8.3",
|
|
44
|
-
"vite": "^7.3.0",
|
|
45
|
-
"vitest": "^4.0.16"
|
|
46
|
-
},
|
|
47
|
-
"publishConfig": {
|
|
48
|
-
"access": "public"
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@redseat/api",
|
|
3
|
+
"version": "0.3.11",
|
|
4
|
+
"description": "TypeScript API client library for interacting with Redseat servers",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/**/*",
|
|
17
|
+
"README.md",
|
|
18
|
+
"*.md"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"redseat",
|
|
22
|
+
"api",
|
|
23
|
+
"client",
|
|
24
|
+
"typescript"
|
|
25
|
+
],
|
|
26
|
+
"author": "Arnaud JEZEQUEL <arnaud.jezequel@gmail.com>",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/yourusername/redseat-svelte.git",
|
|
31
|
+
"directory": "packages/api"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"axios": "^1.11.0",
|
|
40
|
+
"rxjs": "^7.8.2"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"typescript": "^5.8.3",
|
|
44
|
+
"vite": "^7.3.0",
|
|
45
|
+
"vitest": "^4.0.16"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
}
|
|
50
50
|
}
|