dasha 3.1.6 → 3.1.7

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/hls.js +17 -24
  2. package/package.json +1 -1
package/lib/hls.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  const { dirname, basename } = require('node:path');
4
4
  const m3u8Parser = require('m3u8-parser');
5
- const { parseBitrate, getQualityLabel } = require('./util');
6
5
  const {
7
6
  createResolutionFilter,
8
7
  createVideoQualityFilter,
@@ -24,8 +23,7 @@ const parseM3u8 = (manifestString) => {
24
23
 
25
24
  const fetchPlaylist = async (url) => {
26
25
  const response = await fetch(url);
27
- if (!response.ok)
28
- throw new Error(`Failed to fetch playlist (${response.status}): ${url}`);
26
+ if (!response.ok) throw new Error(`Failed to fetch playlist (${response.status}): ${url}`);
29
27
  const text = await response.text();
30
28
  return parseM3u8(text);
31
29
  };
@@ -33,8 +31,7 @@ const fetchPlaylist = async (url) => {
33
31
  const parseUrl = (playlistUri, manifestUri) => {
34
32
  let value = playlistUri;
35
33
  if (!value.startsWith('https://'))
36
- value =
37
- new URL(value, manifestUri).toString() + new URL(manifestUri).search;
34
+ value = new URL(value, manifestUri).toString() + new URL(manifestUri).search;
38
35
  return value;
39
36
  };
40
37
 
@@ -77,23 +74,21 @@ const getSubtitlePlaylists = (m3u8, manifestUri) => {
77
74
  const getVideoPlaylists = (m3u8, manifestUri) => {
78
75
  if (!m3u8.playlists) return [];
79
76
  return m3u8.playlists.map((data) => {
80
- const bandwidth = data.attributes?.BANDWIDTH;
81
- const url = data.resolvedUri || parseUrl(data.uri, manifestUri);
82
- const track = {
77
+ const track = createVideoTrack({
83
78
  id: data.uri.replace('/', ''),
84
- bitrate: parseBitrate(bandwidth),
85
- url,
86
- };
87
- track.type = 'video';
88
- if (data.attributes.RESOLUTION) {
89
- track.resolution = data.attributes.RESOLUTION;
90
- track.quality = getQualityLabel(track.resolution);
91
- }
92
- if (data.attributes['VIDEO-RANGE'])
93
- track.dynamicRange = data.attributes['VIDEO-RANGE'];
94
- if (data.attributes.CODECS) track.codecs = data.attributes.CODECS;
95
- if (data.attributes['FRAME-RATE'])
96
- track.frameRate = data.attributes['FRAME-RATE'];
79
+ label: data.attributes['NAME'],
80
+ type: 'video',
81
+ codec: data.attributes.CODECS,
82
+ dynamicRange: data.attributes['VIDEO-RANGE'],
83
+ bitrate: data.attributes?.BANDWIDTH,
84
+ width: data.attributes.RESOLUTION?.width,
85
+ height: data.attributes.RESOLUTION?.height,
86
+ fps: data.attributes['FRAME-RATE'],
87
+ language: data.attributes['LANGUAGE'],
88
+ });
89
+
90
+ track.url = data.resolvedUri || parseUrl(data.uri, manifestUri);
91
+
97
92
  return track;
98
93
  });
99
94
  };
@@ -168,9 +163,7 @@ const parseManifest = async (manifestString, manifestUri) => {
168
163
  // TODO: Handle audio-only manifests
169
164
  const { pathname } = new URL(manifestUri);
170
165
  const isAudio =
171
- pathname.includes('.m4a') ||
172
- pathname.includes('.mp3') ||
173
- pathname.includes('.opus');
166
+ pathname.includes('.m4a') || pathname.includes('.mp3') || pathname.includes('.opus');
174
167
  if (isAudio) {
175
168
  const track = createAudioTrack({
176
169
  id: 'audio' + basename(pathname),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dasha",
3
- "version": "3.1.6",
3
+ "version": "3.1.7",
4
4
  "description": "Streaming manifest parser",
5
5
  "files": [
6
6
  "dasha.js",