dasha 4.0.0-alpha.10 → 4.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dasha.cjs +9 -7
- package/dist/dasha.mjs +3 -2
- package/package.json +5 -4
package/dist/dasha.cjs
CHANGED
|
@@ -25,6 +25,8 @@ let node_crypto = require("node:crypto");
|
|
|
25
25
|
node_crypto = __toESM(node_crypto);
|
|
26
26
|
let node_fs = require("node:fs");
|
|
27
27
|
let barsic = require("barsic");
|
|
28
|
+
let ky = require("ky");
|
|
29
|
+
ky = __toESM(ky);
|
|
28
30
|
let node_fs_promises = require("node:fs/promises");
|
|
29
31
|
let node_url = require("node:url");
|
|
30
32
|
let node_path = require("node:path");
|
|
@@ -505,7 +507,7 @@ var DefaultHlsKeyProcessor = class {
|
|
|
505
507
|
async fetchKeyWithRetry(url, parserConfig) {
|
|
506
508
|
let retryCount = parserConfig.keyRetryCount ?? 3;
|
|
507
509
|
while (retryCount >= 0) try {
|
|
508
|
-
const response = await
|
|
510
|
+
const response = await (0, ky.default)(url, { headers: parserConfig.headers });
|
|
509
511
|
return new Uint8Array(await response.arrayBuffer());
|
|
510
512
|
} catch (error) {
|
|
511
513
|
if (error.message.includes("scheme is not supported")) throw error;
|
|
@@ -1155,7 +1157,7 @@ var DashExtractor = class DashExtractor {
|
|
|
1155
1157
|
const schemeIdUri = contentProtection.getAttribute("schemeIdUri");
|
|
1156
1158
|
const drmData = {
|
|
1157
1159
|
keyId: contentProtection.getAttribute("cenc:default_KID") || void 0,
|
|
1158
|
-
pssh: contentProtection.getElementsByTagName("cenc:pssh")[0]?.textContent || void 0
|
|
1160
|
+
pssh: (contentProtection.getElementsByTagName("cenc:pssh")[0]?.textContent || void 0)?.trim()
|
|
1159
1161
|
};
|
|
1160
1162
|
if (schemeIdUri?.includes(widevineSystemId)) encryptInfo.drm.widevine = drmData;
|
|
1161
1163
|
else if (schemeIdUri?.includes(playreadySystemId)) encryptInfo.drm.playready = drmData;
|
|
@@ -1163,7 +1165,7 @@ var DashExtractor = class DashExtractor {
|
|
|
1163
1165
|
}
|
|
1164
1166
|
if (streamInfo.playlist.mediaInit) streamInfo.playlist.mediaInit.encryptInfo = encryptInfo;
|
|
1165
1167
|
const segments = streamInfo.playlist.mediaParts[0].mediaSegments;
|
|
1166
|
-
for (const segment of segments) if (!segment.encryptInfo) segment.encryptInfo = encryptInfo;
|
|
1168
|
+
for (const segment of segments) if (!segment.encryptInfo || segment.encryptInfo.method === "unknown") segment.encryptInfo = encryptInfo;
|
|
1167
1169
|
}
|
|
1168
1170
|
const _index = streamInfos.findIndex((item) => item.type === streamInfo.type && item.periodId !== streamInfo.periodId && item.groupId === streamInfo.groupId && (item.type === "video" && streamInfo.type === "video" ? item.width === streamInfo.width && item.height === streamInfo.height : true));
|
|
1169
1171
|
if (_index > -1) if (isLive) {} else if (streamInfos[_index].playlist.mediaParts.at(-1).mediaSegments.at(-1).url !== streamInfo.playlist.mediaParts[0].mediaSegments.at(-1)?.url) {
|
|
@@ -1201,7 +1203,7 @@ var DashExtractor = class DashExtractor {
|
|
|
1201
1203
|
}
|
|
1202
1204
|
async refreshPlayList(streamInfos) {
|
|
1203
1205
|
if (!streamInfos.length) return;
|
|
1204
|
-
const response = await
|
|
1206
|
+
const response = await (0, ky.default)(this.#parserConfig.url, this.#parserConfig.headers).catch(() => (0, ky.default)(this.#parserConfig.originalUrl, this.#parserConfig.headers));
|
|
1205
1207
|
const rawText = await response.text();
|
|
1206
1208
|
const url = response.url;
|
|
1207
1209
|
this.#parserConfig.url = url;
|
|
@@ -1491,12 +1493,12 @@ var HlsExtractor = class {
|
|
|
1491
1493
|
const filePath = new URL(url).pathname;
|
|
1492
1494
|
this.#m3u8Content = await (0, node_fs_promises.readFile)(filePath, "utf8");
|
|
1493
1495
|
} else if (url.startsWith("http")) try {
|
|
1494
|
-
const response = await
|
|
1496
|
+
const response = await (0, ky.default)(url, { headers: this.parserConfig.headers });
|
|
1495
1497
|
url = response.url;
|
|
1496
1498
|
this.#m3u8Content = await response.text();
|
|
1497
1499
|
} catch (e) {
|
|
1498
1500
|
if (this.parserConfig.originalUrl.startsWith("http") && url !== this.parserConfig.originalUrl) {
|
|
1499
|
-
const response = await
|
|
1501
|
+
const response = await (0, ky.default)(this.parserConfig.originalUrl, { headers: this.parserConfig.headers });
|
|
1500
1502
|
url = response.url;
|
|
1501
1503
|
this.#m3u8Content = await response.text();
|
|
1502
1504
|
}
|
|
@@ -1563,7 +1565,7 @@ var StreamExtractor = class {
|
|
|
1563
1565
|
this.#setUrl(url);
|
|
1564
1566
|
} else if (url.startsWith("http")) {
|
|
1565
1567
|
this.#parserConfig.originalUrl = url;
|
|
1566
|
-
const response = await
|
|
1568
|
+
const response = await (0, ky.default)(url, { headers: this.#parserConfig.headers });
|
|
1567
1569
|
this.#rawText = await response.text();
|
|
1568
1570
|
this.#parserConfig.url = response.url;
|
|
1569
1571
|
} else if ((0, node_fs.existsSync)(url)) {
|
package/dist/dasha.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { b } from "barsic";
|
|
4
|
+
import fetch from "ky";
|
|
4
5
|
import { readFile } from "node:fs/promises";
|
|
5
6
|
import { pathToFileURL } from "node:url";
|
|
6
7
|
import path from "node:path";
|
|
@@ -1130,7 +1131,7 @@ var DashExtractor = class DashExtractor {
|
|
|
1130
1131
|
const schemeIdUri = contentProtection.getAttribute("schemeIdUri");
|
|
1131
1132
|
const drmData = {
|
|
1132
1133
|
keyId: contentProtection.getAttribute("cenc:default_KID") || void 0,
|
|
1133
|
-
pssh: contentProtection.getElementsByTagName("cenc:pssh")[0]?.textContent || void 0
|
|
1134
|
+
pssh: (contentProtection.getElementsByTagName("cenc:pssh")[0]?.textContent || void 0)?.trim()
|
|
1134
1135
|
};
|
|
1135
1136
|
if (schemeIdUri?.includes(widevineSystemId)) encryptInfo.drm.widevine = drmData;
|
|
1136
1137
|
else if (schemeIdUri?.includes(playreadySystemId)) encryptInfo.drm.playready = drmData;
|
|
@@ -1138,7 +1139,7 @@ var DashExtractor = class DashExtractor {
|
|
|
1138
1139
|
}
|
|
1139
1140
|
if (streamInfo.playlist.mediaInit) streamInfo.playlist.mediaInit.encryptInfo = encryptInfo;
|
|
1140
1141
|
const segments = streamInfo.playlist.mediaParts[0].mediaSegments;
|
|
1141
|
-
for (const segment of segments) if (!segment.encryptInfo) segment.encryptInfo = encryptInfo;
|
|
1142
|
+
for (const segment of segments) if (!segment.encryptInfo || segment.encryptInfo.method === "unknown") segment.encryptInfo = encryptInfo;
|
|
1142
1143
|
}
|
|
1143
1144
|
const _index = streamInfos.findIndex((item) => item.type === streamInfo.type && item.periodId !== streamInfo.periodId && item.groupId === streamInfo.groupId && (item.type === "video" && streamInfo.type === "video" ? item.width === streamInfo.width && item.height === streamInfo.height : true));
|
|
1144
1145
|
if (_index > -1) if (isLive) {} else if (streamInfos[_index].playlist.mediaParts.at(-1).mediaSegments.at(-1).url !== streamInfo.playlist.mediaParts[0].mediaSegments.at(-1)?.url) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dasha",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.12",
|
|
4
4
|
"description": "Streaming manifest parser",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -58,12 +58,13 @@
|
|
|
58
58
|
}
|
|
59
59
|
],
|
|
60
60
|
"engines": {
|
|
61
|
-
"node": ">=
|
|
61
|
+
"node": ">=22.16"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@xmldom/xmldom": "^0.9.8",
|
|
65
65
|
"barsic": "^0.2.0",
|
|
66
|
-
"
|
|
66
|
+
"ky": "^1.14.3",
|
|
67
|
+
"temporal-polyfill": "^0.3.2"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
70
|
"@eslint/js": "^9.39.1",
|
|
@@ -76,6 +77,6 @@
|
|
|
76
77
|
"tsdown": "^0.16.1",
|
|
77
78
|
"typescript": "^5.9.3",
|
|
78
79
|
"typescript-eslint": "^8.46.3",
|
|
79
|
-
"vitest": "^4.0
|
|
80
|
+
"vitest": "^4.1.0"
|
|
80
81
|
}
|
|
81
82
|
}
|