@mtillmann/chapters 0.1.6 → 0.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.
- package/dist/index.js +57 -1
- package/package.json +3 -2
- package/readme.md +1 -0
package/dist/index.js
CHANGED
|
@@ -1362,6 +1362,61 @@ var Audible = class extends Base {
|
|
|
1362
1362
|
}
|
|
1363
1363
|
};
|
|
1364
1364
|
|
|
1365
|
+
// src/Formats/Podigee.ts
|
|
1366
|
+
var Podigee = class extends Base {
|
|
1367
|
+
supportsPrettyPrint = true;
|
|
1368
|
+
test(data) {
|
|
1369
|
+
if (!Array.isArray(data)) {
|
|
1370
|
+
return { errors: ["JSON Structure: must be an array"] };
|
|
1371
|
+
}
|
|
1372
|
+
if (data.length === 0) {
|
|
1373
|
+
return { errors: ["JSON Structure: must not be empty"] };
|
|
1374
|
+
}
|
|
1375
|
+
if (!data.every((chapter) => "start_time" in chapter && "title" in chapter)) {
|
|
1376
|
+
return { errors: ["JSON Structure: every chapter must have a start_time and title property"] };
|
|
1377
|
+
}
|
|
1378
|
+
return { errors: [] };
|
|
1379
|
+
}
|
|
1380
|
+
parse(string) {
|
|
1381
|
+
const data = JSON.parse(string);
|
|
1382
|
+
const { errors } = this.test(data);
|
|
1383
|
+
if (errors.length > 0) {
|
|
1384
|
+
throw new Error(errors.join(""));
|
|
1385
|
+
}
|
|
1386
|
+
this.chapters = data.map((raw) => {
|
|
1387
|
+
const { start_time: start, title, image, url } = raw;
|
|
1388
|
+
const chapter = {
|
|
1389
|
+
startTime: timestampToSeconds(start)
|
|
1390
|
+
};
|
|
1391
|
+
if (title) {
|
|
1392
|
+
chapter.title = title;
|
|
1393
|
+
}
|
|
1394
|
+
if (image) {
|
|
1395
|
+
chapter.img = image;
|
|
1396
|
+
}
|
|
1397
|
+
if (url) {
|
|
1398
|
+
chapter.url = url;
|
|
1399
|
+
}
|
|
1400
|
+
return chapter;
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
toString(pretty = false) {
|
|
1404
|
+
return JSON.stringify(this.chapters.map((chapter, i) => {
|
|
1405
|
+
const output = {
|
|
1406
|
+
start_time: secondsToTimestamp(chapter.startTime),
|
|
1407
|
+
title: this.ensureTitle(i)
|
|
1408
|
+
};
|
|
1409
|
+
if (chapter.img) {
|
|
1410
|
+
output.image = chapter.img;
|
|
1411
|
+
}
|
|
1412
|
+
if (chapter.url) {
|
|
1413
|
+
output.url = chapter.url;
|
|
1414
|
+
}
|
|
1415
|
+
return output;
|
|
1416
|
+
}), null, pretty ? 2 : 0);
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1365
1420
|
// src/Formats/AutoFormat.ts
|
|
1366
1421
|
var classMap = {
|
|
1367
1422
|
chaptersjson: ChaptersJson,
|
|
@@ -1381,7 +1436,8 @@ var classMap = {
|
|
|
1381
1436
|
podlovejson: PodloveJson,
|
|
1382
1437
|
applehls: AppleHLS,
|
|
1383
1438
|
scenecut: Scenecut,
|
|
1384
|
-
audible: Audible
|
|
1439
|
+
audible: Audible,
|
|
1440
|
+
podigee: Podigee
|
|
1385
1441
|
};
|
|
1386
1442
|
var AutoFormat = {
|
|
1387
1443
|
classMap,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtillmann/chapters",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "library that manages and converts chapters of multiple formats",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"podcast-chapters",
|
|
35
35
|
"edl",
|
|
36
36
|
"hls",
|
|
37
|
-
"scenecut"
|
|
37
|
+
"scenecut",
|
|
38
|
+
"podigee"
|
|
38
39
|
],
|
|
39
40
|
"license": "MIT",
|
|
40
41
|
"devDependencies": {
|
package/readme.md
CHANGED
|
@@ -24,6 +24,7 @@ This is the core library of the [chaptertool](https://github.com/Mtillmann/chapt
|
|
|
24
24
|
| VorbisComment | Vorbis Comment Format | vorbiscomment | `txt` | [spec](https://wiki.xiph.org/Chapter_Extension) |
|
|
25
25
|
| AppleChapters | "Apple Chapters" | applechapters | `xml` | [source](https://github.com/rigaya/NVEnc/blob/master/NVEncC_Options.en.md#--chapter-string:~:text=CHAPTER03NAME%3Dchapter%2D3-,apple%20format,-(should%20be%20in)) |
|
|
26
26
|
| ShutterEDL | Shutter EDL | edl | `edl` | [source](https://github.com/paulpacifico/shutter-encoder/blob/f3d6bb6dfcd629861a0b0a50113bf4b062e1ba17/src/application/SceneDetection.java) |
|
|
27
|
+
| Podigee | Podigee Chapters/Chaptermarks | podigee | `json` | [spec](https://app.podigee.com/api-docs#!/ChapterMarks/updateChapterMark:~:text=Model-,Example%20Value,-%7B%0A%20%20%22title%22%3A%20%22string%22%2C%0A%20%20%22start_time) |
|
|
27
28
|
| PodloveSimpleChapters | Podlove Simple Chapters | psc | `xml` | [spec](https://podlove.org/simple-chapters/) |
|
|
28
29
|
| PodloveJson | Podlove Simple Chapters JSON | podlovejson | `json` | [source](https://github.com/podlove/chapters#:~:text=org/%3E-,Encode%20to%20JSON,-iex%3E%20Chapters) |
|
|
29
30
|
| MP4Chaps | MP4Chaps | mp4chaps | `txt` | [source](https://github.com/podlove/chapters#:~:text=%3Achapters%3E-,Encode%20to%20mp4chaps,-iex%3E%20Chapters) |
|