debrid-ts 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +181 -2
- package/dist/index.d.mts +1373 -0
- package/dist/index.mjs +1234 -0
- package/package.json +65 -3
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1373 @@
|
|
|
1
|
+
//#region src/lib/fetcher.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Base fetcher shared by all debrid service clients.
|
|
4
|
+
*
|
|
5
|
+
* Wraps fetch with: base URL joining, default headers (auth), query-string
|
|
6
|
+
* encoding, form-urlencoded POST/PUT bodies, 204-no-content handling,
|
|
7
|
+
* optional timeout / 429 retries and JSON error normalization into
|
|
8
|
+
* {@link DebridError}.
|
|
9
|
+
*/
|
|
10
|
+
declare class DebridError extends Error {
|
|
11
|
+
/** HTTP status — 200 for errors reported inside a successful response envelope */
|
|
12
|
+
readonly status: number;
|
|
13
|
+
/** Provider error code, e.g. "bad_token" (Real-Debrid), "MAGNET_INVALID_ID" (AllDebrid) */
|
|
14
|
+
readonly code?: string | undefined;
|
|
15
|
+
/** Raw error payload as returned by the provider, when there was one */
|
|
16
|
+
readonly details?: unknown;
|
|
17
|
+
constructor(message: string,
|
|
18
|
+
/** HTTP status — 200 for errors reported inside a successful response envelope */
|
|
19
|
+
status: number,
|
|
20
|
+
/** Provider error code, e.g. "bad_token" (Real-Debrid), "MAGNET_INVALID_ID" (AllDebrid) */
|
|
21
|
+
code?: string | undefined,
|
|
22
|
+
/** Raw error payload as returned by the provider, when there was one */
|
|
23
|
+
details?: unknown);
|
|
24
|
+
}
|
|
25
|
+
/** Options every service client accepts. */
|
|
26
|
+
interface ClientOptions {
|
|
27
|
+
/** Injectable fetch — defaults to global fetch (mock it in tests) */
|
|
28
|
+
fetch?: typeof globalThis.fetch;
|
|
29
|
+
/** Per-request timeout in milliseconds (no timeout by default) */
|
|
30
|
+
timeout?: number;
|
|
31
|
+
/**
|
|
32
|
+
* How many times a request answered with HTTP 429 is retried, honoring
|
|
33
|
+
* `Retry-After` when sent (exponential backoff from 1s otherwise). Default 0.
|
|
34
|
+
*/
|
|
35
|
+
maxRetries?: number;
|
|
36
|
+
}
|
|
37
|
+
interface BaseFetcherOptions extends ClientOptions {
|
|
38
|
+
/** API base URL, e.g. `https://api.real-debrid.com/rest/1.0` */
|
|
39
|
+
baseUrl: string;
|
|
40
|
+
/** Headers sent with every request (auth, etc.) */
|
|
41
|
+
headers?: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
type QueryValue = string | number | boolean | undefined;
|
|
44
|
+
/** Arrays serialize as repeated params: `{ id: [1,2] }` → `id=1&id=2` */
|
|
45
|
+
type FormValue = string | number | boolean | Array<string | number> | undefined;
|
|
46
|
+
/** Local alias — `BodyInit` is not a global under lib: es2023. */
|
|
47
|
+
type BodyLike = NonNullable<RequestInit['body']>;
|
|
48
|
+
interface RequestOptions {
|
|
49
|
+
query?: Record<string, QueryValue>;
|
|
50
|
+
form?: Record<string, FormValue>;
|
|
51
|
+
body?: BodyLike;
|
|
52
|
+
headers?: Record<string, string>;
|
|
53
|
+
}
|
|
54
|
+
declare class BaseFetcher {
|
|
55
|
+
#private;
|
|
56
|
+
constructor(options: BaseFetcherOptions);
|
|
57
|
+
protected request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
58
|
+
/** GET with optional query params */
|
|
59
|
+
get<T>(path: string, query?: Record<string, QueryValue>): Promise<T>;
|
|
60
|
+
/** GET without JSON parsing — endpoints returning raw text (e.g. RD /time). */
|
|
61
|
+
getRawText(path: string): Promise<string>;
|
|
62
|
+
/** POST with a form-urlencoded body */
|
|
63
|
+
post<T>(path: string, form?: Record<string, FormValue>): Promise<T>;
|
|
64
|
+
/** POST with a raw body (multipart file uploads, JSON, ...) */
|
|
65
|
+
postBody<T>(path: string, body: BodyLike, headers?: Record<string, string>): Promise<T>;
|
|
66
|
+
/** PUT with a form-urlencoded body */
|
|
67
|
+
put<T>(path: string, form?: Record<string, FormValue>): Promise<T>;
|
|
68
|
+
/** PUT with a raw body (file uploads) */
|
|
69
|
+
putBody<T>(path: string, body: BodyLike, headers?: Record<string, string>): Promise<T>;
|
|
70
|
+
/** DELETE */
|
|
71
|
+
delete<T>(path: string): Promise<T>;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/lib/utils.d.ts
|
|
75
|
+
/** Anything accepted as file content by the upload methods. */
|
|
76
|
+
type FileInput = Blob | Uint8Array | ArrayBuffer;
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/types.d.ts
|
|
79
|
+
/**
|
|
80
|
+
* Provider-agnostic types. Every service (real-debrid, alldebrid, ...)
|
|
81
|
+
* implements {@link DebridProvider} so consumer code can swap providers
|
|
82
|
+
* without touching anything but the constructor.
|
|
83
|
+
*/
|
|
84
|
+
interface UserInfo {
|
|
85
|
+
id: string;
|
|
86
|
+
username: string;
|
|
87
|
+
/** Whether the account currently has premium status */
|
|
88
|
+
premium: boolean;
|
|
89
|
+
/** Premium expiry, or null for free accounts */
|
|
90
|
+
expiresAt: Date | null;
|
|
91
|
+
email?: string;
|
|
92
|
+
avatar?: string;
|
|
93
|
+
locale?: string;
|
|
94
|
+
}
|
|
95
|
+
type TorrentStatus = 'magnet_error' | 'magnet_conversion' | 'waiting_files_selection' | 'queued' | 'downloading' | 'downloaded' | 'error' | 'virus' | 'compressing' | 'uploading' | 'dead';
|
|
96
|
+
interface TorrentFile {
|
|
97
|
+
id: number;
|
|
98
|
+
path: string;
|
|
99
|
+
bytes: number;
|
|
100
|
+
selected: boolean;
|
|
101
|
+
/** Host link for this file, present once the torrent is downloaded */
|
|
102
|
+
downloadUrl?: string;
|
|
103
|
+
}
|
|
104
|
+
interface Torrent {
|
|
105
|
+
id: string;
|
|
106
|
+
name: string;
|
|
107
|
+
hash: string;
|
|
108
|
+
bytes: number;
|
|
109
|
+
/** 0–100 */
|
|
110
|
+
progress: number;
|
|
111
|
+
status: TorrentStatus;
|
|
112
|
+
files?: TorrentFile[];
|
|
113
|
+
/** Host links (still need unrestricting for direct download) */
|
|
114
|
+
links: string[];
|
|
115
|
+
addedAt?: Date;
|
|
116
|
+
speed?: number;
|
|
117
|
+
seeders?: number;
|
|
118
|
+
ratio?: number;
|
|
119
|
+
}
|
|
120
|
+
interface DownloadLink {
|
|
121
|
+
id: string;
|
|
122
|
+
filename: string;
|
|
123
|
+
bytes: number;
|
|
124
|
+
/** Direct, unrestricted download/stream URL */
|
|
125
|
+
url: string;
|
|
126
|
+
/** Original hoster link */
|
|
127
|
+
originalUrl: string;
|
|
128
|
+
streamable: boolean;
|
|
129
|
+
}
|
|
130
|
+
/** Normalized surface every provider implements. */
|
|
131
|
+
interface DebridProvider {
|
|
132
|
+
readonly name: string;
|
|
133
|
+
/** Account info: username, premium status, expiry. */
|
|
134
|
+
getUser(): Promise<UserInfo>;
|
|
135
|
+
/**
|
|
136
|
+
* Whether the torrent (info hash or magnet) is cached on the provider.
|
|
137
|
+
* May have side effects on the account, note each provider's caveats.
|
|
138
|
+
*/
|
|
139
|
+
isCached(hashOrMagnet: string): Promise<boolean>;
|
|
140
|
+
/** Add a magnet link and return the (not yet started) torrent. */
|
|
141
|
+
addMagnet(magnet: string, options?: {
|
|
142
|
+
host?: string;
|
|
143
|
+
}): Promise<Torrent>;
|
|
144
|
+
/** List the user's torrents. */
|
|
145
|
+
listTorrents(offset?: number, limit?: number): Promise<Torrent[]>;
|
|
146
|
+
/** Unrestricted direct links for all files of a downloaded torrent. */
|
|
147
|
+
getDownloadLinks(torrentId: string): Promise<DownloadLink[]>;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/services/real-debrid/types.d.ts
|
|
151
|
+
/**
|
|
152
|
+
* Real-Debrid API wire types — field names exactly as documented at
|
|
153
|
+
* https://api.real-debrid.com/ .
|
|
154
|
+
*/
|
|
155
|
+
interface RdUser {
|
|
156
|
+
id: number;
|
|
157
|
+
username: string;
|
|
158
|
+
email: string;
|
|
159
|
+
/** Fidelity points */
|
|
160
|
+
points: number;
|
|
161
|
+
locale: string;
|
|
162
|
+
/** Avatar URL */
|
|
163
|
+
avatar: string;
|
|
164
|
+
type: 'free' | 'premium';
|
|
165
|
+
/** Seconds of premium left (0 for free accounts) */
|
|
166
|
+
premium: number;
|
|
167
|
+
/** Premium expiry, jsonDate */
|
|
168
|
+
expiration: string;
|
|
169
|
+
}
|
|
170
|
+
interface RdAlternativeLink {
|
|
171
|
+
id: string;
|
|
172
|
+
filename: string;
|
|
173
|
+
download: string;
|
|
174
|
+
type: string;
|
|
175
|
+
}
|
|
176
|
+
interface RdUnrestrictedLink {
|
|
177
|
+
id: string;
|
|
178
|
+
filename: string;
|
|
179
|
+
/** Guessed from the file extension */
|
|
180
|
+
mimeType: string;
|
|
181
|
+
/** Bytes, 0 if unknown */
|
|
182
|
+
filesize: number;
|
|
183
|
+
/** Original hoster link */
|
|
184
|
+
link: string;
|
|
185
|
+
/** Host main domain */
|
|
186
|
+
host: string;
|
|
187
|
+
host_icon?: string;
|
|
188
|
+
/** Max chunks allowed */
|
|
189
|
+
chunks: number;
|
|
190
|
+
/** Disable / enable CRC check */
|
|
191
|
+
crc: number;
|
|
192
|
+
/** Generated (direct) link */
|
|
193
|
+
download: string;
|
|
194
|
+
/** Is the file streamable on the website */
|
|
195
|
+
streamable: 0 | 1;
|
|
196
|
+
/** Type of the file (in general, its quality) — multi-link results only */
|
|
197
|
+
type?: string;
|
|
198
|
+
/** Other qualities — multi-link results only (e.g. YouTube) */
|
|
199
|
+
alternative?: RdAlternativeLink[];
|
|
200
|
+
}
|
|
201
|
+
interface RdLinkCheck {
|
|
202
|
+
/** Host main domain */
|
|
203
|
+
host: string;
|
|
204
|
+
link: string;
|
|
205
|
+
filename: string;
|
|
206
|
+
filesize: number;
|
|
207
|
+
supported: 0 | 1;
|
|
208
|
+
}
|
|
209
|
+
interface RdTrafficEntry {
|
|
210
|
+
/** Available bytes / links to use */
|
|
211
|
+
left: number;
|
|
212
|
+
/** Bytes downloaded */
|
|
213
|
+
bytes: number;
|
|
214
|
+
/** Links unrestricted */
|
|
215
|
+
links: number;
|
|
216
|
+
limit: number;
|
|
217
|
+
type: 'links' | 'gigabytes' | 'bytes';
|
|
218
|
+
/** Additional traffic / links the user may have bought */
|
|
219
|
+
extra: number;
|
|
220
|
+
reset: 'daily' | 'weekly' | 'monthly';
|
|
221
|
+
}
|
|
222
|
+
/** Host main domain → traffic info */
|
|
223
|
+
type RdTraffic = Record<string, RdTrafficEntry>;
|
|
224
|
+
interface RdTrafficDay {
|
|
225
|
+
/** Host main domain → bytes downloaded on that host */
|
|
226
|
+
host: Record<string, number>;
|
|
227
|
+
/** Total bytes downloaded that day */
|
|
228
|
+
bytes: number;
|
|
229
|
+
}
|
|
230
|
+
/** `YYYY-MM-DD` → traffic of that day */
|
|
231
|
+
type RdTrafficDetails = Record<string, RdTrafficDay>;
|
|
232
|
+
/** Quality name → stream URL */
|
|
233
|
+
type RdTranscodeQualities = Record<string, string>;
|
|
234
|
+
interface RdTranscodeStreams {
|
|
235
|
+
/** M3U8 live streaming */
|
|
236
|
+
apple?: RdTranscodeQualities;
|
|
237
|
+
/** MPD live streaming */
|
|
238
|
+
dash?: RdTranscodeQualities;
|
|
239
|
+
liveMP4?: RdTranscodeQualities;
|
|
240
|
+
h264WebM?: RdTranscodeQualities;
|
|
241
|
+
}
|
|
242
|
+
interface RdMediaVideoStream {
|
|
243
|
+
stream: string;
|
|
244
|
+
lang: string;
|
|
245
|
+
lang_iso: string;
|
|
246
|
+
codec: string;
|
|
247
|
+
colorspace: string;
|
|
248
|
+
width: number;
|
|
249
|
+
height: number;
|
|
250
|
+
}
|
|
251
|
+
interface RdMediaAudioStream {
|
|
252
|
+
stream: string;
|
|
253
|
+
lang: string;
|
|
254
|
+
lang_iso: string;
|
|
255
|
+
codec: string;
|
|
256
|
+
sampling: number;
|
|
257
|
+
channels: number;
|
|
258
|
+
}
|
|
259
|
+
interface RdMediaSubtitleStream {
|
|
260
|
+
stream: string;
|
|
261
|
+
lang: string;
|
|
262
|
+
lang_iso: string;
|
|
263
|
+
type: string;
|
|
264
|
+
}
|
|
265
|
+
interface RdMediaInfo {
|
|
266
|
+
/** Cleaned filename */
|
|
267
|
+
filename: string;
|
|
268
|
+
hoster: string;
|
|
269
|
+
link: string;
|
|
270
|
+
type: 'movie' | 'show' | 'audio';
|
|
271
|
+
season: string | null;
|
|
272
|
+
episode: string | null;
|
|
273
|
+
year: string | null;
|
|
274
|
+
/** Seconds */
|
|
275
|
+
duration: number;
|
|
276
|
+
bitrate: number;
|
|
277
|
+
/** Original filesize in bytes */
|
|
278
|
+
size: number;
|
|
279
|
+
details: {
|
|
280
|
+
video?: Record<string, RdMediaVideoStream>;
|
|
281
|
+
audio?: Record<string, RdMediaAudioStream>;
|
|
282
|
+
subtitles?: Record<string, RdMediaSubtitleStream> | RdMediaSubtitleStream[];
|
|
283
|
+
};
|
|
284
|
+
poster_path?: string;
|
|
285
|
+
audio_image?: string;
|
|
286
|
+
backdrop_path?: string;
|
|
287
|
+
}
|
|
288
|
+
interface RdDownloadItem {
|
|
289
|
+
id: string;
|
|
290
|
+
filename: string;
|
|
291
|
+
mimeType: string;
|
|
292
|
+
/** Bytes, 0 if unknown */
|
|
293
|
+
filesize: number;
|
|
294
|
+
/** Original link */
|
|
295
|
+
link: string;
|
|
296
|
+
host: string;
|
|
297
|
+
host_icon?: string;
|
|
298
|
+
chunks: number;
|
|
299
|
+
/** Generated (direct) link */
|
|
300
|
+
download: string;
|
|
301
|
+
streamable?: 0 | 1;
|
|
302
|
+
/** jsonDate */
|
|
303
|
+
generated: string;
|
|
304
|
+
type?: string;
|
|
305
|
+
}
|
|
306
|
+
type RdTorrentStatus = 'magnet_error' | 'magnet_conversion' | 'waiting_files_selection' | 'queued' | 'downloading' | 'downloaded' | 'error' | 'virus' | 'compressing' | 'uploading' | 'dead';
|
|
307
|
+
interface RdTorrentFile {
|
|
308
|
+
id: number;
|
|
309
|
+
/** Path inside the torrent, starting with "/" */
|
|
310
|
+
path: string;
|
|
311
|
+
bytes: number;
|
|
312
|
+
selected: 0 | 1;
|
|
313
|
+
}
|
|
314
|
+
/** Item of `GET /torrents`. */
|
|
315
|
+
interface RdTorrent {
|
|
316
|
+
id: string;
|
|
317
|
+
filename: string;
|
|
318
|
+
/** SHA1 hash of the torrent */
|
|
319
|
+
hash: string;
|
|
320
|
+
/** Size of the selected files only */
|
|
321
|
+
bytes: number;
|
|
322
|
+
/** Host main domain */
|
|
323
|
+
host: string;
|
|
324
|
+
/** Split size of links */
|
|
325
|
+
split: number;
|
|
326
|
+
/** 0–100 */
|
|
327
|
+
progress: number;
|
|
328
|
+
status: RdTorrentStatus;
|
|
329
|
+
/** jsonDate */
|
|
330
|
+
added: string;
|
|
331
|
+
/** Hoster links — one per selected file (or archive part) once downloaded */
|
|
332
|
+
links: string[];
|
|
333
|
+
/** jsonDate — only present when finished */
|
|
334
|
+
ended?: string;
|
|
335
|
+
/** Only present in "downloading", "compressing", "uploading" status */
|
|
336
|
+
speed?: number;
|
|
337
|
+
/** Only present in "downloading", "magnet_conversion" status */
|
|
338
|
+
seeders?: number;
|
|
339
|
+
}
|
|
340
|
+
/** `GET /torrents/info/{id}` */
|
|
341
|
+
interface RdTorrentInfo extends RdTorrent {
|
|
342
|
+
original_filename: string;
|
|
343
|
+
/** Total size of the torrent */
|
|
344
|
+
original_bytes: number;
|
|
345
|
+
files: RdTorrentFile[];
|
|
346
|
+
}
|
|
347
|
+
interface RdMagnetAdded {
|
|
348
|
+
id: string;
|
|
349
|
+
/** URL of the created resource */
|
|
350
|
+
uri: string;
|
|
351
|
+
}
|
|
352
|
+
interface RdActiveCount {
|
|
353
|
+
/** Currently active torrents */
|
|
354
|
+
nb: number;
|
|
355
|
+
/** Maximum active torrents allowed */
|
|
356
|
+
limit: number;
|
|
357
|
+
}
|
|
358
|
+
interface RdAvailableHost {
|
|
359
|
+
/** Host main domain */
|
|
360
|
+
host: string;
|
|
361
|
+
/** Max split size possible */
|
|
362
|
+
max_file_size: number;
|
|
363
|
+
}
|
|
364
|
+
/** hash → hoster → file-id variants (file id → file) */
|
|
365
|
+
type RdInstantAvailability = Record<string, Record<string, Array<Record<string, {
|
|
366
|
+
filename: string;
|
|
367
|
+
filesize: number;
|
|
368
|
+
}>>>>;
|
|
369
|
+
interface RdHost {
|
|
370
|
+
id: string;
|
|
371
|
+
name: string;
|
|
372
|
+
/** Icon URL */
|
|
373
|
+
image: string;
|
|
374
|
+
}
|
|
375
|
+
/** Host main domain → host */
|
|
376
|
+
type RdHosts = Record<string, RdHost>;
|
|
377
|
+
type RdHostState = 'up' | 'down' | 'unsupported';
|
|
378
|
+
interface RdHostStatus extends RdHost {
|
|
379
|
+
supported: 0 | 1;
|
|
380
|
+
status: RdHostState;
|
|
381
|
+
/** jsonDate */
|
|
382
|
+
check_time: string;
|
|
383
|
+
/** Competitor domain → status */
|
|
384
|
+
competitors_status: Record<string, {
|
|
385
|
+
status: RdHostState;
|
|
386
|
+
check_time: string;
|
|
387
|
+
}>;
|
|
388
|
+
}
|
|
389
|
+
/** Host main domain → status */
|
|
390
|
+
type RdHostStatuses = Record<string, RdHostStatus>;
|
|
391
|
+
type RdSettingName = 'download_port' | 'locale' | 'streaming_language_preference' | 'streaming_quality' | 'mobile_streaming_quality' | 'streaming_cast_audio_preference';
|
|
392
|
+
interface RdSettings {
|
|
393
|
+
download_ports: string[];
|
|
394
|
+
download_port: string;
|
|
395
|
+
locales: Record<string, string>;
|
|
396
|
+
locale: string;
|
|
397
|
+
streaming_qualities: string[];
|
|
398
|
+
streaming_quality: string;
|
|
399
|
+
mobile_streaming_quality: string;
|
|
400
|
+
streaming_languages: Record<string, string>;
|
|
401
|
+
streaming_language_preference: string;
|
|
402
|
+
streaming_cast_audio: string[];
|
|
403
|
+
streaming_cast_audio_preference: string;
|
|
404
|
+
}
|
|
405
|
+
interface RdDeviceCode {
|
|
406
|
+
device_code: string;
|
|
407
|
+
user_code: string;
|
|
408
|
+
verification_url: string;
|
|
409
|
+
/** Seconds */
|
|
410
|
+
expires_in: number;
|
|
411
|
+
/** Minimum seconds between polls */
|
|
412
|
+
interval: number;
|
|
413
|
+
/** Present on some responses: full URL with the user code pre-filled */
|
|
414
|
+
direct_verification_url?: string;
|
|
415
|
+
}
|
|
416
|
+
/** Client credentials bound to the user (opensource-app flow). */
|
|
417
|
+
interface RdDeviceCredentials {
|
|
418
|
+
client_id: string;
|
|
419
|
+
client_secret: string;
|
|
420
|
+
}
|
|
421
|
+
interface RdTokenResponse {
|
|
422
|
+
access_token: string;
|
|
423
|
+
/** Seconds */
|
|
424
|
+
expires_in: number;
|
|
425
|
+
token_type: 'Bearer';
|
|
426
|
+
/** Only expires when the user revokes the app; use with refreshToken() */
|
|
427
|
+
refresh_token: string;
|
|
428
|
+
}
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/services/real-debrid/real-debrid.d.ts
|
|
431
|
+
/** Public client id RD provides for opensource apps (scopes: unrestrict, torrents, downloads, user) */
|
|
432
|
+
declare const REAL_DEBRID_OPENSOURCE_CLIENT_ID = "X245A4XAIBGVM";
|
|
433
|
+
type RealDebridOptions = ClientOptions;
|
|
434
|
+
/** Pagination for list endpoints — `page` wins over `offset` when both are set. */
|
|
435
|
+
interface RdPagination {
|
|
436
|
+
offset?: number;
|
|
437
|
+
page?: number;
|
|
438
|
+
/** 0–5000, default 100 */
|
|
439
|
+
limit?: number;
|
|
440
|
+
}
|
|
441
|
+
/** Result of a completed device authorization — keep `credentials` to refresh the token later. */
|
|
442
|
+
interface RdDeviceAuthorization {
|
|
443
|
+
credentials: RdDeviceCredentials;
|
|
444
|
+
token: RdTokenResponse;
|
|
445
|
+
}
|
|
446
|
+
declare class RealDebrid extends BaseFetcher implements DebridProvider {
|
|
447
|
+
#private;
|
|
448
|
+
/**
|
|
449
|
+
* @param apiToken Private API token (https://real-debrid.com/apitoken) or an OAuth access token
|
|
450
|
+
*/
|
|
451
|
+
constructor(apiToken: string, options?: RealDebridOptions);
|
|
452
|
+
readonly name = "real-debrid";
|
|
453
|
+
getUser(): Promise<UserInfo>;
|
|
454
|
+
/**
|
|
455
|
+
* `/torrents/instantAvailability` is disabled (error 37), so this probes by
|
|
456
|
+
* adding the magnet and watching the torrent status — a cached torrent
|
|
457
|
+
* reaches `downloaded` as soon as all files are selected. The probe torrent
|
|
458
|
+
* is always deleted afterwards (cleanup errors swallowed).
|
|
459
|
+
*
|
|
460
|
+
* Side effect: briefly adds a torrent (and starts it, for at most a few
|
|
461
|
+
* seconds, when the answer is `false`).
|
|
462
|
+
*/
|
|
463
|
+
isCached(hashOrMagnet: string): Promise<boolean>;
|
|
464
|
+
/**
|
|
465
|
+
* Adds the magnet and fetches its state (one extra GET to fill the shape).
|
|
466
|
+
* Real-Debrid only starts the torrent after {@link selectTorrentFiles}.
|
|
467
|
+
*/
|
|
468
|
+
addMagnet(magnet: string, options?: {
|
|
469
|
+
host?: string;
|
|
470
|
+
}): Promise<Torrent>;
|
|
471
|
+
listTorrents(offset?: number, limit?: number): Promise<Torrent[]>;
|
|
472
|
+
/** Unrestricts every host link of a downloaded torrent into direct links. */
|
|
473
|
+
getDownloadLinks(torrentId: string): Promise<DownloadLink[]>;
|
|
474
|
+
/** This instance as the provider-agnostic {@link DebridProvider}. */
|
|
475
|
+
toProvider(): DebridProvider;
|
|
476
|
+
/** GET /disable_access_token — revokes the token this client uses. */
|
|
477
|
+
disableAccessToken(): Promise<void>;
|
|
478
|
+
/** GET /time — server time as raw text (`Y-m-d H:i:s`), no auth required. */
|
|
479
|
+
getServerTime(): Promise<string>;
|
|
480
|
+
/** GET /time/iso — server time as raw ISO text (`Y-m-dTH:i:sO`), no auth required. */
|
|
481
|
+
getServerTimeIso(): Promise<string>;
|
|
482
|
+
/** GET /user — full wire response. */
|
|
483
|
+
getUserRaw(): Promise<RdUser>;
|
|
484
|
+
/** POST /unrestrict/check — whether a file is downloadable on its hoster (no auth needed). */
|
|
485
|
+
checkLink(link: string, password?: string): Promise<RdLinkCheck>;
|
|
486
|
+
/** POST /unrestrict/link — returns an array for multi-file hosts (e.g. YouTube). */
|
|
487
|
+
unrestrictLink(link: string, options?: {
|
|
488
|
+
password?: string;
|
|
489
|
+
remote?: boolean;
|
|
490
|
+
}): Promise<RdUnrestrictedLink | RdUnrestrictedLink[]>;
|
|
491
|
+
/** POST /unrestrict/folder — individual links inside a hoster folder (empty if none). */
|
|
492
|
+
unrestrictFolder(link: string): Promise<string[]>;
|
|
493
|
+
/** PUT /unrestrict/containerFile — decrypt a RSDF/CCF/CCF3/DLC container (raw file body). */
|
|
494
|
+
unrestrictContainerFile(file: FileInput): Promise<string[]>;
|
|
495
|
+
/** POST /unrestrict/containerLink — decrypt a remote container file. */
|
|
496
|
+
unrestrictContainerLink(link: string): Promise<string[]>;
|
|
497
|
+
/** GET /traffic — limits and usage for limited hosters. */
|
|
498
|
+
getTraffic(): Promise<RdTraffic>;
|
|
499
|
+
/** GET /traffic/details — per-day, per-host usage (`YYYY-MM-DD`, max 31 days, default last week). */
|
|
500
|
+
getTrafficDetails(period?: {
|
|
501
|
+
start?: string;
|
|
502
|
+
end?: string;
|
|
503
|
+
}): Promise<RdTrafficDetails>;
|
|
504
|
+
/** GET /streaming/transcode/{id} — transcode URLs ({id} from downloads or unrestrict). */
|
|
505
|
+
getTranscodeStreams(linkId: string): Promise<RdTranscodeStreams>;
|
|
506
|
+
/** GET /streaming/mediaInfos/{id} — detailed media metadata. */
|
|
507
|
+
getMediaInfo(linkId: string): Promise<RdMediaInfo>;
|
|
508
|
+
/** GET /downloads — unrestricted downloads history. */
|
|
509
|
+
listDownloads(pagination?: RdPagination): Promise<RdDownloadItem[]>;
|
|
510
|
+
/** DELETE /downloads/delete/{id} */
|
|
511
|
+
deleteDownload(downloadId: string): Promise<void>;
|
|
512
|
+
/** GET /torrents — raw wire list. `filter: 'active'` lists active torrents only. */
|
|
513
|
+
listTorrentsRaw(params?: RdPagination & {
|
|
514
|
+
filter?: 'active';
|
|
515
|
+
}): Promise<RdTorrent[]>;
|
|
516
|
+
/** GET /torrents/info/{id} — raw wire response. */
|
|
517
|
+
getTorrentInfo(torrentId: string): Promise<RdTorrentInfo>;
|
|
518
|
+
/** GET /torrents/info/{id} — mapped to the unified Torrent shape. */
|
|
519
|
+
getTorrent(torrentId: string): Promise<Torrent>;
|
|
520
|
+
/**
|
|
521
|
+
* GET /torrents/instantAvailability/{hash}/{hash}… — note that Real-Debrid
|
|
522
|
+
* has disabled this endpoint (error 37, "Disabled endpoint"); use
|
|
523
|
+
* {@link isCached} instead.
|
|
524
|
+
*/
|
|
525
|
+
getInstantAvailability(hashes: string[]): Promise<RdInstantAvailability>;
|
|
526
|
+
/** GET /torrents/activeCount */
|
|
527
|
+
getActiveTorrentCount(): Promise<RdActiveCount>;
|
|
528
|
+
/** GET /torrents/availableHosts — hosts a torrent can be uploaded to. */
|
|
529
|
+
getAvailableTorrentHosts(): Promise<RdAvailableHost[]>;
|
|
530
|
+
/** POST /torrents/addMagnet — raw wire response ({ id, uri }). */
|
|
531
|
+
addMagnetRaw(magnet: string, options?: {
|
|
532
|
+
host?: string;
|
|
533
|
+
}): Promise<RdMagnetAdded>;
|
|
534
|
+
/** PUT /torrents/addTorrent — upload a .torrent file (raw body, `host` as query param). */
|
|
535
|
+
addTorrentFile(file: FileInput, options?: {
|
|
536
|
+
host?: string;
|
|
537
|
+
}): Promise<RdMagnetAdded>;
|
|
538
|
+
/** POST /torrents/selectFiles/{id} — `fileIds` are from getTorrentInfo(); 'all' selects everything. */
|
|
539
|
+
selectTorrentFiles(torrentId: string, fileIds: number[] | 'all'): Promise<void>;
|
|
540
|
+
/** DELETE /torrents/delete/{id} */
|
|
541
|
+
deleteTorrent(torrentId: string): Promise<void>;
|
|
542
|
+
/** GET /hosts — supported hosts (no auth). */
|
|
543
|
+
getHosts(): Promise<RdHosts>;
|
|
544
|
+
/** GET /hosts/status — host status, including on competitors. */
|
|
545
|
+
getHostStatuses(): Promise<RdHostStatuses>;
|
|
546
|
+
/** GET /hosts/regex — supported link regexes (no auth). */
|
|
547
|
+
getHostRegexes(): Promise<string[]>;
|
|
548
|
+
/** GET /hosts/regexFolder — supported folder-link regexes (no auth). */
|
|
549
|
+
getHostFolderRegexes(): Promise<string[]>;
|
|
550
|
+
/** GET /hosts/domains — supported hoster domains (no auth). */
|
|
551
|
+
getHostDomains(): Promise<string[]>;
|
|
552
|
+
/** GET /settings — current settings and their possible values. */
|
|
553
|
+
getSettings(): Promise<RdSettings>;
|
|
554
|
+
/** POST /settings/update — possible values are listed by getSettings(). */
|
|
555
|
+
updateSetting(name: RdSettingName, value: string): Promise<void>;
|
|
556
|
+
/** POST /settings/convertPoints — convert fidelity points. */
|
|
557
|
+
convertPoints(): Promise<void>;
|
|
558
|
+
/** POST /settings/changePassword — sends the verification email. */
|
|
559
|
+
requestPasswordChange(): Promise<void>;
|
|
560
|
+
/** PUT /settings/avatarFile — upload an avatar image (raw body). */
|
|
561
|
+
uploadAvatar(file: FileInput): Promise<void>;
|
|
562
|
+
/** DELETE /settings/avatarDelete — reset the avatar to default. */
|
|
563
|
+
deleteAvatar(): Promise<void>;
|
|
564
|
+
/** Builds the /auth redirect URL — step 1 of the three-legged (website) flow. */
|
|
565
|
+
static getAuthorizeUrl(params: {
|
|
566
|
+
clientId: string;
|
|
567
|
+
redirectUri: string;
|
|
568
|
+
state?: string;
|
|
569
|
+
}): string;
|
|
570
|
+
/** POST /token — exchange the authorization code from the redirect. */
|
|
571
|
+
static exchangeCode(params: {
|
|
572
|
+
clientId: string;
|
|
573
|
+
clientSecret: string;
|
|
574
|
+
code: string;
|
|
575
|
+
redirectUri: string;
|
|
576
|
+
} & ClientOptions): Promise<RdTokenResponse>;
|
|
577
|
+
/**
|
|
578
|
+
* GET /device/code — start the device flow. Pass `newCredentials: true`
|
|
579
|
+
* (opensource apps, no client secret) to get user-bound credentials later.
|
|
580
|
+
*/
|
|
581
|
+
static getDeviceCode(clientId?: string, options?: {
|
|
582
|
+
newCredentials?: boolean;
|
|
583
|
+
} & ClientOptions): Promise<RdDeviceCode>;
|
|
584
|
+
/** GET /device/credentials — single poll; throws until the user approves the device. */
|
|
585
|
+
static getDeviceCredentials(params: {
|
|
586
|
+
clientId?: string;
|
|
587
|
+
deviceCode: string;
|
|
588
|
+
} & ClientOptions): Promise<RdDeviceCredentials>;
|
|
589
|
+
/** POST /token (device grant) — single poll; throws until the user approves the device. */
|
|
590
|
+
static getDeviceToken(params: {
|
|
591
|
+
clientId: string;
|
|
592
|
+
clientSecret: string;
|
|
593
|
+
deviceCode: string;
|
|
594
|
+
} & ClientOptions): Promise<RdTokenResponse>;
|
|
595
|
+
/**
|
|
596
|
+
* Polls until the user approves the device code (or it expires), honoring
|
|
597
|
+
* the interval from {@link getDeviceCode}.
|
|
598
|
+
*
|
|
599
|
+
* - With `clientSecret` (your own app): polls the token endpoint directly.
|
|
600
|
+
* - Without it (opensource flow, device code requested with
|
|
601
|
+
* `newCredentials: true`): polls /device/credentials for user-bound
|
|
602
|
+
* credentials, then exchanges them for a token.
|
|
603
|
+
*
|
|
604
|
+
* Keep the returned `credentials` + `token.refresh_token` to call
|
|
605
|
+
* {@link refreshToken} later.
|
|
606
|
+
*/
|
|
607
|
+
static waitForDeviceToken(params: {
|
|
608
|
+
deviceCode: string;
|
|
609
|
+
clientId?: string;
|
|
610
|
+
clientSecret?: string;
|
|
611
|
+
/** Seconds, from getDeviceCode() */
|
|
612
|
+
expiresIn?: number;
|
|
613
|
+
/** Seconds, from getDeviceCode() */
|
|
614
|
+
interval?: number;
|
|
615
|
+
} & ClientOptions): Promise<RdDeviceAuthorization>;
|
|
616
|
+
/** POST /token — new access token from a refresh token (uses the device grant type). */
|
|
617
|
+
static refreshToken(params: {
|
|
618
|
+
clientId: string;
|
|
619
|
+
clientSecret: string;
|
|
620
|
+
refreshToken: string;
|
|
621
|
+
} & ClientOptions): Promise<RdTokenResponse>;
|
|
622
|
+
/** POST /token — grant_type=password (needs special authorization on the client id). */
|
|
623
|
+
static getTokenWithPassword(params: {
|
|
624
|
+
clientId: string;
|
|
625
|
+
username: string;
|
|
626
|
+
password: string;
|
|
627
|
+
} & ClientOptions): Promise<RdTokenResponse>;
|
|
628
|
+
}
|
|
629
|
+
//#endregion
|
|
630
|
+
//#region src/services/all-debrid/types.d.ts
|
|
631
|
+
/**
|
|
632
|
+
* AllDebrid API v4 wire types — field names exactly as documented at
|
|
633
|
+
* https://docs.alldebrid.com/ (including quirks like `preferedDomain`).
|
|
634
|
+
*/
|
|
635
|
+
/** Every AllDebrid response: success → { status, data }, error → { status, error }. */
|
|
636
|
+
interface AdEnvelope<T = unknown> {
|
|
637
|
+
status: 'success' | 'error';
|
|
638
|
+
data?: T;
|
|
639
|
+
error?: AdItemError;
|
|
640
|
+
}
|
|
641
|
+
/** Error object, both top-level (`error`) and embedded in per-item results. */
|
|
642
|
+
interface AdItemError {
|
|
643
|
+
code: string;
|
|
644
|
+
message: string;
|
|
645
|
+
/** AUTH_BLOCKED only: verification token for verifyEmail() / resendVerification() */
|
|
646
|
+
token?: string;
|
|
647
|
+
}
|
|
648
|
+
interface AdPing {
|
|
649
|
+
ping: string;
|
|
650
|
+
}
|
|
651
|
+
interface AdPinGet {
|
|
652
|
+
/** PIN the user must submit at user_url */
|
|
653
|
+
pin: string;
|
|
654
|
+
/** Token to poll /v4/pin/check with */
|
|
655
|
+
check: string;
|
|
656
|
+
/** Seconds before the PIN expires */
|
|
657
|
+
expires_in: number;
|
|
658
|
+
/** Where the user enters the PIN */
|
|
659
|
+
user_url: string;
|
|
660
|
+
base_url: string;
|
|
661
|
+
}
|
|
662
|
+
interface AdPinCheck {
|
|
663
|
+
activated: boolean;
|
|
664
|
+
/** Seconds left before the check token expires */
|
|
665
|
+
expires_in: number;
|
|
666
|
+
/** Apikey — present once the user has validated the PIN */
|
|
667
|
+
apikey?: string;
|
|
668
|
+
}
|
|
669
|
+
interface AdHostInfo {
|
|
670
|
+
name: string;
|
|
671
|
+
type?: string;
|
|
672
|
+
domains?: string[];
|
|
673
|
+
regexps?: string[];
|
|
674
|
+
[key: string]: unknown;
|
|
675
|
+
}
|
|
676
|
+
interface AdHostsData {
|
|
677
|
+
hosts: Record<string, AdHostInfo>;
|
|
678
|
+
streams: Record<string, AdHostInfo>;
|
|
679
|
+
redirectors: Record<string, AdHostInfo>;
|
|
680
|
+
}
|
|
681
|
+
interface AdHostDomainsData {
|
|
682
|
+
hosts: string[];
|
|
683
|
+
streams: string[];
|
|
684
|
+
redirectors: string[];
|
|
685
|
+
}
|
|
686
|
+
interface AdHostPrioritiesData {
|
|
687
|
+
hosts: Record<string, number>;
|
|
688
|
+
}
|
|
689
|
+
interface AdUserInfo {
|
|
690
|
+
username: string;
|
|
691
|
+
email: string;
|
|
692
|
+
isPremium: boolean;
|
|
693
|
+
isSubscribed: boolean;
|
|
694
|
+
isTrial: boolean;
|
|
695
|
+
/** Unix timestamp (seconds); 0 if the user is not premium */
|
|
696
|
+
premiumUntil: number | string;
|
|
697
|
+
lang: string;
|
|
698
|
+
preferedDomain: string;
|
|
699
|
+
fidelityPoints: number;
|
|
700
|
+
limitedHostersQuotas?: Record<string, number>;
|
|
701
|
+
notifications?: string[];
|
|
702
|
+
remainingTrialQuota?: number;
|
|
703
|
+
}
|
|
704
|
+
interface AdUserData {
|
|
705
|
+
user: AdUserInfo;
|
|
706
|
+
}
|
|
707
|
+
interface AdUserHost {
|
|
708
|
+
name: string;
|
|
709
|
+
type?: 'premium' | 'free';
|
|
710
|
+
domains?: string[];
|
|
711
|
+
regexps?: string[];
|
|
712
|
+
/** Working on AllDebrid in the last ~5 minutes (only tested on some hosts) */
|
|
713
|
+
status?: boolean;
|
|
714
|
+
quota?: number;
|
|
715
|
+
quotaMax?: number;
|
|
716
|
+
/** "traffic" = MB left, "nb_download" = downloads left */
|
|
717
|
+
quotaType?: 'traffic' | 'nb_download';
|
|
718
|
+
limitSimuDl?: number;
|
|
719
|
+
[key: string]: unknown;
|
|
720
|
+
}
|
|
721
|
+
interface AdUserHostsData {
|
|
722
|
+
hosts: Record<string, AdUserHost>;
|
|
723
|
+
}
|
|
724
|
+
interface AdVerif {
|
|
725
|
+
verif: 'waiting' | 'allowed' | 'denied';
|
|
726
|
+
resendable?: boolean;
|
|
727
|
+
apikey?: string;
|
|
728
|
+
}
|
|
729
|
+
interface AdVerifResend {
|
|
730
|
+
sent: boolean;
|
|
731
|
+
}
|
|
732
|
+
interface AdUserLink {
|
|
733
|
+
link: string;
|
|
734
|
+
filename: string;
|
|
735
|
+
size: number;
|
|
736
|
+
date: number;
|
|
737
|
+
host: string;
|
|
738
|
+
}
|
|
739
|
+
interface AdUserLinksData {
|
|
740
|
+
links: AdUserLink[];
|
|
741
|
+
}
|
|
742
|
+
interface AdLinkInfo {
|
|
743
|
+
link?: string;
|
|
744
|
+
filename?: string;
|
|
745
|
+
size?: number;
|
|
746
|
+
host?: string;
|
|
747
|
+
hostDomain?: string;
|
|
748
|
+
error?: AdItemError;
|
|
749
|
+
}
|
|
750
|
+
interface AdLinkInfosData {
|
|
751
|
+
infos: AdLinkInfo[];
|
|
752
|
+
}
|
|
753
|
+
interface AdRedirectorData {
|
|
754
|
+
links: string[];
|
|
755
|
+
}
|
|
756
|
+
interface AdStreamQuality {
|
|
757
|
+
/** Stream id for /link/streaming */
|
|
758
|
+
id: string;
|
|
759
|
+
ext: string;
|
|
760
|
+
/** e.g. 1080, 720 or "mp3" */
|
|
761
|
+
quality: number | string;
|
|
762
|
+
filesize: number;
|
|
763
|
+
proto: string;
|
|
764
|
+
name: string;
|
|
765
|
+
/** Audio-only streams: bitrate */
|
|
766
|
+
abr?: number;
|
|
767
|
+
tb?: number;
|
|
768
|
+
}
|
|
769
|
+
interface AdUnlockedLink {
|
|
770
|
+
link: string;
|
|
771
|
+
host: string;
|
|
772
|
+
filename: string;
|
|
773
|
+
paws: boolean;
|
|
774
|
+
filesize: number;
|
|
775
|
+
/** Available stream qualities (ids for /link/streaming) */
|
|
776
|
+
streams?: AdStreamQuality[];
|
|
777
|
+
/** Generation id — pass to /link/streaming */
|
|
778
|
+
id: string;
|
|
779
|
+
hostDomain: string;
|
|
780
|
+
/** Present when the link is delayed — poll getDelayedLink() instead */
|
|
781
|
+
delayed?: number;
|
|
782
|
+
}
|
|
783
|
+
interface AdStreamingLink {
|
|
784
|
+
link?: string;
|
|
785
|
+
filename: string;
|
|
786
|
+
filesize: number;
|
|
787
|
+
delayed?: number;
|
|
788
|
+
}
|
|
789
|
+
interface AdDelayedLink {
|
|
790
|
+
/** 1 processing · 2 ready · 3 error */
|
|
791
|
+
status: 1 | 2 | 3;
|
|
792
|
+
time_left: number;
|
|
793
|
+
/** Present when status === 2 */
|
|
794
|
+
link?: string;
|
|
795
|
+
}
|
|
796
|
+
/** Per-magnet result — on failure only `magnet` and `error` are set. */
|
|
797
|
+
interface AdUploadedMagnet {
|
|
798
|
+
magnet: string;
|
|
799
|
+
name: string;
|
|
800
|
+
id: number;
|
|
801
|
+
hash: string;
|
|
802
|
+
size: number;
|
|
803
|
+
/** Whether the magnet was already available on AllDebrid (cache hit) */
|
|
804
|
+
ready: boolean;
|
|
805
|
+
error?: AdItemError;
|
|
806
|
+
}
|
|
807
|
+
interface AdMagnetUploadData {
|
|
808
|
+
magnets: AdUploadedMagnet[];
|
|
809
|
+
}
|
|
810
|
+
interface AdUploadedFile {
|
|
811
|
+
file: string;
|
|
812
|
+
name: string;
|
|
813
|
+
hash: string;
|
|
814
|
+
id: number;
|
|
815
|
+
size: number;
|
|
816
|
+
ready: boolean;
|
|
817
|
+
error?: AdItemError;
|
|
818
|
+
}
|
|
819
|
+
interface AdMagnetFileUploadData {
|
|
820
|
+
files: AdUploadedFile[];
|
|
821
|
+
}
|
|
822
|
+
type AdMagnetFilter = 'active' | 'ready' | 'expired' | 'error';
|
|
823
|
+
/** Object-literal type (not interface) so it's assignable to Record<string, FormValue>. */
|
|
824
|
+
type AdMagnetStatusParams = {
|
|
825
|
+
/** Single magnet id — omit to list all magnets */
|
|
826
|
+
id?: number;
|
|
827
|
+
status?: AdMagnetFilter;
|
|
828
|
+
/** Live-mode session id */
|
|
829
|
+
session?: number;
|
|
830
|
+
/** Live-mode counter */
|
|
831
|
+
counter?: number;
|
|
832
|
+
};
|
|
833
|
+
/**
|
|
834
|
+
* statusCode table:
|
|
835
|
+
* 0 queued · 1 downloading · 2 compressing/moving · 3 uploading · 4 ready ·
|
|
836
|
+
* 5–15 errors (upload fail, unpack error, not downloaded in 20 min, too big,
|
|
837
|
+
* internal error, >72h download, deleted on hoster, processing failed,
|
|
838
|
+
* tracker error, no peer).
|
|
839
|
+
*/
|
|
840
|
+
interface AdMagnetStatusItem {
|
|
841
|
+
id: number;
|
|
842
|
+
filename: string;
|
|
843
|
+
size: number;
|
|
844
|
+
/** Status in plain English */
|
|
845
|
+
status: string;
|
|
846
|
+
statusCode: number;
|
|
847
|
+
/** Transfer fields — omitted by the API for finished magnets */
|
|
848
|
+
downloaded?: number;
|
|
849
|
+
uploaded?: number;
|
|
850
|
+
seeders?: number;
|
|
851
|
+
downloadSpeed?: number;
|
|
852
|
+
uploadSpeed?: number;
|
|
853
|
+
/** Unix timestamp (seconds) of upload */
|
|
854
|
+
uploadDate: number;
|
|
855
|
+
/** Unix timestamp (seconds) of completion */
|
|
856
|
+
completionDate: number;
|
|
857
|
+
/** Only present when a specific `id` was requested */
|
|
858
|
+
files?: AdMagnetNode[];
|
|
859
|
+
hash?: string;
|
|
860
|
+
}
|
|
861
|
+
interface AdMagnetStatusData {
|
|
862
|
+
magnets: AdMagnetStatusItem[];
|
|
863
|
+
/** Live mode: current counter */
|
|
864
|
+
counter?: number;
|
|
865
|
+
fullsync?: boolean;
|
|
866
|
+
}
|
|
867
|
+
/** Magnet file-tree node: folder → { n, e }, file → { n, s, l }. */
|
|
868
|
+
interface AdMagnetNode {
|
|
869
|
+
n: string;
|
|
870
|
+
/** Filesize (file nodes) */
|
|
871
|
+
s?: number;
|
|
872
|
+
/** Download link (file nodes) */
|
|
873
|
+
l?: string;
|
|
874
|
+
/** Sub-nodes (folder nodes) */
|
|
875
|
+
e?: AdMagnetNode[];
|
|
876
|
+
}
|
|
877
|
+
interface AdMagnetFileEntry {
|
|
878
|
+
/** Returned as a string by the API */
|
|
879
|
+
id: string | number;
|
|
880
|
+
files?: AdMagnetNode[];
|
|
881
|
+
error?: AdItemError;
|
|
882
|
+
}
|
|
883
|
+
interface AdMagnetFilesData {
|
|
884
|
+
magnets: AdMagnetFileEntry[];
|
|
885
|
+
}
|
|
886
|
+
interface AdMagnetRestartData {
|
|
887
|
+
message?: string;
|
|
888
|
+
magnets?: Array<{
|
|
889
|
+
magnet: string | number;
|
|
890
|
+
message?: string;
|
|
891
|
+
error?: AdItemError;
|
|
892
|
+
}>;
|
|
893
|
+
}
|
|
894
|
+
type AdVoucherDuration = 15 | 30 | 90 | 180 | 365;
|
|
895
|
+
interface AdVoucherBalanceData {
|
|
896
|
+
balance: number;
|
|
897
|
+
}
|
|
898
|
+
interface AdVoucherGetData {
|
|
899
|
+
codes: string[];
|
|
900
|
+
/** true when there were not enough vouchers to fulfill the request */
|
|
901
|
+
partialList: boolean;
|
|
902
|
+
}
|
|
903
|
+
interface AdVoucherGenerateData {
|
|
904
|
+
codes: string[];
|
|
905
|
+
pricePerVoucher: number;
|
|
906
|
+
total: number;
|
|
907
|
+
balance: number;
|
|
908
|
+
}
|
|
909
|
+
//#endregion
|
|
910
|
+
//#region src/services/all-debrid/all-debrid.d.ts
|
|
911
|
+
type AllDebridOptions = ClientOptions;
|
|
912
|
+
declare class AllDebrid extends BaseFetcher implements DebridProvider {
|
|
913
|
+
#private;
|
|
914
|
+
/**
|
|
915
|
+
* @param apiKey Apikey from https://alldebrid.com/apikeys/
|
|
916
|
+
*/
|
|
917
|
+
constructor(apiKey: string, options?: AllDebridOptions);
|
|
918
|
+
/** Unwraps the AD `{ status, data | error }` envelope into `data` / DebridError. */
|
|
919
|
+
protected request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
920
|
+
readonly name = "all-debrid";
|
|
921
|
+
getUser(): Promise<UserInfo>;
|
|
922
|
+
/**
|
|
923
|
+
* isCached via the `ready` flag of /magnet/upload ("whether the magnet is
|
|
924
|
+
* already available"). The probe magnet is always deleted afterwards
|
|
925
|
+
* (cleanup errors swallowed).
|
|
926
|
+
*/
|
|
927
|
+
isCached(hashOrMagnet: string): Promise<boolean>;
|
|
928
|
+
/** Uploads the magnet and fetches its full status (one extra POST). */
|
|
929
|
+
addMagnet(magnet: string): Promise<Torrent>;
|
|
930
|
+
/** AD has no server-side pagination for /magnet/status — slice locally. */
|
|
931
|
+
listTorrents(offset?: number, limit?: number): Promise<Torrent[]>;
|
|
932
|
+
/**
|
|
933
|
+
* Direct download links for every file of a ready magnet. The file links
|
|
934
|
+
* from /magnet/files (`https://alldebrid.com/f/…`) are unlocked one by one
|
|
935
|
+
* through /link/unlock (delayed links are awaited).
|
|
936
|
+
*/
|
|
937
|
+
getDownloadLinks(torrentId: string): Promise<DownloadLink[]>;
|
|
938
|
+
/** This instance as the provider-agnostic {@link DebridProvider}. */
|
|
939
|
+
toProvider(): DebridProvider;
|
|
940
|
+
/** GET /v4/ping */
|
|
941
|
+
ping(): Promise<AdPing>;
|
|
942
|
+
/** GET /v4/hosts — supported hosts/streams/redirectors. */
|
|
943
|
+
getHosts(options?: {
|
|
944
|
+
hostsOnly?: boolean;
|
|
945
|
+
}): Promise<AdHostsData>;
|
|
946
|
+
/** GET /v4/hosts/domains — flat domain lists. */
|
|
947
|
+
getHostDomains(): Promise<AdHostDomainsData>;
|
|
948
|
+
/** GET /v4/hosts/priority — host priority order. */
|
|
949
|
+
getHostPriorities(): Promise<AdHostPrioritiesData>;
|
|
950
|
+
/** GET /v4/user — full wire response ({ user }). */
|
|
951
|
+
getUserRaw(): Promise<AdUserData>;
|
|
952
|
+
/** GET /v4.1/user/hosts — per-host quota/status for this account. */
|
|
953
|
+
getUserHosts(): Promise<AdUserHostsData>;
|
|
954
|
+
/** POST /v4/user/verif — email verification token state. */
|
|
955
|
+
verifyEmail(token: string): Promise<AdVerif>;
|
|
956
|
+
/** POST /v4/user/verif/resend */
|
|
957
|
+
resendVerification(token: string): Promise<AdVerifResend>;
|
|
958
|
+
/** POST /v4/user/notification/clear */
|
|
959
|
+
clearNotification(code: string): Promise<{
|
|
960
|
+
message: string;
|
|
961
|
+
}>;
|
|
962
|
+
/** GET /v4/user/links — saved links history. */
|
|
963
|
+
getUserLinks(): Promise<AdUserLinksData>;
|
|
964
|
+
/** POST /v4/user/links/save */
|
|
965
|
+
saveUserLinks(links: string[]): Promise<{
|
|
966
|
+
message: string;
|
|
967
|
+
}>;
|
|
968
|
+
/** POST /v4/user/links/delete */
|
|
969
|
+
deleteUserLinks(links: string[]): Promise<{
|
|
970
|
+
message: string;
|
|
971
|
+
}>;
|
|
972
|
+
/** GET /v4/user/history — recent links (last 3 days; history logging must be enabled in account settings). */
|
|
973
|
+
getUserHistory(): Promise<AdUserLinksData>;
|
|
974
|
+
/** POST /v4/user/history/delete */
|
|
975
|
+
clearUserHistory(): Promise<{
|
|
976
|
+
message: string;
|
|
977
|
+
}>;
|
|
978
|
+
/** POST /v4/link/infos — link metadata without unlocking (per-link errors possible). */
|
|
979
|
+
getLinkInfos(links: string[], password?: string): Promise<AdLinkInfosData>;
|
|
980
|
+
/** POST /v4/link/redirector — resolve a redirector/protection link. */
|
|
981
|
+
getRedirectorLinks(link: string): Promise<AdRedirectorData>;
|
|
982
|
+
/** POST /v4/link/unlock — unlock one hoster link; may return a `delayed` id (see waitForDelayedLink). */
|
|
983
|
+
unlockLink(link: string, password?: string): Promise<AdUnlockedLink>;
|
|
984
|
+
/** POST /v4/link/streaming — stream id/name come from unlockLink().streams. */
|
|
985
|
+
getStreamingLink(id: string, stream: string): Promise<AdStreamingLink>;
|
|
986
|
+
/** POST /v4/link/delayed — poll a delayed link; `link` present when status === 2. */
|
|
987
|
+
getDelayedLink(id: number): Promise<AdDelayedLink>;
|
|
988
|
+
/**
|
|
989
|
+
* Polls /link/delayed (every 5s, as the docs ask) until the link is ready.
|
|
990
|
+
* Throws when generation fails (status 3) or after `timeout` ms.
|
|
991
|
+
*/
|
|
992
|
+
waitForDelayedLink(id: number, options?: {
|
|
993
|
+
interval?: number;
|
|
994
|
+
timeout?: number;
|
|
995
|
+
}): Promise<string>;
|
|
996
|
+
/** POST /v4/magnet/upload — accepts magnet URIs or raw hashes (per-magnet errors possible). */
|
|
997
|
+
uploadMagnets(magnets: string[]): Promise<AdMagnetUploadData>;
|
|
998
|
+
/** POST /v4/magnet/upload/file — upload .torrent file(s) as multipart (`files[]`). */
|
|
999
|
+
uploadMagnetFiles(files: Array<FileInput | {
|
|
1000
|
+
file: FileInput;
|
|
1001
|
+
filename: string;
|
|
1002
|
+
}>): Promise<AdMagnetFileUploadData>;
|
|
1003
|
+
/** POST /v4.1/magnet/status — omit params to list ALL magnets. */
|
|
1004
|
+
getMagnetsStatus(params?: AdMagnetStatusParams): Promise<AdMagnetStatusData>;
|
|
1005
|
+
/** POST /v4.1/magnet/status mapped to the unified Torrent shape. */
|
|
1006
|
+
getTorrent(torrentId: string): Promise<Torrent>;
|
|
1007
|
+
/** POST /v4/magnet/files — file tree (with `/f/` links to unlock) for the given magnet ids. */
|
|
1008
|
+
getMagnetFiles(ids: number[]): Promise<AdMagnetFilesData>;
|
|
1009
|
+
/** POST /v4/magnet/delete */
|
|
1010
|
+
deleteMagnet(id: number): Promise<{
|
|
1011
|
+
message: string;
|
|
1012
|
+
}>;
|
|
1013
|
+
/** POST /v4/magnet/restart — restart one failed magnet, or several at once. */
|
|
1014
|
+
restartMagnets(ids: number | number[]): Promise<AdMagnetRestartData>;
|
|
1015
|
+
/** GET /v4/voucher/balance */
|
|
1016
|
+
getVoucherBalance(): Promise<AdVoucherBalanceData>;
|
|
1017
|
+
/** POST /v4/voucher/get — reserve vouchers from stock. */
|
|
1018
|
+
getVouchers(duration: AdVoucherDuration, nb: number): Promise<AdVoucherGetData>;
|
|
1019
|
+
/** POST /v4/voucher/generate — buy vouchers from balance. */
|
|
1020
|
+
generateVouchers(duration: AdVoucherDuration, nb: number): Promise<AdVoucherGenerateData>;
|
|
1021
|
+
/** GET /v4.1/pin/get — start the PIN flow: show `user_url` (or `pin`), then poll. */
|
|
1022
|
+
static getPin(options?: ClientOptions): Promise<AdPinGet>;
|
|
1023
|
+
/** POST /v4/pin/check — single poll; `apikey` is present once the user submitted the PIN. */
|
|
1024
|
+
static checkPin(params: {
|
|
1025
|
+
check: string;
|
|
1026
|
+
pin: string;
|
|
1027
|
+
} & ClientOptions): Promise<AdPinCheck>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Polls /pin/check every `interval` seconds (default 5) until the user
|
|
1030
|
+
* submits the PIN; resolves with the apikey. Throws PIN_EXPIRED on expiry.
|
|
1031
|
+
*/
|
|
1032
|
+
static waitForPin(params: {
|
|
1033
|
+
check: string;
|
|
1034
|
+
pin: string;
|
|
1035
|
+
interval?: number;
|
|
1036
|
+
} & ClientOptions): Promise<string>;
|
|
1037
|
+
}
|
|
1038
|
+
//#endregion
|
|
1039
|
+
//#region src/services/premiumize/types.d.ts
|
|
1040
|
+
/**
|
|
1041
|
+
* Premiumize.me API wire types — field names exactly as documented at
|
|
1042
|
+
* https://www.premiumize.me/api (deprecated fields intentionally omitted).
|
|
1043
|
+
*/
|
|
1044
|
+
/** Every successful response carries `status`; errors use {@link PmErrorBody}. */
|
|
1045
|
+
interface PmResponse {
|
|
1046
|
+
status: 'success';
|
|
1047
|
+
}
|
|
1048
|
+
/** Error shape any endpoint may return instead of its success payload (HTTP 200). */
|
|
1049
|
+
interface PmErrorBody {
|
|
1050
|
+
status: 'error';
|
|
1051
|
+
message: string;
|
|
1052
|
+
/** Stable code, e.g. "not_found" / "authentication_failed" */
|
|
1053
|
+
code: string;
|
|
1054
|
+
}
|
|
1055
|
+
/** Bare `{ status: "success" }` — rename/delete/paste/retry/clearfinished. */
|
|
1056
|
+
type PmSuccess = PmResponse;
|
|
1057
|
+
interface PmAccountInfo extends PmResponse {
|
|
1058
|
+
/** Public-facing account identifier */
|
|
1059
|
+
customer_id: string;
|
|
1060
|
+
/** Unix timestamp (seconds); null for free accounts */
|
|
1061
|
+
premium_until: number | null;
|
|
1062
|
+
/** Fair-use fraction in [0, 1] */
|
|
1063
|
+
limit_used: number;
|
|
1064
|
+
booster_points: number;
|
|
1065
|
+
}
|
|
1066
|
+
interface PmBreadcrumb {
|
|
1067
|
+
id: string;
|
|
1068
|
+
name: string;
|
|
1069
|
+
}
|
|
1070
|
+
interface PmFolderEntry {
|
|
1071
|
+
id: string;
|
|
1072
|
+
name: string;
|
|
1073
|
+
type: 'folder';
|
|
1074
|
+
created_at: number;
|
|
1075
|
+
}
|
|
1076
|
+
interface PmFileEntry {
|
|
1077
|
+
id: string;
|
|
1078
|
+
name: string;
|
|
1079
|
+
type: 'file';
|
|
1080
|
+
created_at: number;
|
|
1081
|
+
size: number;
|
|
1082
|
+
mime_type: string;
|
|
1083
|
+
/** CDN download URL */
|
|
1084
|
+
link: string;
|
|
1085
|
+
}
|
|
1086
|
+
type PmContentEntry = PmFolderEntry | PmFileEntry;
|
|
1087
|
+
/** Object-literal type (not interface) so it's assignable to Record<string, QueryValue>. */
|
|
1088
|
+
type PmFolderListParams = {
|
|
1089
|
+
/** Folder id; omit for the root folder */
|
|
1090
|
+
id?: string;
|
|
1091
|
+
/** Alternative to `id` */
|
|
1092
|
+
path?: string;
|
|
1093
|
+
/** Include the parent folder chain, root first */
|
|
1094
|
+
includebreadcrumbs?: boolean;
|
|
1095
|
+
};
|
|
1096
|
+
interface PmFolderList extends PmResponse {
|
|
1097
|
+
name: string;
|
|
1098
|
+
parent_id: string | null;
|
|
1099
|
+
folder_id: string;
|
|
1100
|
+
/** Only present when includebreadcrumbs=true */
|
|
1101
|
+
breadcrumbs?: PmBreadcrumb[];
|
|
1102
|
+
content: PmContentEntry[];
|
|
1103
|
+
}
|
|
1104
|
+
interface PmFolderCreate extends PmResponse {
|
|
1105
|
+
id: string;
|
|
1106
|
+
}
|
|
1107
|
+
interface PmUploadInfo extends PmResponse {
|
|
1108
|
+
/** Single-use upload token */
|
|
1109
|
+
token: string;
|
|
1110
|
+
/** Where to POST the multipart upload */
|
|
1111
|
+
url: string;
|
|
1112
|
+
}
|
|
1113
|
+
interface PmSearchResults extends PmResponse {
|
|
1114
|
+
name: string;
|
|
1115
|
+
content: PmContentEntry[];
|
|
1116
|
+
}
|
|
1117
|
+
interface PmItemDetails extends PmResponse {
|
|
1118
|
+
id: string;
|
|
1119
|
+
name: string;
|
|
1120
|
+
size: number;
|
|
1121
|
+
created_at: number;
|
|
1122
|
+
folder_id: string;
|
|
1123
|
+
mime_type: string;
|
|
1124
|
+
link: string;
|
|
1125
|
+
}
|
|
1126
|
+
interface PmListedFile {
|
|
1127
|
+
id: string;
|
|
1128
|
+
name: string;
|
|
1129
|
+
/** Slash-joined path from the root folder */
|
|
1130
|
+
path: string;
|
|
1131
|
+
size: number;
|
|
1132
|
+
created_at: number;
|
|
1133
|
+
mime_type: string;
|
|
1134
|
+
}
|
|
1135
|
+
interface PmItemListAll extends PmResponse {
|
|
1136
|
+
files: PmListedFile[];
|
|
1137
|
+
}
|
|
1138
|
+
/** `seeding` = torrent finished downloading, files already available. */
|
|
1139
|
+
type PmTransferStatus = 'queued' | 'running' | 'finished' | 'seeding' | 'error';
|
|
1140
|
+
interface PmTransfer {
|
|
1141
|
+
id: string;
|
|
1142
|
+
name: string;
|
|
1143
|
+
status: PmTransferStatus;
|
|
1144
|
+
/** 0.0–1.0 */
|
|
1145
|
+
progress: number;
|
|
1146
|
+
/** Free-form status text, empty when there's nothing to say */
|
|
1147
|
+
message: string;
|
|
1148
|
+
/** Target folder once finished; null while queued/running/error */
|
|
1149
|
+
folder_id: string | null;
|
|
1150
|
+
/** Resulting file; null for multi-file sources and while in progress */
|
|
1151
|
+
file_id: string | null;
|
|
1152
|
+
/** Unix timestamp (seconds) of creation */
|
|
1153
|
+
created_at?: number;
|
|
1154
|
+
}
|
|
1155
|
+
interface PmTransferList extends PmResponse {
|
|
1156
|
+
/** Active, queued, finished and errored — newest first */
|
|
1157
|
+
transfers: PmTransfer[];
|
|
1158
|
+
}
|
|
1159
|
+
interface PmTransferCreated extends PmResponse {
|
|
1160
|
+
id: string;
|
|
1161
|
+
name: string;
|
|
1162
|
+
}
|
|
1163
|
+
/** Returned when `src` is a .dlc/.ccf/.rsdf container — submit `content` one by one. */
|
|
1164
|
+
interface PmTransferContainer extends PmResponse {
|
|
1165
|
+
type: 'container';
|
|
1166
|
+
content: string[];
|
|
1167
|
+
}
|
|
1168
|
+
type PmTransferCreateResult = PmTransferCreated | PmTransferContainer;
|
|
1169
|
+
interface PmDirectDlContent {
|
|
1170
|
+
/** Slash-joined path inside the source */
|
|
1171
|
+
path: string;
|
|
1172
|
+
size: number;
|
|
1173
|
+
link: string;
|
|
1174
|
+
}
|
|
1175
|
+
interface PmDirectDl extends PmResponse {
|
|
1176
|
+
content: PmDirectDlContent[];
|
|
1177
|
+
}
|
|
1178
|
+
interface PmCacheCheck extends PmResponse {
|
|
1179
|
+
/** Parallel arrays, indexed by request order */
|
|
1180
|
+
response: boolean[];
|
|
1181
|
+
filename: Array<string | null>;
|
|
1182
|
+
filesize: Array<string | number>;
|
|
1183
|
+
}
|
|
1184
|
+
interface PmServicesList extends PmResponse {
|
|
1185
|
+
/** Services whose links can be checked with /cache/check */
|
|
1186
|
+
cache: string[];
|
|
1187
|
+
/** Services accepted by /transfer/directdl */
|
|
1188
|
+
directdl: string[];
|
|
1189
|
+
/** Services accepted by /transfer/create */
|
|
1190
|
+
queue: string[];
|
|
1191
|
+
/** Fair-use multiplier per service */
|
|
1192
|
+
fairusefactor: Record<string, number>;
|
|
1193
|
+
aliases: Record<string, string[]>;
|
|
1194
|
+
regexpatterns: Record<string, string[]>;
|
|
1195
|
+
}
|
|
1196
|
+
interface PmZipGenerate extends PmResponse {
|
|
1197
|
+
/** Downloadable immediately; the filename is encoded in the URL path */
|
|
1198
|
+
location: string;
|
|
1199
|
+
}
|
|
1200
|
+
/** POST /token with response_type=device_code */
|
|
1201
|
+
interface PmDeviceCode {
|
|
1202
|
+
verification_uri: string;
|
|
1203
|
+
/** Short `xxxx-xxxx` code the user types at verification_uri */
|
|
1204
|
+
user_code: string;
|
|
1205
|
+
device_code: string;
|
|
1206
|
+
expires_in: number;
|
|
1207
|
+
/** Minimum seconds between polls */
|
|
1208
|
+
interval: number;
|
|
1209
|
+
}
|
|
1210
|
+
interface PmTokenResponse {
|
|
1211
|
+
access_token: string;
|
|
1212
|
+
token_type: 'Bearer';
|
|
1213
|
+
expires_in: number;
|
|
1214
|
+
/** The only scope is "full" */
|
|
1215
|
+
scope: string;
|
|
1216
|
+
/** Issued by some grants (e.g. authorization code with PKCE) */
|
|
1217
|
+
refresh_token?: string;
|
|
1218
|
+
}
|
|
1219
|
+
/** Pending/failed polls come back as HTTP 400 with this body. */
|
|
1220
|
+
interface PmOAuthError {
|
|
1221
|
+
error: string;
|
|
1222
|
+
error_description?: string;
|
|
1223
|
+
}
|
|
1224
|
+
//#endregion
|
|
1225
|
+
//#region src/services/premiumize/premiumize.d.ts
|
|
1226
|
+
type PremiumizeOptions = ClientOptions;
|
|
1227
|
+
declare class Premiumize extends BaseFetcher implements DebridProvider {
|
|
1228
|
+
#private;
|
|
1229
|
+
/**
|
|
1230
|
+
* @param apiKey Apikey from https://www.premiumize.me/account (or an OAuth access token)
|
|
1231
|
+
*/
|
|
1232
|
+
constructor(apiKey: string, options?: PremiumizeOptions);
|
|
1233
|
+
/** Throws on `{ status: "error" }`, otherwise returns the body as-is. */
|
|
1234
|
+
protected request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
1235
|
+
readonly name = "premiumize";
|
|
1236
|
+
getUser(): Promise<UserInfo>;
|
|
1237
|
+
/**
|
|
1238
|
+
* Real cache check — unlike Real-Debrid/AllDebrid this needs no probe
|
|
1239
|
+
* torrent, so there is nothing to add or clean up.
|
|
1240
|
+
*/
|
|
1241
|
+
isCached(hashOrMagnet: string): Promise<boolean>;
|
|
1242
|
+
/** Creates the transfer and fetches its state (one extra GET to fill the shape). */
|
|
1243
|
+
addMagnet(magnet: string): Promise<Torrent>;
|
|
1244
|
+
/** /transfer/list has no server-side pagination — slice locally. */
|
|
1245
|
+
listTorrents(offset?: number, limit?: number): Promise<Torrent[]>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Direct links for a finished transfer: a single-file source resolves to its
|
|
1248
|
+
* item, a multi-file source to the whole resulting folder tree.
|
|
1249
|
+
*/
|
|
1250
|
+
getDownloadLinks(torrentId: string): Promise<DownloadLink[]>;
|
|
1251
|
+
/** This instance as the provider-agnostic {@link DebridProvider}. */
|
|
1252
|
+
toProvider(): DebridProvider;
|
|
1253
|
+
/** GET /account/info */
|
|
1254
|
+
getAccountInfo(): Promise<PmAccountInfo>;
|
|
1255
|
+
/** GET /folder/list — root folder when neither `id` nor `path` is passed. */
|
|
1256
|
+
listFolder(params?: PmFolderListParams): Promise<PmFolderList>;
|
|
1257
|
+
/** POST /folder/create — `parentId` defaults to root. */
|
|
1258
|
+
createFolder(name: string, parentId?: string): Promise<PmFolderCreate>;
|
|
1259
|
+
/** POST /folder/rename */
|
|
1260
|
+
renameFolder(id: string, name: string): Promise<PmSuccess>;
|
|
1261
|
+
/** POST /folder/delete — deletes the folder and everything in it. */
|
|
1262
|
+
deleteFolder(id: string): Promise<PmSuccess>;
|
|
1263
|
+
/** POST /folder/paste — moves files and/or folders into `id`. */
|
|
1264
|
+
pasteIntoFolder(id: string, items: {
|
|
1265
|
+
files?: string[];
|
|
1266
|
+
folders?: string[];
|
|
1267
|
+
}): Promise<PmSuccess>;
|
|
1268
|
+
/** GET /folder/uploadinfo — one-shot `token` + `url` for {@link uploadFile}. */
|
|
1269
|
+
getFolderUploadInfo(id?: string): Promise<PmUploadInfo>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Two-step upload: /folder/uploadinfo hands out a one-shot url + token, then
|
|
1272
|
+
* the file is POSTed there as multipart with fields `token` and `file`.
|
|
1273
|
+
* The upload endpoint is outside the API base, so it uses the injected fetch.
|
|
1274
|
+
*/
|
|
1275
|
+
uploadFile(file: FileInput, options?: {
|
|
1276
|
+
folderId?: string;
|
|
1277
|
+
filename?: string;
|
|
1278
|
+
}): Promise<void>;
|
|
1279
|
+
/** GET /folder/search — files and folders matching `q`. */
|
|
1280
|
+
search(q: string): Promise<PmSearchResults>;
|
|
1281
|
+
/** GET /item/details — file ids only, folder ids are rejected by the API. */
|
|
1282
|
+
getItemDetails(id: string): Promise<PmItemDetails>;
|
|
1283
|
+
/** POST /item/rename */
|
|
1284
|
+
renameItem(id: string, name: string): Promise<PmSuccess>;
|
|
1285
|
+
/** POST /item/delete */
|
|
1286
|
+
deleteItem(id: string): Promise<PmSuccess>;
|
|
1287
|
+
/** GET /item/listall — flat list of every owned file, with full path. */
|
|
1288
|
+
listAllItems(): Promise<PmItemListAll>;
|
|
1289
|
+
/**
|
|
1290
|
+
* POST /transfer/create — magnet, hoster link or nzb url.
|
|
1291
|
+
* Container sources (`.dlc`/`.ccf`/`.rsdf`) return the extracted links instead.
|
|
1292
|
+
*/
|
|
1293
|
+
createTransfer(src: string, options?: {
|
|
1294
|
+
folderId?: string;
|
|
1295
|
+
password?: string;
|
|
1296
|
+
}): Promise<PmTransferCreateResult>;
|
|
1297
|
+
/** POST /transfer/create — upload a .torrent/.nzb/.dlc file as the source. */
|
|
1298
|
+
createTransferFile(file: FileInput, options?: {
|
|
1299
|
+
folderId?: string;
|
|
1300
|
+
password?: string;
|
|
1301
|
+
filename?: string;
|
|
1302
|
+
}): Promise<PmTransferCreateResult>;
|
|
1303
|
+
/** POST /transfer/directdl — direct links without storing anything in your cloud. */
|
|
1304
|
+
getDirectDownloadLinks(src: string): Promise<PmDirectDl>;
|
|
1305
|
+
/** GET /transfer/list — every transfer (active, queued, finished, errored), newest first. */
|
|
1306
|
+
listTransfers(): Promise<PmTransferList>;
|
|
1307
|
+
/** GET /transfer/list mapped to the unified Torrent shape. */
|
|
1308
|
+
getTorrent(torrentId: string): Promise<Torrent>;
|
|
1309
|
+
/** GET /transfer/list + id lookup — the API has no single-transfer endpoint. */
|
|
1310
|
+
getTransfer(transferId: string): Promise<PmTransfer>;
|
|
1311
|
+
/** POST /transfer/retry — re-queues a failed transfer. */
|
|
1312
|
+
retryTransfer(id: string): Promise<PmSuccess>;
|
|
1313
|
+
/** POST /transfer/delete — deletes the transfer record (not the file). */
|
|
1314
|
+
deleteTransfer(id: string): Promise<PmSuccess>;
|
|
1315
|
+
/** POST /transfer/clearfinished */
|
|
1316
|
+
clearFinishedTransfers(): Promise<PmSuccess>;
|
|
1317
|
+
/** POST /cache/check — `response`/`filename`/`filesize` are parallel arrays. */
|
|
1318
|
+
checkCache(items: string[]): Promise<PmCacheCheck>;
|
|
1319
|
+
/** GET /services/list — supported services and their capabilities. */
|
|
1320
|
+
listServices(): Promise<PmServicesList>;
|
|
1321
|
+
/** POST /zip/generate — synchronous, `location` is downloadable right away. */
|
|
1322
|
+
generateZip(items: {
|
|
1323
|
+
files?: string[];
|
|
1324
|
+
folders?: string[];
|
|
1325
|
+
}): Promise<PmZipGenerate>;
|
|
1326
|
+
/** Builds the /authorize redirect URL — step 1 of the auth-code / PKCE flow. */
|
|
1327
|
+
static getAuthorizeUrl(params: {
|
|
1328
|
+
clientId: string;
|
|
1329
|
+
redirectUri: string;
|
|
1330
|
+
state?: string;
|
|
1331
|
+
/** PKCE challenge; sets code_challenge_method=S256 */
|
|
1332
|
+
codeChallenge?: string;
|
|
1333
|
+
/** 'token' for the legacy implicit flow */
|
|
1334
|
+
responseType?: 'code' | 'token';
|
|
1335
|
+
}): string;
|
|
1336
|
+
/** POST /token — start the device flow; show `user_code` at `verification_uri`. */
|
|
1337
|
+
static getDeviceCode(clientId: string, options?: ClientOptions): Promise<PmDeviceCode>;
|
|
1338
|
+
/**
|
|
1339
|
+
* POST /token — single device-flow poll. While pending the API answers
|
|
1340
|
+
* HTTP 400 + `{ error }`, which surfaces as a DebridError.
|
|
1341
|
+
*/
|
|
1342
|
+
static getDeviceToken(params: {
|
|
1343
|
+
clientId: string;
|
|
1344
|
+
deviceCode: string;
|
|
1345
|
+
} & ClientOptions): Promise<PmTokenResponse>;
|
|
1346
|
+
/**
|
|
1347
|
+
* Polls the device token endpoint until the user approves (or expiry),
|
|
1348
|
+
* honoring the interval from the device-code endpoint.
|
|
1349
|
+
*/
|
|
1350
|
+
static waitForDeviceToken(params: {
|
|
1351
|
+
clientId: string;
|
|
1352
|
+
deviceCode: string;
|
|
1353
|
+
expiresIn?: number;
|
|
1354
|
+
interval?: number;
|
|
1355
|
+
} & ClientOptions): Promise<PmTokenResponse>;
|
|
1356
|
+
/** POST /token — exchange an authorization code (PKCE: `codeVerifier`, else `clientSecret`). */
|
|
1357
|
+
static exchangeCode(params: {
|
|
1358
|
+
clientId: string;
|
|
1359
|
+
code: string;
|
|
1360
|
+
redirectUri: string;
|
|
1361
|
+
codeVerifier?: string;
|
|
1362
|
+
clientSecret?: string;
|
|
1363
|
+
} & ClientOptions): Promise<PmTokenResponse>;
|
|
1364
|
+
/** POST /token — legacy password grant, first-party clients only. */
|
|
1365
|
+
static getTokenWithPassword(params: {
|
|
1366
|
+
clientId: string;
|
|
1367
|
+
clientSecret: string;
|
|
1368
|
+
username: string;
|
|
1369
|
+
password: string;
|
|
1370
|
+
} & ClientOptions): Promise<PmTokenResponse>;
|
|
1371
|
+
}
|
|
1372
|
+
//#endregion
|
|
1373
|
+
export { type AdDelayedLink, type AdEnvelope, type AdHostDomainsData, type AdHostInfo, type AdHostPrioritiesData, type AdHostsData, type AdItemError, type AdLinkInfo, type AdLinkInfosData, type AdMagnetFileEntry, type AdMagnetFileUploadData, type AdMagnetFilesData, type AdMagnetFilter, type AdMagnetNode, type AdMagnetRestartData, type AdMagnetStatusData, type AdMagnetStatusItem, type AdMagnetStatusParams, type AdMagnetUploadData, type AdPinCheck, type AdPinGet, type AdPing, type AdRedirectorData, type AdStreamQuality, type AdStreamingLink, type AdUnlockedLink, type AdUploadedFile, type AdUploadedMagnet, type AdUserData, type AdUserHost, type AdUserHostsData, type AdUserInfo, type AdUserLink, type AdUserLinksData, type AdVerif, type AdVerifResend, type AdVoucherBalanceData, type AdVoucherDuration, type AdVoucherGenerateData, type AdVoucherGetData, AllDebrid, type AllDebridOptions, BaseFetcher, type BaseFetcherOptions, type BodyLike, type ClientOptions, DebridError, type DebridProvider, type DownloadLink, type FileInput, type FormValue, type PmAccountInfo, type PmBreadcrumb, type PmCacheCheck, type PmContentEntry, type PmDeviceCode, type PmDirectDl, type PmDirectDlContent, type PmErrorBody, type PmFileEntry, type PmFolderCreate, type PmFolderEntry, type PmFolderList, type PmFolderListParams, type PmItemDetails, type PmItemListAll, type PmListedFile, type PmOAuthError, type PmResponse, type PmSearchResults, type PmServicesList, type PmSuccess, type PmTokenResponse, type PmTransfer, type PmTransferContainer, type PmTransferCreateResult, type PmTransferCreated, type PmTransferList, type PmTransferStatus, type PmUploadInfo, type PmZipGenerate, Premiumize, type PremiumizeOptions, type QueryValue, REAL_DEBRID_OPENSOURCE_CLIENT_ID, type RdActiveCount, type RdAlternativeLink, type RdAvailableHost, type RdDeviceAuthorization, type RdDeviceCode, type RdDeviceCredentials, type RdDownloadItem, type RdHost, type RdHostState, type RdHostStatus, type RdHostStatuses, type RdHosts, type RdInstantAvailability, type RdLinkCheck, type RdMagnetAdded, type RdMediaAudioStream, type RdMediaInfo, type RdMediaSubtitleStream, type RdMediaVideoStream, type RdPagination, type RdSettingName, type RdSettings, type RdTokenResponse, type RdTorrent, type RdTorrentFile, type RdTorrentInfo, type RdTorrentStatus, type RdTraffic, type RdTrafficDay, type RdTrafficDetails, type RdTrafficEntry, type RdTranscodeQualities, type RdTranscodeStreams, type RdUnrestrictedLink, type RdUser, RealDebrid, type RealDebridOptions, type RequestOptions, type Torrent, type TorrentFile, type TorrentStatus, type UserInfo };
|