Skip to content

Commit

Permalink
Merge pull request #24 from mccauli/coreymccourt/ch76192/investigate-…
Browse files Browse the repository at this point in the history
…why-attached-vtt-file-fails-to

standardize vtt styles to object if empty
  • Loading branch information
McCourtRC committed Dec 11, 2019
2 parents b8d2211 + 519ab0b commit be3abfa
Show file tree
Hide file tree
Showing 5 changed files with 5,479 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/parsers/vtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ function standardize(subtitleJSON, options) {
return {
global: {},
body: subtitleJSON.cues.map((line, index) => {
const styles = line.styles.split(' ')
const styles = line.styles ? line.styles.split(' ')
.reduce((obj, style) => {
const [key, value] = style.split(':');
obj[key] = value;
return obj;
}, {});
}, {}) : {};

return {
id: index.toString(),
startMicro: secondsToMicroseconds(line.start),
Expand Down
3 changes: 2 additions & 1 deletion lib/tests/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const goodSrt = require('./mocks/goodSRT');
const goodSCC = require('./mocks/goodSCC');
const goodTTML = require('./mocks/goodTTML');
const goodVTT = require('./mocks/goodVTT');
const goodVTT2 = require('./mocks/goodVTT2');
const goodDFXP = require('./mocks/goodDFXP');

describe('#convert', () => {
Expand Down Expand Up @@ -140,7 +141,7 @@ describe('#convert', () => {
expect(status.success).to.be.true;
});
it('should convert VTT to VTT', () => {
const { status } = convert(goodVTT, '.vtt', '.vtt');
const { status } = convert(goodVTT2, '.vtt', '.vtt');
expect(status.success).to.be.true;
});
it('should convert DFXP to VTT', () => {
Expand Down
Loading

0 comments on commit be3abfa

Please sign in to comment.