dasha 4.0.0-alpha.2 → 4.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/dasha.cjs +267 -240
- package/dist/dasha.d.cts +200 -90
- package/dist/dasha.d.mts +289 -0
- package/dist/{dasha.js → dasha.mjs} +240 -224
- package/package.json +17 -20
- package/dist/dasha.d.ts +0 -179
package/dist/dasha.d.cts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
//#region lib/shared/media-type.d.ts
|
|
2
|
-
declare const MEDIA_TYPES: {
|
|
3
|
-
readonly VIDEO: "video";
|
|
4
|
-
readonly AUDIO: "audio";
|
|
5
|
-
readonly SUBTITLES: "subtitle";
|
|
6
|
-
readonly CLOSED_CAPTIONS: "closed-captions";
|
|
7
|
-
};
|
|
8
|
-
type MediaType = (typeof MEDIA_TYPES)[keyof typeof MEDIA_TYPES];
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
1
|
//#region lib/shared/encrypt-method.d.ts
|
|
12
2
|
declare const ENCRYPT_METHODS: {
|
|
13
|
-
NONE:
|
|
14
|
-
AES_128:
|
|
15
|
-
AES_128_ECB:
|
|
16
|
-
SAMPLE_AES:
|
|
17
|
-
SAMPLE_AES_CTR:
|
|
18
|
-
CENC:
|
|
19
|
-
CHACHA20:
|
|
20
|
-
UNKNOWN:
|
|
3
|
+
readonly NONE: "none";
|
|
4
|
+
readonly AES_128: "aes-128";
|
|
5
|
+
readonly AES_128_ECB: "aes-128-ecb";
|
|
6
|
+
readonly SAMPLE_AES: "sample-aes";
|
|
7
|
+
readonly SAMPLE_AES_CTR: "sample-aes-ctr";
|
|
8
|
+
readonly CENC: "cenc";
|
|
9
|
+
readonly CHACHA20: "chacha20";
|
|
10
|
+
readonly UNKNOWN: "unknown";
|
|
21
11
|
};
|
|
22
12
|
type EncryptMethod = (typeof ENCRYPT_METHODS)[keyof typeof ENCRYPT_METHODS];
|
|
23
|
-
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region lib/shared/encrypt-info.d.ts
|
|
15
|
+
type DrmType = 'widevine' | 'playready' | 'fairplay';
|
|
16
|
+
declare class EncryptInfo {
|
|
17
|
+
method: EncryptMethod;
|
|
18
|
+
key?: Uint8Array;
|
|
19
|
+
iv?: Uint8Array;
|
|
20
|
+
drm: { [key in DrmType]?: {
|
|
21
|
+
keyId?: string;
|
|
22
|
+
pssh?: string;
|
|
23
|
+
} };
|
|
24
|
+
constructor(method?: string | null);
|
|
25
|
+
parseMethod(method?: string | null): EncryptMethod;
|
|
26
|
+
}
|
|
24
27
|
//#endregion
|
|
25
28
|
//#region lib/shared/extractor-type.d.ts
|
|
26
29
|
declare const EXTRACTOR_TYPES: {
|
|
@@ -30,71 +33,6 @@ declare const EXTRACTOR_TYPES: {
|
|
|
30
33
|
readonly MSS: "MSS";
|
|
31
34
|
};
|
|
32
35
|
type ExtractorType = (typeof EXTRACTOR_TYPES)[keyof typeof EXTRACTOR_TYPES];
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region lib/shared/role-type.d.ts
|
|
36
|
-
declare const ROLE_TYPE: {
|
|
37
|
-
Subtitle: number;
|
|
38
|
-
Main: number;
|
|
39
|
-
Alternate: number;
|
|
40
|
-
Supplementary: number;
|
|
41
|
-
Commentary: number;
|
|
42
|
-
Dub: number;
|
|
43
|
-
Description: number;
|
|
44
|
-
Sign: number;
|
|
45
|
-
Metadata: number;
|
|
46
|
-
ForcedSubtitle: number;
|
|
47
|
-
};
|
|
48
|
-
type RoleType = (typeof ROLE_TYPE)[keyof typeof ROLE_TYPE];
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region lib/shared/encrypt-info.d.ts
|
|
52
|
-
declare class EncryptInfo {
|
|
53
|
-
method: EncryptMethod;
|
|
54
|
-
key?: Buffer;
|
|
55
|
-
iv?: Buffer;
|
|
56
|
-
constructor(method?: string | null);
|
|
57
|
-
parseMethod(method?: string | null): EncryptMethod;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region lib/processor.d.ts
|
|
62
|
-
declare abstract class ContentProcessor {
|
|
63
|
-
abstract canProcess(extractorType: ExtractorType, rawText: string, parserConfig: ParserConfig): boolean;
|
|
64
|
-
abstract process(rawText: string, parserConfig: ParserConfig): string;
|
|
65
|
-
}
|
|
66
|
-
declare abstract class KeyProcessor {
|
|
67
|
-
abstract canProcess(extractorType: ExtractorType, keyLine: string, m3u8Url: string, m3u8Content: string, parserConfig: ParserConfig): boolean;
|
|
68
|
-
abstract process(keyLine: string, m3u8Url: string, m3u8Content: string, parserConfig: ParserConfig): Promise<EncryptInfo>;
|
|
69
|
-
}
|
|
70
|
-
declare abstract class UrlProcessor {
|
|
71
|
-
abstract canProcess(extractorType: ExtractorType, originalUrl: string, parserConfig: ParserConfig): boolean;
|
|
72
|
-
abstract process(originalUrl: string, parserConfig: ParserConfig): string;
|
|
73
|
-
}
|
|
74
|
-
declare class DefaultUrlProcessor extends UrlProcessor {
|
|
75
|
-
canProcess(_extractorType: ExtractorType, _originalUrl: string, parserConfig: ParserConfig): boolean;
|
|
76
|
-
process(url: string, parserConfig: ParserConfig): string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region lib/parser-config.d.ts
|
|
81
|
-
declare class ParserConfig {
|
|
82
|
-
url: string;
|
|
83
|
-
originalUrl: string;
|
|
84
|
-
baseUrl?: string;
|
|
85
|
-
customParserArgs: Record<string, string>;
|
|
86
|
-
headers: Record<string, string>;
|
|
87
|
-
contentProcessors: ContentProcessor[];
|
|
88
|
-
urlProcessors: UrlProcessor[];
|
|
89
|
-
keyProcessors: KeyProcessor[];
|
|
90
|
-
customMethod?: EncryptMethod;
|
|
91
|
-
customKey?: Buffer;
|
|
92
|
-
customIv?: Buffer;
|
|
93
|
-
urlProcessorArgs?: string;
|
|
94
|
-
appendUrlParams: boolean;
|
|
95
|
-
keyRetryCount: number;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
36
|
//#endregion
|
|
99
37
|
//#region lib/shared/media-segment.d.ts
|
|
100
38
|
declare class MediaSegment {
|
|
@@ -112,14 +50,21 @@ declare class MediaSegment {
|
|
|
112
50
|
equals(segment: unknown): boolean;
|
|
113
51
|
getHashCode(): string;
|
|
114
52
|
}
|
|
115
|
-
|
|
116
53
|
//#endregion
|
|
117
54
|
//#region lib/shared/media-part.d.ts
|
|
118
55
|
declare class MediaPart {
|
|
119
56
|
mediaSegments: MediaSegment[];
|
|
120
57
|
constructor(segments?: MediaSegment[]);
|
|
121
58
|
}
|
|
122
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region lib/shared/media-type.d.ts
|
|
61
|
+
declare const MEDIA_TYPES: {
|
|
62
|
+
readonly VIDEO: "video";
|
|
63
|
+
readonly AUDIO: "audio";
|
|
64
|
+
readonly SUBTITLES: "subtitle";
|
|
65
|
+
readonly CLOSED_CAPTIONS: "closed-captions";
|
|
66
|
+
};
|
|
67
|
+
type MediaType = (typeof MEDIA_TYPES)[keyof typeof MEDIA_TYPES];
|
|
123
68
|
//#endregion
|
|
124
69
|
//#region lib/shared/playlist.d.ts
|
|
125
70
|
declare class Playlist {
|
|
@@ -131,7 +76,21 @@ declare class Playlist {
|
|
|
131
76
|
mediaInit?: MediaSegment;
|
|
132
77
|
mediaParts: MediaPart[];
|
|
133
78
|
}
|
|
134
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region lib/shared/role-type.d.ts
|
|
81
|
+
declare const ROLE_TYPE: {
|
|
82
|
+
Subtitle: number;
|
|
83
|
+
Main: number;
|
|
84
|
+
Alternate: number;
|
|
85
|
+
Supplementary: number;
|
|
86
|
+
Commentary: number;
|
|
87
|
+
Dub: number;
|
|
88
|
+
Description: number;
|
|
89
|
+
Sign: number;
|
|
90
|
+
Metadata: number;
|
|
91
|
+
ForcedSubtitle: number;
|
|
92
|
+
};
|
|
93
|
+
type RoleType = (typeof ROLE_TYPE)[keyof typeof ROLE_TYPE];
|
|
135
94
|
//#endregion
|
|
136
95
|
//#region lib/shared/stream-spec.d.ts
|
|
137
96
|
declare class StreamSpec {
|
|
@@ -161,7 +120,52 @@ declare class StreamSpec {
|
|
|
161
120
|
get segmentsCount(): number;
|
|
162
121
|
toShortString(): string;
|
|
163
122
|
}
|
|
164
|
-
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region lib/extractor.d.ts
|
|
125
|
+
interface Extractor {
|
|
126
|
+
extractorType: ExtractorType;
|
|
127
|
+
extractStreams(rawText: string): Promise<StreamSpec[]>;
|
|
128
|
+
fetchPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
129
|
+
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
130
|
+
preProcessUrl(url: string): string;
|
|
131
|
+
preProcessContent(): void;
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region lib/processor.d.ts
|
|
135
|
+
interface ContentProcessor {
|
|
136
|
+
canProcess(extractorType: ExtractorType, rawText: string, parserConfig: ParserConfig): boolean;
|
|
137
|
+
process(rawText: string, parserConfig: ParserConfig): string;
|
|
138
|
+
}
|
|
139
|
+
interface KeyProcessor {
|
|
140
|
+
canProcess(extractorType: ExtractorType, keyLine: string, m3u8Url: string, m3u8Content: string, parserConfig: ParserConfig): boolean;
|
|
141
|
+
process(keyLine: string, m3u8Url: string, m3u8Content: string, parserConfig: ParserConfig): Promise<EncryptInfo>;
|
|
142
|
+
}
|
|
143
|
+
interface UrlProcessor {
|
|
144
|
+
canProcess(extractorType: ExtractorType, originalUrl: string, parserConfig: ParserConfig): boolean;
|
|
145
|
+
process(originalUrl: string, parserConfig: ParserConfig): string;
|
|
146
|
+
}
|
|
147
|
+
declare class DefaultUrlProcessor implements UrlProcessor {
|
|
148
|
+
canProcess(_extractorType: ExtractorType, _originalUrl: string, parserConfig: ParserConfig): boolean;
|
|
149
|
+
process(url: string, parserConfig: ParserConfig): string;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region lib/parser-config.d.ts
|
|
153
|
+
declare class ParserConfig {
|
|
154
|
+
url: string;
|
|
155
|
+
originalUrl: string;
|
|
156
|
+
baseUrl?: string;
|
|
157
|
+
customParserArgs: Record<string, string>;
|
|
158
|
+
headers: Record<string, string>;
|
|
159
|
+
contentProcessors: ContentProcessor[];
|
|
160
|
+
urlProcessors: UrlProcessor[];
|
|
161
|
+
keyProcessors: KeyProcessor[];
|
|
162
|
+
customMethod?: EncryptMethod;
|
|
163
|
+
customKey?: Uint8Array;
|
|
164
|
+
customIv?: Uint8Array;
|
|
165
|
+
urlProcessorArgs?: string;
|
|
166
|
+
appendUrlParams: boolean;
|
|
167
|
+
keyRetryCount: number;
|
|
168
|
+
}
|
|
165
169
|
//#endregion
|
|
166
170
|
//#region lib/stream-extractor.d.ts
|
|
167
171
|
declare class StreamExtractor {
|
|
@@ -174,6 +178,112 @@ declare class StreamExtractor {
|
|
|
174
178
|
fetchPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
175
179
|
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
176
180
|
}
|
|
177
|
-
|
|
178
181
|
//#endregion
|
|
179
|
-
|
|
182
|
+
//#region lib/dash/dash-content-processor.d.ts
|
|
183
|
+
declare class DefaultDashContentProcessor implements ContentProcessor {
|
|
184
|
+
canProcess(extractorType: ExtractorType, mpdContent: string): boolean;
|
|
185
|
+
process(mpdContent: string): string;
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region lib/dash/dash-extractor.d.ts
|
|
189
|
+
declare class DashExtractor implements Extractor {
|
|
190
|
+
#private;
|
|
191
|
+
get extractorType(): ExtractorType;
|
|
192
|
+
constructor(parserConfig: ParserConfig);
|
|
193
|
+
extractStreams(rawText: string): Promise<StreamSpec[]>;
|
|
194
|
+
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
195
|
+
fetchPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
196
|
+
preProcessUrl(url: string): string;
|
|
197
|
+
preProcessContent(): void;
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region lib/dash/dash-tags.d.ts
|
|
201
|
+
declare const DASH_TAGS: {
|
|
202
|
+
TemplateRepresentationID: string;
|
|
203
|
+
TemplateBandwidth: string;
|
|
204
|
+
TemplateNumber: string;
|
|
205
|
+
TemplateTime: string;
|
|
206
|
+
};
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region lib/dash/dash-utils.d.ts
|
|
209
|
+
/**
|
|
210
|
+
* Extracts StartRange and ExpectLength information from a string like "100-300"
|
|
211
|
+
* @param range - The range string in the format "start-end"
|
|
212
|
+
* @returns A tuple containing [StartRange, ExpectLength]
|
|
213
|
+
*/
|
|
214
|
+
declare const parseRange: (range: string) => [number, number];
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region lib/hls/hls-content-processor.d.ts
|
|
217
|
+
declare class DefaultHlsContentProcessor implements ContentProcessor {
|
|
218
|
+
private static readonly YkDVRegex;
|
|
219
|
+
private static readonly DNSPRegex;
|
|
220
|
+
private static readonly DNSPSubRegex;
|
|
221
|
+
private static readonly OrderFixRegex;
|
|
222
|
+
private static readonly ATVRegex;
|
|
223
|
+
private static readonly ATVRegex2;
|
|
224
|
+
canProcess(extractorType: ExtractorType): boolean;
|
|
225
|
+
process(m3u8Content: string, parserConfig: ParserConfig): string;
|
|
226
|
+
private applyRegexReplacement;
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region lib/hls/hls-extractor.d.ts
|
|
230
|
+
declare class HlsExtractor implements Extractor {
|
|
231
|
+
#private;
|
|
232
|
+
get extractorType(): ExtractorType;
|
|
233
|
+
parserConfig: ParserConfig;
|
|
234
|
+
constructor(parserConfig: ParserConfig);
|
|
235
|
+
preProcessContent(): void;
|
|
236
|
+
preProcessUrl(url: string): string;
|
|
237
|
+
extractStreams(rawText: string): Promise<StreamSpec[]>;
|
|
238
|
+
fetchPlayList(lists: StreamSpec[]): Promise<void>;
|
|
239
|
+
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region lib/hls/hls-key-processor.d.ts
|
|
243
|
+
declare class DefaultHlsKeyProcessor implements KeyProcessor {
|
|
244
|
+
canProcess(extractorType: ExtractorType): boolean;
|
|
245
|
+
process(keyLine: string, m3u8Url: string, _m3u8Content: string, parserConfig: ParserConfig): Promise<EncryptInfo>;
|
|
246
|
+
private getAttribute;
|
|
247
|
+
private fetchKeyWithRetry;
|
|
248
|
+
private preProcessUrl;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region lib/hls/hls-tags.d.ts
|
|
252
|
+
declare const HLS_TAGS: {
|
|
253
|
+
extM3u: string;
|
|
254
|
+
extXTargetDuration: string;
|
|
255
|
+
extXMediaSequence: string;
|
|
256
|
+
extXDiscontinuitySequence: string;
|
|
257
|
+
extXProgramDateTime: string;
|
|
258
|
+
extXMedia: string;
|
|
259
|
+
extXPlaylistType: string;
|
|
260
|
+
extXKey: string;
|
|
261
|
+
extXStreamInf: string;
|
|
262
|
+
extXVersion: string;
|
|
263
|
+
extXAllowCache: string;
|
|
264
|
+
extXEndlist: string;
|
|
265
|
+
extInf: string;
|
|
266
|
+
extIframesOnly: string;
|
|
267
|
+
extXByterange: string;
|
|
268
|
+
extXIframeStreamInf: string;
|
|
269
|
+
extXDiscontinuity: string;
|
|
270
|
+
extXCueOutStart: string;
|
|
271
|
+
extXCueOut: string;
|
|
272
|
+
extIsIndependentSegments: string;
|
|
273
|
+
extXScte35: string;
|
|
274
|
+
extXCueStart: string;
|
|
275
|
+
extXCueEnd: string;
|
|
276
|
+
extXCueSpan: string;
|
|
277
|
+
extXMap: string;
|
|
278
|
+
extXStart: string;
|
|
279
|
+
};
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region lib/hls/hls-utils.d.ts
|
|
282
|
+
/**
|
|
283
|
+
* Extracts length and optional start values from a string formatted as "n[@o]".
|
|
284
|
+
* @param input - The input string.
|
|
285
|
+
* @returns A tuple containing [n (length), o (start)].
|
|
286
|
+
*/
|
|
287
|
+
declare function getRange(input: string): [number, number | null];
|
|
288
|
+
//#endregion
|
|
289
|
+
export { ContentProcessor, DASH_TAGS, DashExtractor, DefaultDashContentProcessor, DefaultHlsContentProcessor, DefaultHlsKeyProcessor, DefaultUrlProcessor, ENCRYPT_METHODS, EXTRACTOR_TYPES, EncryptInfo, EncryptMethod, Extractor, ExtractorType, HLS_TAGS, HlsExtractor, KeyProcessor, MEDIA_TYPES, MediaPart, MediaSegment, MediaType, ParserConfig, ROLE_TYPE, RoleType, StreamExtractor, StreamSpec, UrlProcessor, getRange, parseRange };
|
package/dist/dasha.d.mts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
//#region lib/shared/encrypt-method.d.ts
|
|
2
|
+
declare const ENCRYPT_METHODS: {
|
|
3
|
+
readonly NONE: "none";
|
|
4
|
+
readonly AES_128: "aes-128";
|
|
5
|
+
readonly AES_128_ECB: "aes-128-ecb";
|
|
6
|
+
readonly SAMPLE_AES: "sample-aes";
|
|
7
|
+
readonly SAMPLE_AES_CTR: "sample-aes-ctr";
|
|
8
|
+
readonly CENC: "cenc";
|
|
9
|
+
readonly CHACHA20: "chacha20";
|
|
10
|
+
readonly UNKNOWN: "unknown";
|
|
11
|
+
};
|
|
12
|
+
type EncryptMethod = (typeof ENCRYPT_METHODS)[keyof typeof ENCRYPT_METHODS];
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region lib/shared/encrypt-info.d.ts
|
|
15
|
+
type DrmType = 'widevine' | 'playready' | 'fairplay';
|
|
16
|
+
declare class EncryptInfo {
|
|
17
|
+
method: EncryptMethod;
|
|
18
|
+
key?: Uint8Array;
|
|
19
|
+
iv?: Uint8Array;
|
|
20
|
+
drm: { [key in DrmType]?: {
|
|
21
|
+
keyId?: string;
|
|
22
|
+
pssh?: string;
|
|
23
|
+
} };
|
|
24
|
+
constructor(method?: string | null);
|
|
25
|
+
parseMethod(method?: string | null): EncryptMethod;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region lib/shared/extractor-type.d.ts
|
|
29
|
+
declare const EXTRACTOR_TYPES: {
|
|
30
|
+
readonly MPEG_DASH: "MPEG_DASH";
|
|
31
|
+
readonly HLS: "HLS";
|
|
32
|
+
readonly HTTP_LIVE: "HTTP_LIVE";
|
|
33
|
+
readonly MSS: "MSS";
|
|
34
|
+
};
|
|
35
|
+
type ExtractorType = (typeof EXTRACTOR_TYPES)[keyof typeof EXTRACTOR_TYPES];
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region lib/shared/media-segment.d.ts
|
|
38
|
+
declare class MediaSegment {
|
|
39
|
+
index: number;
|
|
40
|
+
duration: number;
|
|
41
|
+
title?: string;
|
|
42
|
+
dateTime?: Date;
|
|
43
|
+
startRange?: number;
|
|
44
|
+
get stopRange(): number | undefined;
|
|
45
|
+
expectLength?: number;
|
|
46
|
+
encryptInfo: EncryptInfo;
|
|
47
|
+
get isEncrypted(): boolean;
|
|
48
|
+
url: string;
|
|
49
|
+
nameFromVar?: string;
|
|
50
|
+
equals(segment: unknown): boolean;
|
|
51
|
+
getHashCode(): string;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region lib/shared/media-part.d.ts
|
|
55
|
+
declare class MediaPart {
|
|
56
|
+
mediaSegments: MediaSegment[];
|
|
57
|
+
constructor(segments?: MediaSegment[]);
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region lib/shared/media-type.d.ts
|
|
61
|
+
declare const MEDIA_TYPES: {
|
|
62
|
+
readonly VIDEO: "video";
|
|
63
|
+
readonly AUDIO: "audio";
|
|
64
|
+
readonly SUBTITLES: "subtitle";
|
|
65
|
+
readonly CLOSED_CAPTIONS: "closed-captions";
|
|
66
|
+
};
|
|
67
|
+
type MediaType = (typeof MEDIA_TYPES)[keyof typeof MEDIA_TYPES];
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region lib/shared/playlist.d.ts
|
|
70
|
+
declare class Playlist {
|
|
71
|
+
url: string;
|
|
72
|
+
isLive: boolean;
|
|
73
|
+
refreshIntervalMs: number;
|
|
74
|
+
get totalDuration(): number;
|
|
75
|
+
targetDuration?: number;
|
|
76
|
+
mediaInit?: MediaSegment;
|
|
77
|
+
mediaParts: MediaPart[];
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region lib/shared/role-type.d.ts
|
|
81
|
+
declare const ROLE_TYPE: {
|
|
82
|
+
Subtitle: number;
|
|
83
|
+
Main: number;
|
|
84
|
+
Alternate: number;
|
|
85
|
+
Supplementary: number;
|
|
86
|
+
Commentary: number;
|
|
87
|
+
Dub: number;
|
|
88
|
+
Description: number;
|
|
89
|
+
Sign: number;
|
|
90
|
+
Metadata: number;
|
|
91
|
+
ForcedSubtitle: number;
|
|
92
|
+
};
|
|
93
|
+
type RoleType = (typeof ROLE_TYPE)[keyof typeof ROLE_TYPE];
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region lib/shared/stream-spec.d.ts
|
|
96
|
+
declare class StreamSpec {
|
|
97
|
+
mediaType?: MediaType;
|
|
98
|
+
groupId: string | null;
|
|
99
|
+
language?: string;
|
|
100
|
+
name?: string;
|
|
101
|
+
default?: boolean;
|
|
102
|
+
skippedDuration?: number;
|
|
103
|
+
bandwidth?: number;
|
|
104
|
+
codecs: string | null;
|
|
105
|
+
resolution?: string;
|
|
106
|
+
frameRate?: number;
|
|
107
|
+
channels: string | null;
|
|
108
|
+
extension: string | null;
|
|
109
|
+
role?: RoleType;
|
|
110
|
+
videoRange?: string;
|
|
111
|
+
characteristics?: string;
|
|
112
|
+
publishTime?: Date;
|
|
113
|
+
audioId?: string;
|
|
114
|
+
videoId?: string;
|
|
115
|
+
subtitleId?: string;
|
|
116
|
+
periodId: string | null;
|
|
117
|
+
url: string;
|
|
118
|
+
originalUrl: string;
|
|
119
|
+
playlist?: Playlist;
|
|
120
|
+
get segmentsCount(): number;
|
|
121
|
+
toShortString(): string;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region lib/extractor.d.ts
|
|
125
|
+
interface Extractor {
|
|
126
|
+
extractorType: ExtractorType;
|
|
127
|
+
extractStreams(rawText: string): Promise<StreamSpec[]>;
|
|
128
|
+
fetchPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
129
|
+
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
130
|
+
preProcessUrl(url: string): string;
|
|
131
|
+
preProcessContent(): void;
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region lib/processor.d.ts
|
|
135
|
+
interface ContentProcessor {
|
|
136
|
+
canProcess(extractorType: ExtractorType, rawText: string, parserConfig: ParserConfig): boolean;
|
|
137
|
+
process(rawText: string, parserConfig: ParserConfig): string;
|
|
138
|
+
}
|
|
139
|
+
interface KeyProcessor {
|
|
140
|
+
canProcess(extractorType: ExtractorType, keyLine: string, m3u8Url: string, m3u8Content: string, parserConfig: ParserConfig): boolean;
|
|
141
|
+
process(keyLine: string, m3u8Url: string, m3u8Content: string, parserConfig: ParserConfig): Promise<EncryptInfo>;
|
|
142
|
+
}
|
|
143
|
+
interface UrlProcessor {
|
|
144
|
+
canProcess(extractorType: ExtractorType, originalUrl: string, parserConfig: ParserConfig): boolean;
|
|
145
|
+
process(originalUrl: string, parserConfig: ParserConfig): string;
|
|
146
|
+
}
|
|
147
|
+
declare class DefaultUrlProcessor implements UrlProcessor {
|
|
148
|
+
canProcess(_extractorType: ExtractorType, _originalUrl: string, parserConfig: ParserConfig): boolean;
|
|
149
|
+
process(url: string, parserConfig: ParserConfig): string;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region lib/parser-config.d.ts
|
|
153
|
+
declare class ParserConfig {
|
|
154
|
+
url: string;
|
|
155
|
+
originalUrl: string;
|
|
156
|
+
baseUrl?: string;
|
|
157
|
+
customParserArgs: Record<string, string>;
|
|
158
|
+
headers: Record<string, string>;
|
|
159
|
+
contentProcessors: ContentProcessor[];
|
|
160
|
+
urlProcessors: UrlProcessor[];
|
|
161
|
+
keyProcessors: KeyProcessor[];
|
|
162
|
+
customMethod?: EncryptMethod;
|
|
163
|
+
customKey?: Uint8Array;
|
|
164
|
+
customIv?: Uint8Array;
|
|
165
|
+
urlProcessorArgs?: string;
|
|
166
|
+
appendUrlParams: boolean;
|
|
167
|
+
keyRetryCount: number;
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region lib/stream-extractor.d.ts
|
|
171
|
+
declare class StreamExtractor {
|
|
172
|
+
#private;
|
|
173
|
+
constructor(parserConfig?: ParserConfig);
|
|
174
|
+
get extractorType(): ExtractorType;
|
|
175
|
+
loadSourceFromUrl(url: string): Promise<void>;
|
|
176
|
+
loadSourceFromText(rawText: string, url?: string): void;
|
|
177
|
+
extractStreams(): Promise<StreamSpec[]>;
|
|
178
|
+
fetchPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
179
|
+
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region lib/dash/dash-content-processor.d.ts
|
|
183
|
+
declare class DefaultDashContentProcessor implements ContentProcessor {
|
|
184
|
+
canProcess(extractorType: ExtractorType, mpdContent: string): boolean;
|
|
185
|
+
process(mpdContent: string): string;
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region lib/dash/dash-extractor.d.ts
|
|
189
|
+
declare class DashExtractor implements Extractor {
|
|
190
|
+
#private;
|
|
191
|
+
get extractorType(): ExtractorType;
|
|
192
|
+
constructor(parserConfig: ParserConfig);
|
|
193
|
+
extractStreams(rawText: string): Promise<StreamSpec[]>;
|
|
194
|
+
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
195
|
+
fetchPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
196
|
+
preProcessUrl(url: string): string;
|
|
197
|
+
preProcessContent(): void;
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region lib/dash/dash-tags.d.ts
|
|
201
|
+
declare const DASH_TAGS: {
|
|
202
|
+
TemplateRepresentationID: string;
|
|
203
|
+
TemplateBandwidth: string;
|
|
204
|
+
TemplateNumber: string;
|
|
205
|
+
TemplateTime: string;
|
|
206
|
+
};
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region lib/dash/dash-utils.d.ts
|
|
209
|
+
/**
|
|
210
|
+
* Extracts StartRange and ExpectLength information from a string like "100-300"
|
|
211
|
+
* @param range - The range string in the format "start-end"
|
|
212
|
+
* @returns A tuple containing [StartRange, ExpectLength]
|
|
213
|
+
*/
|
|
214
|
+
declare const parseRange: (range: string) => [number, number];
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region lib/hls/hls-content-processor.d.ts
|
|
217
|
+
declare class DefaultHlsContentProcessor implements ContentProcessor {
|
|
218
|
+
private static readonly YkDVRegex;
|
|
219
|
+
private static readonly DNSPRegex;
|
|
220
|
+
private static readonly DNSPSubRegex;
|
|
221
|
+
private static readonly OrderFixRegex;
|
|
222
|
+
private static readonly ATVRegex;
|
|
223
|
+
private static readonly ATVRegex2;
|
|
224
|
+
canProcess(extractorType: ExtractorType): boolean;
|
|
225
|
+
process(m3u8Content: string, parserConfig: ParserConfig): string;
|
|
226
|
+
private applyRegexReplacement;
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region lib/hls/hls-extractor.d.ts
|
|
230
|
+
declare class HlsExtractor implements Extractor {
|
|
231
|
+
#private;
|
|
232
|
+
get extractorType(): ExtractorType;
|
|
233
|
+
parserConfig: ParserConfig;
|
|
234
|
+
constructor(parserConfig: ParserConfig);
|
|
235
|
+
preProcessContent(): void;
|
|
236
|
+
preProcessUrl(url: string): string;
|
|
237
|
+
extractStreams(rawText: string): Promise<StreamSpec[]>;
|
|
238
|
+
fetchPlayList(lists: StreamSpec[]): Promise<void>;
|
|
239
|
+
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region lib/hls/hls-key-processor.d.ts
|
|
243
|
+
declare class DefaultHlsKeyProcessor implements KeyProcessor {
|
|
244
|
+
canProcess(extractorType: ExtractorType): boolean;
|
|
245
|
+
process(keyLine: string, m3u8Url: string, _m3u8Content: string, parserConfig: ParserConfig): Promise<EncryptInfo>;
|
|
246
|
+
private getAttribute;
|
|
247
|
+
private fetchKeyWithRetry;
|
|
248
|
+
private preProcessUrl;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region lib/hls/hls-tags.d.ts
|
|
252
|
+
declare const HLS_TAGS: {
|
|
253
|
+
extM3u: string;
|
|
254
|
+
extXTargetDuration: string;
|
|
255
|
+
extXMediaSequence: string;
|
|
256
|
+
extXDiscontinuitySequence: string;
|
|
257
|
+
extXProgramDateTime: string;
|
|
258
|
+
extXMedia: string;
|
|
259
|
+
extXPlaylistType: string;
|
|
260
|
+
extXKey: string;
|
|
261
|
+
extXStreamInf: string;
|
|
262
|
+
extXVersion: string;
|
|
263
|
+
extXAllowCache: string;
|
|
264
|
+
extXEndlist: string;
|
|
265
|
+
extInf: string;
|
|
266
|
+
extIframesOnly: string;
|
|
267
|
+
extXByterange: string;
|
|
268
|
+
extXIframeStreamInf: string;
|
|
269
|
+
extXDiscontinuity: string;
|
|
270
|
+
extXCueOutStart: string;
|
|
271
|
+
extXCueOut: string;
|
|
272
|
+
extIsIndependentSegments: string;
|
|
273
|
+
extXScte35: string;
|
|
274
|
+
extXCueStart: string;
|
|
275
|
+
extXCueEnd: string;
|
|
276
|
+
extXCueSpan: string;
|
|
277
|
+
extXMap: string;
|
|
278
|
+
extXStart: string;
|
|
279
|
+
};
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region lib/hls/hls-utils.d.ts
|
|
282
|
+
/**
|
|
283
|
+
* Extracts length and optional start values from a string formatted as "n[@o]".
|
|
284
|
+
* @param input - The input string.
|
|
285
|
+
* @returns A tuple containing [n (length), o (start)].
|
|
286
|
+
*/
|
|
287
|
+
declare function getRange(input: string): [number, number | null];
|
|
288
|
+
//#endregion
|
|
289
|
+
export { ContentProcessor, DASH_TAGS, DashExtractor, DefaultDashContentProcessor, DefaultHlsContentProcessor, DefaultHlsKeyProcessor, DefaultUrlProcessor, ENCRYPT_METHODS, EXTRACTOR_TYPES, EncryptInfo, EncryptMethod, Extractor, ExtractorType, HLS_TAGS, HlsExtractor, KeyProcessor, MEDIA_TYPES, MediaPart, MediaSegment, MediaType, ParserConfig, ROLE_TYPE, RoleType, StreamExtractor, StreamSpec, UrlProcessor, getRange, parseRange };
|