build all packages

This commit is contained in:
Harvey committed 2019-11-11 09:11:36 +08:00
1 parent da45181d18
commit 66bb5326ec
11 files changed
+57 -31

No files matched your search

+10 -13
View File
@@ -1,4 +1,4 @@
import { setStyles, srtToVtt, vttToBlob, getExt, errorHandle } from './utils';
import { setStyles, srtToVtt, vttToBlob, getExt } from './utils';
import assToVtt from './utils/assToVtt';
export default class Subtitle {
@@ -89,19 +89,16 @@ export default class Subtitle {
return response.text();
})
.then(text => {
const type = getExt(url);
errorHandle(['srt', 'ass', 'vtt'].includes(type), `Unsupported subtitle format: ${type}`);
const formatText = text.replace(/{[\s\S]*?}/g, '');
if (type === 'srt') {
return vttToBlob(srtToVtt(formatText));
switch (getExt(url)) {
case 'srt':
return vttToBlob(srtToVtt(text));
case 'ass':
return vttToBlob(assToVtt(text));
case 'vtt':
return vttToBlob(text);
default:
return url;
}
if (type === 'ass') {
return vttToBlob(assToVtt(formatText));
}
return vttToBlob(formatText);
})
.catch(err => {
notice.show(err);
+1
View File
@@ -151,6 +151,7 @@ export function tooltip(target, msg, pos = 'up') {
export function srtToVtt(srtText) {
return 'WEBVTT \r\n\r\n'.concat(
srtText
.replace(/{[\s\S]*?}/g, '')
.replace(/\{\\([ibu])\}/g, '</$1>')
.replace(/\{\\([ibu])1\}/g, '<$1>')
.replace(/\{([ibu])\}/g, '<$1>')