dasha 2.2.0 → 2.2.1

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 CHANGED
@@ -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 matches = representations.filter((r) => r.height === height);
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,7 +44,7 @@ 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.height),
47
+ quality: getQualityLabel(representation.width),
46
48
  };
47
49
  }
48
50
 
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 = (videoHeight) => {
38
- const height = typeof videoHeight === 'number' ? videoHeight : parseInt(videoHeight);
39
- if (isNaN(height)) return;
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 (height >= 720) label = 'HD';
42
- if (height >= 1080) label = 'Full HD';
43
- if (height >= 2160) label = '4K';
44
- if (height >= 4320) label = '8K';
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.0",
3
+ "version": "2.2.1",
4
4
  "author": "Vitaliy Gashkov <vitnore@gmail.com>",
5
5
  "description": "Simple MPEG-DASH MPD parser",
6
6
  "license": "Apache-2.0",