zezo010 / Elgindy-VTT-to-SRT-Subtitle-Converter

A tool for converting Web Video Text Tracks Format (WebVTT) subtitle to srt one. As most of video players support srt subtitles and can't open vtt subtitles, We should convert vtt to srt or sub subtitles but it's not easy to do that.
90 stars 14 forks source link

converted vtt file contains text format in srt output #9

Open darodi opened 2 years ago

darodi commented 2 years ago

converted vtt file contains text format in srt output

source file https://gist.github.com/darodi/3ff8be373302fcd8c8bb0f9069dc7208#file-je-suis-la-2853734-fra-vtt

target file https://gist.github.com/darodi/3ff8be373302fcd8c8bb0f9069dc7208#file-je-suis-la-2853734-fra-srt

as you can see,

1
00:00:07,120 --> 00:00:09,480 
<c.magenta.bg_black>Musique douce</c>

insead of

1
00:00:07,120 --> 00:00:09,480 
Musique douce
zezo010 commented 2 years ago

Mmmm, in all lines or specific ones?

darodi commented 2 years ago

all lines, as seen in output https://gist.github.com/darodi/3ff8be373302fcd8c8bb0f9069dc7208#file-je-suis-la-2853734-fra-srt

darodi commented 2 years ago

the input is


WEBVTT

STYLE
::cue {
    font-family: Verdana, Arial, Tiresias;
    line-height: 125%;
}
::cue(.white) {
    color: #ffffff;
}
::cue(.lime) {
    color: #00ff00;
}
::cue(.cyan) {
    color: #00ffff;
}
::cue(.red) {
    color: #ff0000;
}
::cue(.yellow) {
    color: #ffff00;
}
::cue(.magenta) {
    color: #ff00ff;
}
::cue(.blue) {
    color: #0000ff;
}
::cue(.black) {
    color: #000000;
}
::cue(.bg_black) {
    background: rgba(0, 0, 0, 0.76);
}

sub0
00:00:07.120 --> 00:00:09.480 line:-1
<c.magenta.bg_black>Musique douce</c>

the output should be something like this i think

1
00:00:07,120 --> 00:00:09,480 
<font color=#ff00ff">Musique douce</font> 
zezo010 commented 2 years ago

This because this file used VTT classes, So we should check if each line uses classes tags and removing it.