Skip to content

Commit a25a9e7

Browse files
committed
fix: Map default and autoSelect in EXT-X-MEDIA and EXT-X-CUE-OUT with number only format
1 parent 01fba1b commit a25a9e7

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

apps/stitcher/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dev": "bun --watch --inspect=ws://localhost:6500/sprs-stitcher ./src/index.ts",
77
"dev:wrangler": "wrangler dev ./src/index.ts",
88
"build": "bun build ./src/index.ts --target=bun --outdir=./dist",
9-
"deploy:wrangler": "wrangler deploy --minify ./src/index.ts",
9+
"deploy:wrangler": "npx wrangler deploy --minify ./src/index.ts",
1010
"test": "bun test",
1111
"lint": "tsc && eslint"
1212
},

apps/stitcher/src/parser/lexical-parse.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ function parseLine(line: string): Tag | null {
211211
name: attrs.name,
212212
uri: attrs.uri,
213213
channels: attrs.channels,
214+
default: attrs.default,
215+
autoSelect: attrs.autoSelect,
214216
},
215217
];
216218
}
@@ -301,6 +303,18 @@ function parseLine(line: string): Tag | null {
301303
case "EXT-X-CUE-OUT": {
302304
assert(param, "EXT-X-CUE-OUT: no param");
303305

306+
// EXT-X-CUE-OUT can also contain only a number. Try to parse it,
307+
// and assume its the duration.
308+
const valueAsNumber = Number.parseFloat(param);
309+
if (!Number.isNaN(valueAsNumber)) {
310+
return [
311+
name,
312+
{
313+
duration: valueAsNumber,
314+
},
315+
];
316+
}
317+
304318
const attrs: Partial<CueOut> = {};
305319

306320
mapAttributes(param, (key, value) => {
@@ -329,12 +343,17 @@ function parseLine(line: string): Tag | null {
329343
mapAttributes(param, (key, value) => {
330344
switch (key) {
331345
case "METHOD":
346+
attrs.method = value;
347+
break;
332348
case "URI":
349+
attrs.uri = value;
350+
break;
333351
case "KEYFORMAT":
352+
attrs.format = value;
353+
break;
334354
case "KEYFORMATVERSION":
335-
attrs.method = value;
355+
attrs.formatVersion = value;
336356
break;
337-
338357
case "IV":
339358
attrs.iv = parseIV(value);
340359
break;

apps/stitcher/test/parser/__snapshots__/parse-master.test.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,29 @@ exports[`parse master should parse with groups 1`] = `
3636
"independentSegments": false,
3737
"renditions": [
3838
{
39-
"autoSelect": undefined,
39+
"autoSelect": true,
4040
"channels": undefined,
41-
"default": undefined,
41+
"default": true,
4242
"groupId": "aud1",
4343
"language": "eng",
4444
"name": "English",
4545
"type": "AUDIO",
4646
"uri": "a1.m3u8",
4747
},
4848
{
49-
"autoSelect": undefined,
49+
"autoSelect": true,
5050
"channels": undefined,
51-
"default": undefined,
51+
"default": true,
5252
"groupId": "aud2",
5353
"language": "nld",
5454
"name": "Nederlands",
5555
"type": "AUDIO",
5656
"uri": "a2.m3u8",
5757
},
5858
{
59-
"autoSelect": undefined,
59+
"autoSelect": true,
6060
"channels": undefined,
61-
"default": undefined,
61+
"default": true,
6262
"groupId": "sub1",
6363
"language": "eng",
6464
"name": "English",
@@ -98,9 +98,9 @@ exports[`parse master should parse with audio channels 1`] = `
9898
"independentSegments": false,
9999
"renditions": [
100100
{
101-
"autoSelect": undefined,
101+
"autoSelect": true,
102102
"channels": "6",
103-
"default": undefined,
103+
"default": true,
104104
"groupId": "aud1",
105105
"language": "eng",
106106
"name": "English",

0 commit comments

Comments
 (0)