dasha 2.2.0 → 2.2.3
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/lib/manifest.js +7 -5
- package/lib/utils.js +8 -7
- package/package.json +6 -6
package/lib/manifest.js
CHANGED
|
@@ -21,7 +21,7 @@ class Manifest {
|
|
|
21
21
|
getVideoTrack(height) {
|
|
22
22
|
const isVideoAdaptationSet = (adaptationSet) =>
|
|
23
23
|
adaptationSet.contentType === CONTENT_TYPE.video ||
|
|
24
|
-
adaptationSet.mimeType
|
|
24
|
+
adaptationSet.mimeType?.includes('video') ||
|
|
25
25
|
adaptationSet.maxWidth ||
|
|
26
26
|
adaptationSet.maxHeight;
|
|
27
27
|
const adaptationSets = this.periods
|
|
@@ -29,7 +29,9 @@ class Manifest {
|
|
|
29
29
|
.flat(1)
|
|
30
30
|
.filter(isVideoAdaptationSet);
|
|
31
31
|
const representations = adaptationSets.map((a) => a.representations).flat(2);
|
|
32
|
-
const
|
|
32
|
+
const matchesInHeight = representations.filter((r) => r.height === height);
|
|
33
|
+
const matchesInId = representations.filter((r) => r.id.includes(height));
|
|
34
|
+
const matches = matchesInHeight?.length ? matchesInHeight : matchesInId;
|
|
33
35
|
const representation = this.findBestRepresentation(matches.length ? matches : representations);
|
|
34
36
|
const adaptationSet = adaptationSets.find((a) => a.representations.includes(representation));
|
|
35
37
|
return {
|
|
@@ -42,14 +44,14 @@ class Manifest {
|
|
|
42
44
|
size: Math.ceil((representation.bandwidth / 8e6) * this.mediaPresentationDuration), // MB
|
|
43
45
|
width: representation.width,
|
|
44
46
|
height: representation.height,
|
|
45
|
-
quality: getQualityLabel(representation.
|
|
47
|
+
quality: getQualityLabel(representation.width),
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
getAudioTracks(languages) {
|
|
50
52
|
const isAudioAdaptationSet = (adaptationSet) =>
|
|
51
53
|
(adaptationSet.contentType === CONTENT_TYPE.audio ||
|
|
52
|
-
adaptationSet.mimeType
|
|
54
|
+
adaptationSet.mimeType?.includes('audio')) &&
|
|
53
55
|
!adaptationSet.maxWidth;
|
|
54
56
|
const adaptationSets = this.periods
|
|
55
57
|
.map((p) => p.adaptationSets)
|
|
@@ -84,7 +86,7 @@ class Manifest {
|
|
|
84
86
|
getSubtitleTracks(languages) {
|
|
85
87
|
const isSubtitleAdaptationSet = (adaptationSet) =>
|
|
86
88
|
(adaptationSet.contentType === CONTENT_TYPE.text ||
|
|
87
|
-
adaptationSet.mimeType
|
|
89
|
+
adaptationSet.mimeType?.includes('text')) &&
|
|
88
90
|
!adaptationSet.maxWidth;
|
|
89
91
|
const adaptationSets = this.periods
|
|
90
92
|
.map((p) => p.adaptationSets)
|
package/lib/utils.js
CHANGED
|
@@ -34,14 +34,15 @@ const parseDuration = (durationString) => {
|
|
|
34
34
|
return isFinite(d) ? d : null;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const getQualityLabel = (
|
|
38
|
-
const
|
|
39
|
-
if (isNaN(
|
|
37
|
+
const getQualityLabel = (videoWidth) => {
|
|
38
|
+
const width = typeof videoWidth === 'number' ? videoWidth : parseInt(videoWidth);
|
|
39
|
+
if (isNaN(width)) return;
|
|
40
40
|
let label = 'SD';
|
|
41
|
-
if (
|
|
42
|
-
if (
|
|
43
|
-
if (
|
|
44
|
-
if (
|
|
41
|
+
if (width >= 1280) label = 'HD';
|
|
42
|
+
if (width >= 1920) label = 'Full HD';
|
|
43
|
+
if (width >= 3840) label = 'UHD';
|
|
44
|
+
if (width >= 4096) label = '4K';
|
|
45
|
+
if (width >= 7680) label = '8K';
|
|
45
46
|
return label;
|
|
46
47
|
};
|
|
47
48
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dasha",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"author": "Vitaliy Gashkov <vitnore@gmail.com>",
|
|
5
5
|
"description": "Simple MPEG-DASH MPD parser",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"format:check": "prettier --loglevel warn --check \"**/*.{ts,js,json,yaml}\""
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/node": "^17.0.
|
|
38
|
-
"eslint": "^8.
|
|
39
|
-
"eslint-config-prettier": "^8.
|
|
37
|
+
"@types/node": "^17.0.23",
|
|
38
|
+
"eslint": "^8.12.0",
|
|
39
|
+
"eslint-config-prettier": "^8.5.0",
|
|
40
40
|
"eslint-plugin-import": "^2.25.4",
|
|
41
41
|
"eslint-plugin-prettier": "^4.0.0",
|
|
42
42
|
"jest": "^27.5.1",
|
|
43
|
-
"prettier": "^2.
|
|
44
|
-
"typescript": "^4.
|
|
43
|
+
"prettier": "^2.6.1",
|
|
44
|
+
"typescript": "^4.6.3"
|
|
45
45
|
}
|
|
46
46
|
}
|