dasha 2.2.4 → 2.3.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.
Files changed (2) hide show
  1. package/lib/manifest.js +15 -9
  2. package/package.json +6 -6
package/lib/manifest.js CHANGED
@@ -18,6 +18,11 @@ class Manifest {
18
18
  for (const key of Object.keys(manifest)) this[key] = manifest[key];
19
19
  }
20
20
 
21
+ addBaseUrl(value) {
22
+ if (Array.isArray(this.baseUrls)) this.baseUrls.push({ value });
23
+ else this.baseUrls = [{ value }];
24
+ }
25
+
21
26
  getVideoTrack(height) {
22
27
  const isVideoAdaptationSet = (adaptationSet) =>
23
28
  adaptationSet.contentType === CONTENT_TYPE.video ||
@@ -49,23 +54,22 @@ class Manifest {
49
54
  }
50
55
 
51
56
  getAudioTracks(languages) {
52
- const isAudioAdaptationSet = (adaptationSet) =>
57
+ const filterAudio = (adaptationSet) =>
53
58
  (adaptationSet.contentType === CONTENT_TYPE.audio ||
54
59
  adaptationSet.mimeType?.includes('audio') ||
55
60
  adaptationSet.representations.some((r) => r.mimeType?.includes('audio'))) &&
56
61
  !adaptationSet.maxWidth;
62
+ const filterLanguages = (adaptationSet) =>
63
+ languages?.length ? languages.some((lang) => adaptationSet.lang.includes(lang)) : true;
57
64
  const adaptationSets = this.periods
58
65
  .map((p) => p.adaptationSets)
59
66
  .flat(1)
60
- .filter(isAudioAdaptationSet);
61
-
62
- const representations = adaptationSets.map((a) => a.representations).flat(2);
63
- const matches = representations.filter((r) => languages?.some((lang) => r.lang.includes(lang)));
64
- const selectedRepresentations = matches?.length ? matches : representations;
67
+ .filter(filterAudio)
68
+ .filter(filterLanguages);
65
69
 
66
70
  const tracks = [];
67
- for (const representation of selectedRepresentations) {
68
- const adaptationSet = adaptationSets.find((a) => a.representations.includes(representation));
71
+ for (const adaptationSet of adaptationSets) {
72
+ const representation = this.findBestRepresentation(adaptationSet.representations);
69
73
  const track = {
70
74
  id: tracks.length,
71
75
  type: CONTENT_TYPE.audio,
@@ -95,7 +99,9 @@ class Manifest {
95
99
  .filter(isSubtitleAdaptationSet);
96
100
 
97
101
  const representations = adaptationSets.map((a) => a.representations).flat(2);
98
- const matches = representations.filter((r) => languages?.some((lang) => r.lang.includes(lang)));
102
+ const matches = representations.filter((r) =>
103
+ languages?.length ? languages?.some((lang) => r.lang.includes(lang)) : true
104
+ );
99
105
  const selectedRepresentations = matches?.length ? matches : representations;
100
106
 
101
107
  const tracks = [];
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dasha",
3
- "version": "2.2.4",
4
- "author": "Vitaliy Gashkov <vitnore@gmail.com>",
5
- "description": "Simple MPEG-DASH MPD parser",
3
+ "version": "2.3.0",
4
+ "author": "Vitaly Gashkov <vitalygashkov@outlook.com>",
5
+ "description": "MPD-manifest parser for MPEG DASH",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "mpeg",
@@ -19,11 +19,11 @@
19
19
  ],
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "git+https://github.com/vitnore/dasha.git"
22
+ "url": "git+https://github.com/vitalygashkov/dasha.git"
23
23
  },
24
24
  "funding": {
25
- "type": "patreon",
26
- "url": "https://www.patreon.com/vitnore"
25
+ "type": "individual",
26
+ "url": "https://boosty.to/vitalygashkov"
27
27
  },
28
28
  "scripts": {
29
29
  "test": "jest",