@mtillmann/chapters 0.1.0 → 0.1.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.
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/readme.md +29 -8
package/dist/index.js
CHANGED
|
@@ -190,7 +190,7 @@ var Base = class {
|
|
|
190
190
|
duration = 0;
|
|
191
191
|
isChapterFormat = true;
|
|
192
192
|
constructor(duration = 3600) {
|
|
193
|
-
this.duration = duration;
|
|
193
|
+
this.duration = Float(duration);
|
|
194
194
|
}
|
|
195
195
|
static create(input, duration) {
|
|
196
196
|
return new this(duration).from(input);
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/js/@mtillmann%2Fchapters)
|
|
4
|
+
|
|
3
5
|
# chapters
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
This is the core library of the [chaptertool](https://github.com/Mtillmann/chaptertool) project and provides the functionality to handle the formats below.
|
|
8
|
+
|
|
9
|
+
[Click here to open the web GUI](https://mtillmann.github.io/chaptertool) or go install chaptertool locally for CLI use.
|
|
10
|
+
|
|
11
|
+
## Supported formats
|
|
6
12
|
|
|
7
13
|
| class | description | key | ext | info |
|
|
8
14
|
|-------------------------------------|------------------------------|----------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
@@ -73,9 +79,24 @@ All formats support the following methods:
|
|
|
73
79
|
|
|
74
80
|
Creates a new instance of the class, optionally with a duration in seconds.
|
|
75
81
|
|
|
82
|
+
```javascript
|
|
83
|
+
const chapters = (new ChaptersJson(3600)).from(input)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
> the constructor will not accept any input due to javascript's order of initialization which prevents the parse method
|
|
87
|
+
> from having access to cerain locally defined properties and methods.
|
|
88
|
+
|
|
76
89
|
### `static create (input?: string | MediaItem): MediaItem`
|
|
77
90
|
|
|
78
|
-
Creates a new media item. This is the suggested way to create a media item:
|
|
91
|
+
Creates a new media item. This is the suggested way to create a media item from a string:
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
const chapters = MatroskaXML.create(input)
|
|
95
|
+
// chapters is now an instance of MatroskaXML
|
|
96
|
+
|
|
97
|
+
const chapterString = WebVTT.create(chapters).toString()
|
|
98
|
+
// chapterString is now a string representation of the chapters
|
|
99
|
+
```
|
|
79
100
|
|
|
80
101
|
### `from (input?: string | MediaItem): MediaItem`
|
|
81
102
|
|
|
@@ -135,11 +156,11 @@ Returns the index of the chapter at the given time.
|
|
|
135
156
|
|
|
136
157
|
### `toString([pretty: boolean][, options: object]): string`
|
|
137
158
|
|
|
138
|
-
Convert the chapters to a string.
|
|
159
|
+
Convert the chapters to a string.
|
|
139
160
|
If `pretty` is `true`, the output will be formatted for better readability. Only supported by `json` and `xml` formats.
|
|
140
|
-
|
|
161
|
+
Some formats support additional options:
|
|
141
162
|
|
|
142
|
-
#### ChapterJson
|
|
163
|
+
#### ChapterJson toString() options
|
|
143
164
|
|
|
144
165
|
| option | type | default | description |
|
|
145
166
|
|---------------------|-----------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
@@ -147,20 +168,20 @@ If `pretty` is `true`, the output will be formatted for better readability. Only
|
|
|
147
168
|
| `writeRedundantToc` | `boolean` | `false` | Write [redundant](https://github.com/Podcastindex-org/podcast-namespace/blob/main/chapters/jsonChapters.md#:~:text=or%20not%20present%20at%20all) TOC attributes |
|
|
148
169
|
| `writeEndTimes` | `boolean` | `false` | Write end times |
|
|
149
170
|
|
|
150
|
-
#### AppleChapters
|
|
171
|
+
#### AppleChapters toString() options
|
|
151
172
|
|
|
152
173
|
| option | type | default | description |
|
|
153
174
|
|-----------------|-----------|---------|-----------------------------------------------------------|
|
|
154
175
|
| `acUseTextAttr` | `boolean` | `false` | When set, the text-attribute will be used instead of node textContent |
|
|
155
176
|
|
|
156
|
-
#### PySceneDetect
|
|
177
|
+
#### PySceneDetect toString() options
|
|
157
178
|
|
|
158
179
|
| option | type | default | description |
|
|
159
180
|
|--------------------|----------|----------|------------------------------------------|
|
|
160
181
|
| `psdFramerate` | `number` | `23.976` | Framerate of the video file |
|
|
161
182
|
| `psdOmitTimecodes` | `boolen` | `false` | When set, the first line will be omitted |
|
|
162
183
|
|
|
163
|
-
#### Scenecut
|
|
184
|
+
#### Scenecut toString() options
|
|
164
185
|
|
|
165
186
|
| option | type | default | description |
|
|
166
187
|
|--------|----------|---------|-----------------------------|
|