@vyla-entertainment/sdk 1.19.0 → 1.21.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/package.json +3 -2
- package/src/config.js +46 -85
- package/src/sdk.d.ts +94 -121
- package/src/sdk.js +82 -78
- package/src/sources/111477.js +88 -100
- package/src/sources/123anime.js +120 -56
- package/src/sources/3eyedraven.js +82 -135
- package/src/sources/cinecat.js +37 -18
- package/src/sources/cinemaarmy.js +179 -180
- package/src/sources/cinesrc.js +401 -397
- package/src/sources/cno.js +101 -94
- package/src/sources/dulo.js +134 -149
- package/src/sources/flaxmovies.js +114 -105
- package/src/sources/frost.js +39 -0
- package/src/sources/fsonline.js +95 -47
- package/src/sources/hdhub.js +43 -0
- package/src/sources/hexa.js +60 -53
- package/src/sources/hyper.js +42 -35
- package/src/sources/kickassanime.js +117 -124
- package/src/sources/kisskh.js +114 -59
- package/src/sources/lmscript.js +72 -70
- package/src/sources/lookmovie.js +80 -79
- package/src/sources/movenerds.js +74 -124
- package/src/sources/movy.js +197 -209
- package/src/sources/net79.js +59 -55
- package/src/sources/peestream.js +126 -138
- package/src/sources/pengu.js +46 -49
- package/src/sources/pstream.js +73 -67
- package/src/sources/purstream.js +96 -104
- package/src/sources/rivestream.js +182 -176
- package/src/sources/rivo.js +58 -53
- package/src/sources/streamaggregator.js +114 -128
- package/src/sources/thugtv.js +70 -62
- package/src/sources/vidapi.js +122 -114
- package/src/sources/vidcore.js +14 -122
- package/src/sources/vidfast.js +14 -122
- package/src/sources/vidlink.js +78 -27
- package/src/sources/vidup.js +14 -122
- package/src/sources/vidvault.js +133 -187
- package/src/sources/vidy.js +192 -187
- package/src/sources/vidzee.js +189 -183
- package/src/sources/vixsrc.js +123 -113
- package/src/sources/watchout.js +60 -0
- package/src/sources/xdownloader.js +127 -128
- package/src/sources/yapgrid.js +68 -62
- package/src/sources/yastream.js +35 -29
- package/src/subtitles.js +105 -122
- package/src/utils/helpers.js +586 -230
- package/src/sources/bcine.js +0 -202
- package/src/sources/cinezo.js +0 -55
- package/src/sources/vidora.js +0 -62
- package/src/sources/vidrock.js +0 -145
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vyla-entertainment/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"test": "node test/index.js"
|
|
5
|
+
"test": "node test/index.js",
|
|
6
|
+
"test:all": "node test/index.js all"
|
|
6
7
|
},
|
|
7
8
|
"author": "vyla-entertainment",
|
|
8
9
|
"contributors": [
|
package/src/config.js
CHANGED
|
@@ -56,24 +56,6 @@ export const SOURCES = [
|
|
|
56
56
|
}],
|
|
57
57
|
},
|
|
58
58
|
|
|
59
|
-
{
|
|
60
|
-
key: 'bcine',
|
|
61
|
-
label: 'Bcine',
|
|
62
|
-
sourceFile: 'bcine',
|
|
63
|
-
proxyParam: 'bc',
|
|
64
|
-
timeout: 25000,
|
|
65
|
-
jitter: 500,
|
|
66
|
-
retries: 2,
|
|
67
|
-
multiUrl: true,
|
|
68
|
-
cdnHeaders: [{
|
|
69
|
-
pattern: /1embed\.cc|videasy\.to/i,
|
|
70
|
-
headers: {
|
|
71
|
-
Referer: 'https://bcine.ru/',
|
|
72
|
-
Origin: 'https://bcine.ru',
|
|
73
|
-
},
|
|
74
|
-
}],
|
|
75
|
-
},
|
|
76
|
-
|
|
77
59
|
{
|
|
78
60
|
key: 'cinemaarmy',
|
|
79
61
|
label: 'CinemaArmy',
|
|
@@ -112,24 +94,6 @@ export const SOURCES = [
|
|
|
112
94
|
}],
|
|
113
95
|
},
|
|
114
96
|
|
|
115
|
-
{
|
|
116
|
-
key: 'cinezo',
|
|
117
|
-
label: 'Cinezo',
|
|
118
|
-
sourceFile: 'cinezo',
|
|
119
|
-
proxyParam: 'czo',
|
|
120
|
-
timeout: 25000,
|
|
121
|
-
jitter: 500,
|
|
122
|
-
retries: 2,
|
|
123
|
-
multiUrl: true,
|
|
124
|
-
cdnHeaders: [{
|
|
125
|
-
pattern: /yenime\.net|flikhub\.net|hakunaymatata\.com/i,
|
|
126
|
-
headers: {
|
|
127
|
-
Referer: 'https://player.cinezo.live/',
|
|
128
|
-
Origin: 'https://player.cinezo.live',
|
|
129
|
-
},
|
|
130
|
-
}],
|
|
131
|
-
},
|
|
132
|
-
|
|
133
97
|
{
|
|
134
98
|
key: 'cno',
|
|
135
99
|
label: 'Cno',
|
|
@@ -187,6 +151,18 @@ export const SOURCES = [
|
|
|
187
151
|
}],
|
|
188
152
|
},
|
|
189
153
|
|
|
154
|
+
{
|
|
155
|
+
key: 'frost',
|
|
156
|
+
label: 'FrostStream',
|
|
157
|
+
sourceFile: 'frost',
|
|
158
|
+
proxyParam: 'fst',
|
|
159
|
+
timeout: 25000,
|
|
160
|
+
jitter: 500,
|
|
161
|
+
retries: 2,
|
|
162
|
+
multiUrl: true,
|
|
163
|
+
skipProxy: true,
|
|
164
|
+
},
|
|
165
|
+
|
|
190
166
|
{
|
|
191
167
|
key: 'fsonline',
|
|
192
168
|
label: 'FSOnline',
|
|
@@ -199,6 +175,18 @@ export const SOURCES = [
|
|
|
199
175
|
skipProxy: true,
|
|
200
176
|
},
|
|
201
177
|
|
|
178
|
+
{
|
|
179
|
+
key: 'hdhub',
|
|
180
|
+
label: 'HDHub',
|
|
181
|
+
sourceFile: 'hdhub',
|
|
182
|
+
proxyParam: 'hdh',
|
|
183
|
+
timeout: 25000,
|
|
184
|
+
jitter: 500,
|
|
185
|
+
retries: 2,
|
|
186
|
+
multiUrl: true,
|
|
187
|
+
skipProxy: true,
|
|
188
|
+
},
|
|
189
|
+
|
|
202
190
|
{
|
|
203
191
|
key: 'hexa',
|
|
204
192
|
label: 'Hexa',
|
|
@@ -337,14 +325,6 @@ export const SOURCES = [
|
|
|
337
325
|
jitter: 500,
|
|
338
326
|
retries: 2,
|
|
339
327
|
multiUrl: true,
|
|
340
|
-
skipProxy: true,
|
|
341
|
-
cdnHeaders: [{
|
|
342
|
-
pattern: /hakunaymatata\.com/i,
|
|
343
|
-
headers: {
|
|
344
|
-
Referer: 'https://net79.cc/',
|
|
345
|
-
Origin: 'https://net79.cc',
|
|
346
|
-
},
|
|
347
|
-
}],
|
|
348
328
|
},
|
|
349
329
|
|
|
350
330
|
{
|
|
@@ -357,7 +337,7 @@ export const SOURCES = [
|
|
|
357
337
|
retries: 1,
|
|
358
338
|
multiUrl: true,
|
|
359
339
|
skipProxy: true,
|
|
360
|
-
disabled: false,
|
|
340
|
+
disabled: false,
|
|
361
341
|
},
|
|
362
342
|
|
|
363
343
|
{
|
|
@@ -469,7 +449,16 @@ export const SOURCES = [
|
|
|
469
449
|
jitter: 500,
|
|
470
450
|
retries: 1,
|
|
471
451
|
multiUrl: true,
|
|
452
|
+
skipProxy: true,
|
|
453
|
+
cdnHeaders: [{
|
|
454
|
+
pattern: /vidcore\.io/i,
|
|
455
|
+
headers: {
|
|
456
|
+
Referer: 'https://vidcore.io/',
|
|
457
|
+
Origin: 'https://vidcore.io',
|
|
458
|
+
},
|
|
459
|
+
}],
|
|
472
460
|
},
|
|
461
|
+
|
|
473
462
|
{
|
|
474
463
|
key: 'vidfast',
|
|
475
464
|
label: 'VidFast',
|
|
@@ -481,25 +470,6 @@ export const SOURCES = [
|
|
|
481
470
|
multiUrl: true,
|
|
482
471
|
},
|
|
483
472
|
|
|
484
|
-
{
|
|
485
|
-
key: 'vidora',
|
|
486
|
-
label: 'Vidora',
|
|
487
|
-
sourceFile: 'vidora',
|
|
488
|
-
proxyParam: 'vdra',
|
|
489
|
-
timeout: 25000,
|
|
490
|
-
jitter: 500,
|
|
491
|
-
retries: 2,
|
|
492
|
-
multiUrl: true,
|
|
493
|
-
skipProxy: true,
|
|
494
|
-
cdnHeaders: [{
|
|
495
|
-
pattern: /rousav\.tech|vidbolt\.xyz|vidrift\.in|goldenkite\.top|ravok\.buzz/i,
|
|
496
|
-
headers: {
|
|
497
|
-
Referer: 'https://vidora-3l2w.onrender.com/',
|
|
498
|
-
Origin: 'https://vidora-3l2w.onrender.com',
|
|
499
|
-
},
|
|
500
|
-
}],
|
|
501
|
-
},
|
|
502
|
-
|
|
503
473
|
{
|
|
504
474
|
key: 'vidlink',
|
|
505
475
|
label: 'Vidlink',
|
|
@@ -508,28 +478,7 @@ export const SOURCES = [
|
|
|
508
478
|
timeout: 20000,
|
|
509
479
|
jitter: 500,
|
|
510
480
|
retries: 2,
|
|
511
|
-
skipProxy: true,
|
|
512
|
-
multiUrl: true,
|
|
513
|
-
},
|
|
514
|
-
|
|
515
|
-
{
|
|
516
|
-
key: 'vidrock',
|
|
517
|
-
label: 'VidRock',
|
|
518
|
-
sourceFile: 'vidrock',
|
|
519
|
-
proxyParam: 'vr',
|
|
520
|
-
timeout: 20000,
|
|
521
|
-
jitter: 800,
|
|
522
|
-
retries: 3,
|
|
523
481
|
multiUrl: true,
|
|
524
|
-
cdnHeaders: [{
|
|
525
|
-
pattern: /./,
|
|
526
|
-
headers: {
|
|
527
|
-
Accept: '/',
|
|
528
|
-
'Accept-Language': 'en-US,en;q=0.9',
|
|
529
|
-
Referer: 'https://vidrock.ru/',
|
|
530
|
-
Origin: 'https://vidrock.ru',
|
|
531
|
-
},
|
|
532
|
-
},],
|
|
533
482
|
},
|
|
534
483
|
|
|
535
484
|
{
|
|
@@ -608,6 +557,18 @@ export const SOURCES = [
|
|
|
608
557
|
},
|
|
609
558
|
},
|
|
610
559
|
|
|
560
|
+
{
|
|
561
|
+
key: 'watchout',
|
|
562
|
+
label: 'Watchout',
|
|
563
|
+
sourceFile: 'watchout',
|
|
564
|
+
proxyParam: 'wo',
|
|
565
|
+
timeout: 25000,
|
|
566
|
+
jitter: 500,
|
|
567
|
+
retries: 2,
|
|
568
|
+
multiUrl: true,
|
|
569
|
+
skipProxy: true,
|
|
570
|
+
},
|
|
571
|
+
|
|
611
572
|
{
|
|
612
573
|
key: 'xdownloader',
|
|
613
574
|
label: 'XDownloader',
|
package/src/sdk.d.ts
CHANGED
|
@@ -1,122 +1,95 @@
|
|
|
1
|
-
export interface SourceConfig {
|
|
2
|
-
key: string;
|
|
3
|
-
label: string;
|
|
4
|
-
sourceFile: string;
|
|
5
|
-
proxyParam: string;
|
|
6
|
-
timeout: number;
|
|
7
|
-
jitter: number;
|
|
8
|
-
retries: number;
|
|
9
|
-
multiUrl: boolean;
|
|
10
|
-
skipProxy?: boolean;
|
|
11
|
-
cdnHeaders?: {
|
|
12
|
-
pattern: RegExp;
|
|
13
|
-
headers: {
|
|
14
|
-
Referer: string;
|
|
15
|
-
Origin: string;
|
|
16
|
-
};
|
|
17
|
-
}[];
|
|
18
|
-
skipVerify?: boolean;
|
|
19
|
-
verifyHeaders?: boolean;
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
sourcesTimeout?: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
e?: number | null,
|
|
96
|
-
clientIP?: string | null
|
|
97
|
-
): Promise<StreamResult | { allUrls: StreamResult[] }>;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Get subtitles for a movie or TV episode.
|
|
101
|
-
* @param id Media id
|
|
102
|
-
* @param s Season number (for TV), or null for movies
|
|
103
|
-
* @param e Episode number (for TV), or null for movies
|
|
104
|
-
*/
|
|
105
|
-
getSubtitles(
|
|
106
|
-
id: string | number,
|
|
107
|
-
s?: number | null,
|
|
108
|
-
e?: number | null
|
|
109
|
-
): Promise<SubtitleResult[]>;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Get download links for a movie or TV episode.
|
|
113
|
-
* @param id Media id
|
|
114
|
-
* @param s Season number (for TV), or null for movies
|
|
115
|
-
* @param e Episode number (for TV), or null for movies
|
|
116
|
-
*/
|
|
117
|
-
getDownloads(
|
|
118
|
-
id: string | number,
|
|
119
|
-
s?: number | null,
|
|
120
|
-
e?: number | null
|
|
121
|
-
): Promise<DownloadResult[]>;
|
|
1
|
+
export interface SourceConfig {
|
|
2
|
+
key: string;
|
|
3
|
+
label: string;
|
|
4
|
+
sourceFile: string;
|
|
5
|
+
proxyParam: string;
|
|
6
|
+
timeout: number;
|
|
7
|
+
jitter: number;
|
|
8
|
+
retries: number;
|
|
9
|
+
multiUrl: boolean;
|
|
10
|
+
skipProxy?: boolean;
|
|
11
|
+
cdnHeaders?: {
|
|
12
|
+
pattern: RegExp;
|
|
13
|
+
headers: {
|
|
14
|
+
Referer: string;
|
|
15
|
+
Origin: string;
|
|
16
|
+
};
|
|
17
|
+
}[];
|
|
18
|
+
skipVerify?: boolean;
|
|
19
|
+
verifyHeaders?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
sourcesTimeout?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ProbeResult {
|
|
25
|
+
ok: boolean;
|
|
26
|
+
ms: number | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface StreamResult {
|
|
30
|
+
url: string;
|
|
31
|
+
headers: {
|
|
32
|
+
"User-Agent": string;
|
|
33
|
+
Referer: string;
|
|
34
|
+
Origin: string;
|
|
35
|
+
[key: string]: string;
|
|
36
|
+
};
|
|
37
|
+
server: string;
|
|
38
|
+
quality: string;
|
|
39
|
+
type: "mp4" | "hls";
|
|
40
|
+
skipVerify?: boolean;
|
|
41
|
+
skipProxy?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface DownloadResult {
|
|
45
|
+
url: string;
|
|
46
|
+
quality: string;
|
|
47
|
+
size: number | null;
|
|
48
|
+
type: "mkv";
|
|
49
|
+
active: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface SubtitleResult {
|
|
53
|
+
label: string;
|
|
54
|
+
file: string;
|
|
55
|
+
type: "vtt" | "srt";
|
|
56
|
+
source: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type ProbeAllResult = Record<string, ProbeResult>;
|
|
60
|
+
|
|
61
|
+
export interface VylaSDKOptions {
|
|
62
|
+
tmdbApiKey?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default class VylaSDK {
|
|
66
|
+
tmdbApiKey?: string;
|
|
67
|
+
|
|
68
|
+
constructor(options?: VylaSDKOptions);
|
|
69
|
+
|
|
70
|
+
getSources(excludeDisabled?: boolean): SourceConfig[];
|
|
71
|
+
|
|
72
|
+
probeAllSources(): Promise<ProbeAllResult>;
|
|
73
|
+
|
|
74
|
+
probeSource(key: string): Promise<ProbeResult>;
|
|
75
|
+
|
|
76
|
+
getStream(
|
|
77
|
+
key: string,
|
|
78
|
+
id: string | number,
|
|
79
|
+
s?: number | null,
|
|
80
|
+
e?: number | null,
|
|
81
|
+
clientIP?: string | null
|
|
82
|
+
): Promise<StreamResult | { allUrls: StreamResult[] }>;
|
|
83
|
+
|
|
84
|
+
getSubtitles(
|
|
85
|
+
id: string | number,
|
|
86
|
+
s?: number | null,
|
|
87
|
+
e?: number | null
|
|
88
|
+
): Promise<SubtitleResult[]>;
|
|
89
|
+
|
|
90
|
+
getDownloads(
|
|
91
|
+
id: string | number,
|
|
92
|
+
s?: number | null,
|
|
93
|
+
e?: number | null
|
|
94
|
+
): Promise<DownloadResult[]>;
|
|
122
95
|
}
|
package/src/sdk.js
CHANGED
|
@@ -1,78 +1,82 @@
|
|
|
1
|
-
import SOURCES, { SOURCE_MAP } from "./config.js";
|
|
2
|
-
import { fetchDownloads } from "./downloads/downloads.js";
|
|
3
|
-
import { probeSource } from "./health.js";
|
|
4
|
-
import { getChapterPages, getMangaDetails, searchManga } from "./manga/atsu.js";
|
|
5
|
-
import { fetchSubtitles, getSubPathsMovie, getSubPathsTv } from "./subtitles.js";
|
|
6
|
-
import { createStreamArgs } from "./utils/helpers.js";
|
|
7
|
-
|
|
8
|
-
const ALL_SOURCE_MODULES = Object.fromEntries(
|
|
9
|
-
await Promise.all(SOURCES.map(async cfg => [cfg.key, await import(`./sources/${cfg.sourceFile}.js`)]))
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
const SOURCE_MODULES = Object.fromEntries(
|
|
13
|
-
Object.entries(ALL_SOURCE_MODULES).filter(([key]) => !SOURCE_MAP[key]?.disabled)
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
export default class VylaSDK {
|
|
17
|
-
tmdbApiKey = null;
|
|
18
|
-
penguManifest = null;
|
|
19
|
-
constructor({ tmdbApiKey, penguManifest } = {}) {
|
|
20
|
-
this.tmdbApiKey = tmdbApiKey || null;
|
|
21
|
-
this.penguManifest = penguManifest || null;
|
|
22
|
-
}
|
|
23
|
-
getSources(excludeDisabled = false) {
|
|
24
|
-
if (excludeDisabled) {
|
|
25
|
-
return SOURCES.filter(cfg => !cfg.disabled);
|
|
26
|
-
}
|
|
27
|
-
return SOURCES;
|
|
28
|
-
}
|
|
29
|
-
async probeAllSources() {
|
|
30
|
-
const active = SOURCES.filter(cfg => !cfg.disabled);
|
|
31
|
-
|
|
32
|
-
const results = await Promise.allSettled(
|
|
33
|
-
active.map(async cfg => await probeSource(cfg, SOURCE_MODULES[cfg.key]))
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const sources = Object.fromEntries(
|
|
37
|
-
active.map((cfg, i) => [
|
|
38
|
-
cfg.key,
|
|
39
|
-
results[i].status === 'fulfilled' ? results[i].value : { ok: false, ms: null },
|
|
40
|
-
])
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return sources;
|
|
44
|
-
}
|
|
45
|
-
async probeSource(key) {
|
|
46
|
-
const cfg = SOURCES.find(cfg => cfg.key === key);
|
|
47
|
-
if (!cfg) throw new Error(`Source with key "${key}" not found`);
|
|
48
|
-
const mod = SOURCE_MODULES[key];
|
|
49
|
-
if (!mod) throw new Error(`Source module for key "${key}" not found`);
|
|
50
|
-
return await probeSource(this, cfg, mod);
|
|
51
|
-
}
|
|
52
|
-
async getStream(key, id, s = null, e = null, clientIP = null) {
|
|
53
|
-
const cfg = SOURCES.find(cfg => cfg.key === key);
|
|
54
|
-
if (!cfg) throw new Error(`Source with key "${key}" not found`);
|
|
55
|
-
const mod = SOURCE_MODULES[key];
|
|
56
|
-
if (!mod) throw new Error(`Source module for key "${key}" not found`);
|
|
57
|
-
const streamArgs = await createStreamArgs(cfg, this, id, s, e, clientIP);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
1
|
+
import SOURCES, { SOURCE_MAP } from "./config.js";
|
|
2
|
+
import { fetchDownloads } from "./downloads/downloads.js";
|
|
3
|
+
import { probeSource } from "./health.js";
|
|
4
|
+
import { getChapterPages, getMangaDetails, searchManga } from "./manga/atsu.js";
|
|
5
|
+
import { fetchSubtitles, getSubPathsMovie, getSubPathsTv } from "./subtitles.js";
|
|
6
|
+
import { createStreamArgs } from "./utils/helpers.js";
|
|
7
|
+
|
|
8
|
+
const ALL_SOURCE_MODULES = Object.fromEntries(
|
|
9
|
+
await Promise.all(SOURCES.map(async cfg => [cfg.key, await import(`./sources/${cfg.sourceFile}.js`)]))
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const SOURCE_MODULES = Object.fromEntries(
|
|
13
|
+
Object.entries(ALL_SOURCE_MODULES).filter(([key]) => !SOURCE_MAP[key]?.disabled)
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default class VylaSDK {
|
|
17
|
+
tmdbApiKey = null;
|
|
18
|
+
penguManifest = null;
|
|
19
|
+
constructor({ tmdbApiKey, penguManifest } = {}) {
|
|
20
|
+
this.tmdbApiKey = tmdbApiKey || null;
|
|
21
|
+
this.penguManifest = penguManifest || null;
|
|
22
|
+
}
|
|
23
|
+
getSources(excludeDisabled = false) {
|
|
24
|
+
if (excludeDisabled) {
|
|
25
|
+
return SOURCES.filter(cfg => !cfg.disabled);
|
|
26
|
+
}
|
|
27
|
+
return SOURCES;
|
|
28
|
+
}
|
|
29
|
+
async probeAllSources() {
|
|
30
|
+
const active = SOURCES.filter(cfg => !cfg.disabled);
|
|
31
|
+
|
|
32
|
+
const results = await Promise.allSettled(
|
|
33
|
+
active.map(async cfg => await probeSource(this, cfg, SOURCE_MODULES[cfg.key]))
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const sources = Object.fromEntries(
|
|
37
|
+
active.map((cfg, i) => [
|
|
38
|
+
cfg.key,
|
|
39
|
+
results[i].status === 'fulfilled' ? results[i].value : { ok: false, ms: null },
|
|
40
|
+
])
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return sources;
|
|
44
|
+
}
|
|
45
|
+
async probeSource(key) {
|
|
46
|
+
const cfg = SOURCES.find(cfg => cfg.key === key);
|
|
47
|
+
if (!cfg) throw new Error(`Source with key "${key}" not found`);
|
|
48
|
+
const mod = SOURCE_MODULES[key];
|
|
49
|
+
if (!mod) throw new Error(`Source module for key "${key}" not found`);
|
|
50
|
+
return await probeSource(this, cfg, mod);
|
|
51
|
+
}
|
|
52
|
+
async getStream(key, id, s = null, e = null, clientIP = null) {
|
|
53
|
+
const cfg = SOURCES.find(cfg => cfg.key === key);
|
|
54
|
+
if (!cfg) throw new Error(`Source with key "${key}" not found`);
|
|
55
|
+
const mod = SOURCE_MODULES[key];
|
|
56
|
+
if (!mod) throw new Error(`Source module for key "${key}" not found`);
|
|
57
|
+
const streamArgs = await createStreamArgs(cfg, this, id, s, e, clientIP);
|
|
58
|
+
const result = await mod.getStream(streamArgs);
|
|
59
|
+
if (result && typeof result === 'object') {
|
|
60
|
+
delete result.subtitles;
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
async getSubtitles(id, s = null, e = null) {
|
|
65
|
+
const paths = s != null && e != null
|
|
66
|
+
? await getSubPathsTv(id, s, e)
|
|
67
|
+
: await getSubPathsMovie(id);
|
|
68
|
+
return await fetchSubtitles(paths);
|
|
69
|
+
}
|
|
70
|
+
async getDownloads(id, s = null, e = null) {
|
|
71
|
+
return await fetchDownloads(this, id, s, e);
|
|
72
|
+
}
|
|
73
|
+
async searchManga(query, page = 1, perPage = 12) {
|
|
74
|
+
return await searchManga(query, page, perPage);
|
|
75
|
+
}
|
|
76
|
+
async getManga(id) {
|
|
77
|
+
return await getMangaDetails(id);
|
|
78
|
+
}
|
|
79
|
+
async getMangaChapter(mangaId, chapterId) {
|
|
80
|
+
return await getChapterPages(mangaId, chapterId);
|
|
81
|
+
}
|
|
82
|
+
}
|