分离部分工具函数

This commit is contained in:
Harvey Zack committed 2018-11-23 09:45:36 +08:00
1 parent d6e35781ca
commit 748ce304e6
15 files changed
+244 -417

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
export function srtToVtt(srtText) {
return 'WEBVTT \r\n\r\n'.concat(
srtText
.replace(/\{\\([ibu])\}/g, '</$1>')
.replace(/\{\\([ibu])1\}/g, '<$1>')
.replace(/\{([ibu])\}/g, '<$1>')
.replace(/\{\/([ibu])\}/g, '</$1>')
.replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g, '$1.$2')
.concat('\r\n\r\n'),
);
}
export function vttToBlob(vttText) {
return URL.createObjectURL(
new Blob([vttText], {
type: 'text/vtt',
}),
);
}