Skip to content

Commit

Permalink
chore: Update ArtPlayer version to 5.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
zhw2590582 committed Jun 2, 2024
1 parent 0fce9f5 commit a59942c
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 50 deletions.
5 changes: 3 additions & 2 deletions docs/compiled/artplayer.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions docs/compiled/artplayer.legacy.js

Large diffs are not rendered by default.

28 changes: 15 additions & 13 deletions docs/uncompiled/artplayer/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/uncompiled/artplayer/index.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions packages/artplayer/dist/artplayer.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions packages/artplayer/dist/artplayer.legacy.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/artplayer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"license": "MIT",
"name": "artplayer",
"version": "5.1.4",
"version": "5.1.5",
"main": "dist/artplayer.js",
"legacy": "dist/artplayer.legacy.js",
"types": "types/artplayer.d.ts",
Expand All @@ -24,4 +24,4 @@
"dependencies": {
"option-validator": "^2.0.6"
}
}
}
57 changes: 31 additions & 26 deletions packages/artplayer/src/utils/subtitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,35 @@ export function assToVtt(ass) {
.join('');
}

return `WEBVTT\n\n${ass
.split(/\r?\n/)
.map((line) => {
const m = line.match(reAss);
if (!m) return null;
return {
start: fixTime(m[1].trim()),
end: fixTime(m[2].trim()),
text: m[5]
.replace(/{[\s\S]*?}/g, '')
.replace(/(\\N)/g, '\n')
.trim()
.split(/\r?\n/)
.map((item) => item.trim())
.join('\n'),
};
})
.filter((line) => line)
.map((line, index) => {
if (line) {
return `${index + 1}\n${line.start} --> ${line.end}\n${line.text}`;
}
return '';
})
.filter((line) => line.trim())
.join('\n\n')}`;
return (
'WEBVTT' +
'\n' +
'\n' +
ass
.split(/\r?\n/)
.map((line) => {
const m = line.match(reAss);
if (!m) return null;
return {
start: fixTime(m[1].trim()),
end: fixTime(m[2].trim()),
text: m[5]
.replace(/{[\s\S]*?}/g, '')
.replace(/(\\N)/g, '\n')
.trim()
.split(/\r?\n/)
.map((item) => item.trim())
.join('\n'),
};
})
.filter((line) => line)
.map((line, index) => {
if (line) {
return index + 1 + '\n' + `${line.start} --> ${line.end}` + '\n' + `${line.text}`;
}
return '';
})
.filter((line) => line.trim())
.join('\n\n')
);
}

0 comments on commit a59942c

Please sign in to comment.