@mtillmann/chapters 0.0.1 → 0.0.2

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/package.json +1 -1
  2. package/readme.md +51 -31
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtillmann/chapters",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
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",
package/readme.md CHANGED
@@ -4,25 +4,25 @@
4
4
 
5
5
  Create, manage and convert chapters for 17 chapters formats:
6
6
 
7
- | name | key | ext | info |
8
- |------------------------------|----------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
9
- | Podcasting 2.0 Chapters | chaptersjson | `json` | [spec](https://github.com/Podcastindex-org/podcast-namespace/blob/main/chapters/jsonChapters.md) |
10
- | FFMetadata | ffmpegdata | `txt` | [spec](https://ffmpeg.org/ffmpeg-formats.html#Metadata-1) |
11
- | Matroska XML chapters | matroskaxml | `xml` | [spec](https://www.matroska.org/technical/chapters.html) |
12
- | MKVToolNix mkvmerge XML | mkvmergexml | `xml` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
13
- | MKVToolNix mkvmerge _simple_ | mkvmergesimple | `txt` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
14
- | WebVTT Chapters | webvtt | `vtt` | [spec](https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API) |
15
- | Youtube Chapter Syntax | youtube | `txt` | |
16
- | FFMpegInfo | ffmpeginfo | `txt` | read only, used internally |
17
- | PySceneDetect | pyscenedetect | `csv` | [project home](https://github.com/Breakthrough/PySceneDetect) |
18
- | Vorbis Comment Format | vorbiscomment | `txt` | [spec](https://wiki.xiph.org/Chapter_Extension) |
19
- | "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)) |
20
- | Shutter EDL | edl | `edl` | [source](https://github.com/paulpacifico/shutter-encoder/blob/f3d6bb6dfcd629861a0b0a50113bf4b062e1ba17/src/application/SceneDetection.java) |
21
- | Podlove Simple Chapters | psc | `xml` | [spec](https://podlove.org/simple-chapters/) |
22
- | Podlove Simple Chapters JSON | podlovejson | `json` | [source](https://github.com/podlove/chapters#:~:text=org/%3E-,Encode%20to%20JSON,-iex%3E%20Chapters) |
23
- | MP4Chaps | mp4chaps | `txt` | [source](https://github.com/podlove/chapters#:~:text=%3Achapters%3E-,Encode%20to%20mp4chaps,-iex%3E%20Chapters) |
24
- | Apple HLS Chapters | applehls | `json` | [spec](https://developer.apple.com/documentation/http-live-streaming/providing-javascript-object-notation-json-chapters), partial support |
25
- | Scenecut | scenecut | `json` | [source](https://github.com/slhck/scenecut-extractor#:~:text=cuts%20in%20JSON-,format,-%3A) |
7
+ | class | description | key | ext | info |
8
+ |-------------------------------------|------------------------------|----------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
9
+ | ChaptersJson | Podcasting 2.0 Chapters | chaptersjson | `json` | [spec](https://github.com/Podcastindex-org/podcast-namespace/blob/main/chapters/jsonChapters.md) |
10
+ | FFMetadata | FFMetadata | ffmpegdata | `txt` | [spec](https://ffmpeg.org/ffmpeg-formats.html#Metadata-1) |
11
+ | MatroskaXML | Matroska XML chapters | matroskaxml | `xml` | [spec](https://www.matroska.org/technical/chapters.html) |
12
+ | MKVMergeXML | MKVToolNix mkvmerge XML | mkvmergexml | `xml` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
13
+ | MKVMergeSimple | MKVToolNix mkvmerge _simple_ | mkvmergesimple | `txt` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
14
+ | WebVTT | WebVTT Chapters | webvtt | `vtt` | [spec](https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API) |
15
+ | Youtube | Youtube Chapter Syntax | youtube | `txt` | |
16
+ | FFMpegInfo | FFMpegInfo | ffmpeginfo | `txt` | read only, used internally |
17
+ | PySceneDetect | PySceneDetect | pyscenedetect | `csv` | [project home](https://github.com/Breakthrough/PySceneDetect) |
18
+ | VorbisComment | Vorbis Comment Format | vorbiscomment | `txt` | [spec](https://wiki.xiph.org/Chapter_Extension) |
19
+ | 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)) |
20
+ | ShutterEDL | Shutter EDL | edl | `edl` | [source](https://github.com/paulpacifico/shutter-encoder/blob/f3d6bb6dfcd629861a0b0a50113bf4b062e1ba17/src/application/SceneDetection.java) |
21
+ | PodloveSimpleChapters | Podlove Simple Chapters | psc | `xml` | [spec](https://podlove.org/simple-chapters/) |
22
+ | PodloveJson | Podlove Simple Chapters JSON | podlovejson | `json` | [source](https://github.com/podlove/chapters#:~:text=org/%3E-,Encode%20to%20JSON,-iex%3E%20Chapters) |
23
+ | MP4Chaps | MP4Chaps | mp4chaps | `txt` | [source](https://github.com/podlove/chapters#:~:text=%3Achapters%3E-,Encode%20to%20mp4chaps,-iex%3E%20Chapters) |
24
+ | AppleHLS | Apple HLS Chapters | applehls | `json` | [spec](https://developer.apple.com/documentation/http-live-streaming/providing-javascript-object-notation-json-chapters), partial support |
25
+ | Scenecut | Scenecut | scenecut | `json` | [source](https://github.com/slhck/scenecut-extractor#:~:text=cuts%20in%20JSON-,format,-%3A) |
26
26
 
27
27
  ## Installation
28
28
 
@@ -31,18 +31,38 @@ Create, manage and convert chapters for 17 chapters formats:
31
31
  ## Usage
32
32
 
33
33
  ```javascript
34
- import {ChapterJson} from '@mtillmann/chapters';
35
-
36
- const chapters = new ChapterJson();
37
- chapters.add({
38
- startTime: 0,
39
- title: 'Intro'
40
- });
41
- chapters.add({
42
- startTime: 30,
43
- title: 'Some Topic'
44
- });
45
- const json = chapters.toString();
34
+ import { ChaptersJson } from '@mtillmann/chapters';
35
+
36
+ const chapters = new ChaptersJson()
37
+ chapters.add({ startTime: 0, title: 'Intro' })
38
+ chapters.add({ startTime: 30, title: 'Some Topic' })
39
+ const json = chapters.toString()
40
+ ```
41
+
42
+ ## Autoformat
43
+
44
+ `Autoformat` is a helper that can be used to automatically detect the format of a given input and return the corresponding class,
45
+ key or a new instance of the detected class. It also provides a method to convert the input to a specific format.
46
+
47
+ ```javascript
48
+ import { Autoformat } from '@mtillmann/chapters'
49
+ import { WebVTT } from '@mtillmann/chapters'
50
+
51
+ const content = '<podcasting 2.0 chapters.json>...'
52
+ const instance = Autoformat.detect(content) // returns an instance of ChaptersJson
53
+ const instance2 = Autoformat.from(content) // returns an instance of ChaptersJson
54
+
55
+ const key = Autoformat.detect(content, 'key') // returns 'chaptersjson'
56
+ const className = Autoformat.detect(content, 'class') // returns ChaptersJson
57
+
58
+ const webVttString = 'WEBVTT...';
59
+
60
+ const autodetectedWebVtt = Autoformat.detect(webVttString) // returns an instance of WebVTT
61
+
62
+ const fail = Autoformat.as('chaptersjson', webVttString) // throws an error
63
+
64
+ const vtt = Autoformat.as('webvtt', webVttString) // returns an instance of WebVTT
65
+ const vtt2 = Autoformat.as(WebVTT, webVttString) // returns an instance of WebVTT
46
66
  ```
47
67
 
48
68
  ## API