dasha 4.0.0-alpha.1 → 4.0.0-alpha.11

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 CHANGED
@@ -6,10 +6,14 @@
6
6
 
7
7
  Library for parsing MPEG-DASH (.mpd) and HLS (.m3u8) manifests. Made with the purpose of obtaining a simplified representation convenient for further downloading of segments.
8
8
 
9
+ > [!WARNING]
10
+ > This README is for the alpha version. Info about latest stable version is available on [NPM](https://www.npmjs.com/package/dasha/v/3.1.5) or [another GitHub branch](https://github.com/azot-labs/dasha/tree/v3).
11
+
12
+
9
13
  ## Install
10
14
 
11
15
  ```shell
12
- npm i dasha
16
+ npm i dasha@alpha
13
17
  ```
14
18
 
15
19
  ## Usage
@@ -19,13 +23,16 @@ import fs from 'node:fs/promises';
19
23
  import { parse } from 'dasha';
20
24
 
21
25
  const url = 'https://dash.akamaized.net/dash264/TestCases/1a/sony/SNE_DASH_SD_CASE1A_REVISED.mpd';
22
- const body = await fetch(url).then((res) => res.text());
23
- const manifest = await parse(body, url);
24
-
25
- for (const track of manifest.tracks.all) {
26
- for (const segment of track.segments) {
27
- const content = await fetch(url).then((res) => res.arrayBuffer());
28
- await fs.appendFile(`${track.id}.mp4`, content);
26
+ const streamExtractor = new StreamExtractor();
27
+ await streamExtractor.loadSourceFromUrl(url);
28
+ const streams = await streamExtractor.extractStreams();
29
+
30
+ for (const stream of streams) {
31
+ const segments = stream.playlist?.mediaParts[0].mediaSegments || [];
32
+ const filename = `${stream.name}_${stream.groupId}`;
33
+ for (const segment of segments) {
34
+ const content = await fetch(segment.url).then((res) => res.arrayBuffer());
35
+ await fs.appendFile(`${filename}.${stream.extension}`, content);
29
36
  }
30
37
  }
31
38
  ```