vtt2ass 0.2.13 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -1
- data/Gemfile +0 -7
- data/README.md +20 -18
- data/bin/{run → vtt2ass} +1 -1
- data/doc/ASSFile.html +3 -3
- data/doc/ASSLine.html +2 -2
- data/doc/ASSStyle.html +13 -7
- data/doc/ASSStyleParams.html +10 -18
- data/doc/Application.html +90 -26
- data/doc/Command.html +227 -0
- data/doc/MainCommand.html +336 -0
- data/doc/VTTFile.html +117 -26
- data/doc/VTTLine.html +34 -30
- data/doc/Vtt2ass.html +4 -146
- data/doc/_index.html +15 -2
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +26 -19
- data/doc/index.html +26 -19
- data/doc/method_list.html +58 -26
- data/doc/top-level-namespace.html +3 -3
- data/exe/vtt2ass +1 -1
- data/lib/vtt2ass/ASSFile.rb +39 -2
- data/lib/vtt2ass/ASSStyle.rb +14 -2
- data/lib/vtt2ass/Application.rb +11 -6
- data/lib/vtt2ass/CSSFile.rb +36 -0
- data/lib/vtt2ass/CSSRule.rb +22 -0
- data/lib/vtt2ass/VTTFile.rb +10 -0
- data/lib/vtt2ass/VTTLine.rb +3 -2
- data/lib/vtt2ass/Validator.rb +10 -0
- data/lib/vtt2ass/version.rb +1 -1
- data/lib/vtt2ass.rb +17 -98
- data/vtt2ass.gemspec +3 -1
- metadata +39 -6
data/doc/_index.html
CHANGED
@@ -109,6 +109,19 @@
|
|
109
109
|
</ul>
|
110
110
|
|
111
111
|
|
112
|
+
<ul id="alpha_M" class="alpha">
|
113
|
+
<li class="letter">M</li>
|
114
|
+
<ul>
|
115
|
+
|
116
|
+
<li>
|
117
|
+
<span class='object_link'><a href="MainCommand.html" title="MainCommand (class)">MainCommand</a></span>
|
118
|
+
|
119
|
+
</li>
|
120
|
+
|
121
|
+
</ul>
|
122
|
+
</ul>
|
123
|
+
|
124
|
+
|
112
125
|
<ul id="alpha_V" class="alpha">
|
113
126
|
<li class="letter">V</li>
|
114
127
|
<ul>
|
@@ -140,9 +153,9 @@
|
|
140
153
|
</div>
|
141
154
|
|
142
155
|
<div id="footer">
|
143
|
-
Generated on
|
156
|
+
Generated on Mon Nov 22 21:50:10 2021 by
|
144
157
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
145
|
-
0.9.26 (ruby-3.0.
|
158
|
+
0.9.26 (ruby-3.0.2).
|
146
159
|
</div>
|
147
160
|
|
148
161
|
</div>
|
data/doc/class_list.html
CHANGED
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
<ul id="full_list" class="class">
|
45
45
|
<li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
|
46
|
-
<li id='object_ASSFile' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="ASSFile.html" title="ASSFile (class)">ASSFile</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_ASSLine' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="ASSLine.html" title="ASSLine (class)">ASSLine</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_ASSStyle' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="ASSStyle.html" title="ASSStyle (class)">ASSStyle</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_ASSStyleParams' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="ASSStyleParams.html" title="ASSStyleParams (class)">ASSStyleParams</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_Application' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="Application.html" title="Application (class)">Application</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='
|
46
|
+
<li id='object_ASSFile' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="ASSFile.html" title="ASSFile (class)">ASSFile</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_ASSLine' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="ASSLine.html" title="ASSLine (class)">ASSLine</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_ASSStyle' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="ASSStyle.html" title="ASSStyle (class)">ASSStyle</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_ASSStyleParams' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="ASSStyleParams.html" title="ASSStyleParams (class)">ASSStyleParams</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_Application' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="Application.html" title="Application (class)">Application</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_MainCommand' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="MainCommand.html" title="MainCommand (class)">MainCommand</a></span> < Thor<small class='search_info'>Top Level Namespace</small></div></li><li id='object_VTTFile' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="VTTFile.html" title="VTTFile (class)">VTTFile</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_VTTLine' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="VTTLine.html" title="VTTLine (class)">VTTLine</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li><li id='object_Vtt2ass' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="Vtt2ass.html" title="Vtt2ass (module)">Vtt2ass</a></span><small class='search_info'>Top Level Namespace</small></div></li>
|
47
47
|
|
48
48
|
</ul>
|
49
49
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -73,7 +73,10 @@
|
|
73
73
|
|
74
74
|
<h2 id="label-Installation">Installation</h2>
|
75
75
|
|
76
|
-
<p>To install
|
76
|
+
<p>To install:</p>
|
77
|
+
|
78
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_vtt2ass'>vtt2ass</span>
|
79
|
+
</code></pre>
|
77
80
|
|
78
81
|
<h1 id="label-Build">Build</h1>
|
79
82
|
|
@@ -82,22 +85,26 @@
|
|
82
85
|
|
83
86
|
<h2 id="label-Usage">Usage</h2>
|
84
87
|
|
85
|
-
<
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
Usage:
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
88
|
+
<pre class="code ruby"><code class="ruby">$ vtt2ass
|
89
|
+
Commands:
|
90
|
+
vtt2ass convert INPUT # Run the VTT to ASS conversion for the specified file(s)
|
91
|
+
vtt2ass help [COMMAND] # Describe available commands or one specific command
|
92
|
+
vtt2ass version # Show version
|
93
|
+
|
94
|
+
$ vtt2ass help convert
|
95
|
+
Usage:
|
96
|
+
vtt2ass convert INPUT
|
97
|
+
|
98
|
+
Options:
|
99
|
+
-o, [--output=OUTPUT] # Output directory of the converted file
|
100
|
+
-t, [--title=TITLE] # Specify a title for you file. If the input is a directory, all files will share the same title.
|
101
|
+
-s, [--font-size=N] # Specify a font size for the subtitles
|
102
|
+
# Default: 52
|
103
|
+
-f, [--font-family=FONT_FAMILY] # Specify a font family for the subtitles
|
104
|
+
# Default: Open Sans Semibold
|
105
|
+
-q, [--quiet], [--no-quiet] # Don't output to the console
|
106
|
+
|
107
|
+
Run the VTT to ASS conversion for the specified file(s)
|
101
108
|
</code></pre>
|
102
109
|
|
103
110
|
<h1 id="label-Donate">Donate</h1>
|
@@ -108,9 +115,9 @@ Specific options:
|
|
108
115
|
</div></div>
|
109
116
|
|
110
117
|
<div id="footer">
|
111
|
-
Generated on
|
118
|
+
Generated on Mon Nov 22 21:50:10 2021 by
|
112
119
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
113
|
-
0.9.26 (ruby-3.0.
|
120
|
+
0.9.26 (ruby-3.0.2).
|
114
121
|
</div>
|
115
122
|
|
116
123
|
</div>
|
data/doc/index.html
CHANGED
@@ -73,7 +73,10 @@
|
|
73
73
|
|
74
74
|
<h2 id="label-Installation">Installation</h2>
|
75
75
|
|
76
|
-
<p>To install
|
76
|
+
<p>To install:</p>
|
77
|
+
|
78
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_vtt2ass'>vtt2ass</span>
|
79
|
+
</code></pre>
|
77
80
|
|
78
81
|
<h1 id="label-Build">Build</h1>
|
79
82
|
|
@@ -82,22 +85,26 @@
|
|
82
85
|
|
83
86
|
<h2 id="label-Usage">Usage</h2>
|
84
87
|
|
85
|
-
<
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
Usage:
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
88
|
+
<pre class="code ruby"><code class="ruby">$ vtt2ass
|
89
|
+
Commands:
|
90
|
+
vtt2ass convert INPUT # Run the VTT to ASS conversion for the specified file(s)
|
91
|
+
vtt2ass help [COMMAND] # Describe available commands or one specific command
|
92
|
+
vtt2ass version # Show version
|
93
|
+
|
94
|
+
$ vtt2ass help convert
|
95
|
+
Usage:
|
96
|
+
vtt2ass convert INPUT
|
97
|
+
|
98
|
+
Options:
|
99
|
+
-o, [--output=OUTPUT] # Output directory of the converted file
|
100
|
+
-t, [--title=TITLE] # Specify a title for you file. If the input is a directory, all files will share the same title.
|
101
|
+
-s, [--font-size=N] # Specify a font size for the subtitles
|
102
|
+
# Default: 52
|
103
|
+
-f, [--font-family=FONT_FAMILY] # Specify a font family for the subtitles
|
104
|
+
# Default: Open Sans Semibold
|
105
|
+
-q, [--quiet], [--no-quiet] # Don't output to the console
|
106
|
+
|
107
|
+
Run the VTT to ASS conversion for the specified file(s)
|
101
108
|
</code></pre>
|
102
109
|
|
103
110
|
<h1 id="label-Donate">Donate</h1>
|
@@ -108,9 +115,9 @@ Specific options:
|
|
108
115
|
</div></div>
|
109
116
|
|
110
117
|
<div id="footer">
|
111
|
-
Generated on
|
118
|
+
Generated on Mon Nov 22 21:50:10 2021 by
|
112
119
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
113
|
-
0.9.26 (ruby-3.0.
|
120
|
+
0.9.26 (ruby-3.0.2).
|
114
121
|
</div>
|
115
122
|
|
116
123
|
</div>
|
data/doc/method_list.html
CHANGED
@@ -76,6 +76,22 @@
|
|
76
76
|
</li>
|
77
77
|
|
78
78
|
|
79
|
+
<li class="odd ">
|
80
|
+
<div class="item">
|
81
|
+
<span class='object_link'><a href="MainCommand.html#convert-instance_method" title="MainCommand#convert (method)">#convert</a></span>
|
82
|
+
<small>MainCommand</small>
|
83
|
+
</div>
|
84
|
+
</li>
|
85
|
+
|
86
|
+
|
87
|
+
<li class="even ">
|
88
|
+
<div class="item">
|
89
|
+
<span class='object_link'><a href="Application.html#convert-instance_method" title="Application#convert (method)">#convert</a></span>
|
90
|
+
<small>Application</small>
|
91
|
+
</div>
|
92
|
+
</li>
|
93
|
+
|
94
|
+
|
79
95
|
<li class="odd ">
|
80
96
|
<div class="item">
|
81
97
|
<span class='object_link'><a href="ASSLine.html#convertTime-instance_method" title="ASSLine#convertTime (method)">#convertTime</a></span>
|
@@ -124,6 +140,22 @@
|
|
124
140
|
</li>
|
125
141
|
|
126
142
|
|
143
|
+
<li class="odd ">
|
144
|
+
<div class="item">
|
145
|
+
<span class='object_link'><a href="VTTFile.html#determine_line_ending-instance_method" title="VTTFile#determine_line_ending (method)">#determine_line_ending</a></span>
|
146
|
+
<small>VTTFile</small>
|
147
|
+
</div>
|
148
|
+
</li>
|
149
|
+
|
150
|
+
|
151
|
+
<li class="even ">
|
152
|
+
<div class="item">
|
153
|
+
<span class='object_link'><a href="MainCommand.html#exit_on_failure%3F-class_method" title="MainCommand.exit_on_failure? (method)">exit_on_failure?</a></span>
|
154
|
+
<small>MainCommand</small>
|
155
|
+
</div>
|
156
|
+
</li>
|
157
|
+
|
158
|
+
|
127
159
|
<li class="odd ">
|
128
160
|
<div class="item">
|
129
161
|
<span class='object_link'><a href="ASSFile.html#height-instance_method" title="ASSFile#height (method)">#height</a></span>
|
@@ -205,14 +237,6 @@
|
|
205
237
|
|
206
238
|
|
207
239
|
<li class="odd ">
|
208
|
-
<div class="item">
|
209
|
-
<span class='object_link'><a href="Vtt2ass.html#main-class_method" title="Vtt2ass.main (method)">main</a></span>
|
210
|
-
<small>Vtt2ass</small>
|
211
|
-
</div>
|
212
|
-
</li>
|
213
|
-
|
214
|
-
|
215
|
-
<li class="even ">
|
216
240
|
<div class="item">
|
217
241
|
<span class='object_link'><a href="ASSLine.html#padTimeNum-instance_method" title="ASSLine#padTimeNum (method)">#padTimeNum</a></span>
|
218
242
|
<small>ASSLine</small>
|
@@ -220,7 +244,7 @@
|
|
220
244
|
</li>
|
221
245
|
|
222
246
|
|
223
|
-
<li class="
|
247
|
+
<li class="even ">
|
224
248
|
<div class="item">
|
225
249
|
<span class='object_link'><a href="VTTLine.html#params-instance_method" title="VTTLine#params (method)">#params</a></span>
|
226
250
|
<small>VTTLine</small>
|
@@ -228,7 +252,7 @@
|
|
228
252
|
</li>
|
229
253
|
|
230
254
|
|
231
|
-
<li class="
|
255
|
+
<li class="odd ">
|
232
256
|
<div class="item">
|
233
257
|
<span class='object_link'><a href="Application.html#start-instance_method" title="Application#start (method)">#start</a></span>
|
234
258
|
<small>Application</small>
|
@@ -236,7 +260,7 @@
|
|
236
260
|
</li>
|
237
261
|
|
238
262
|
|
239
|
-
<li class="
|
263
|
+
<li class="even ">
|
240
264
|
<div class="item">
|
241
265
|
<span class='object_link'><a href="ASSLine.html#style-instance_method" title="ASSLine#style (method)">#style</a></span>
|
242
266
|
<small>ASSLine</small>
|
@@ -244,7 +268,7 @@
|
|
244
268
|
</li>
|
245
269
|
|
246
270
|
|
247
|
-
<li class="
|
271
|
+
<li class="odd ">
|
248
272
|
<div class="item">
|
249
273
|
<span class='object_link'><a href="VTTLine.html#style-instance_method" title="VTTLine#style (method)">#style</a></span>
|
250
274
|
<small>VTTLine</small>
|
@@ -252,7 +276,7 @@
|
|
252
276
|
</li>
|
253
277
|
|
254
278
|
|
255
|
-
<li class="
|
279
|
+
<li class="even ">
|
256
280
|
<div class="item">
|
257
281
|
<span class='object_link'><a href="ASSStyle.html#style_name-instance_method" title="ASSStyle#style_name (method)">#style_name</a></span>
|
258
282
|
<small>ASSStyle</small>
|
@@ -260,7 +284,7 @@
|
|
260
284
|
</li>
|
261
285
|
|
262
286
|
|
263
|
-
<li class="
|
287
|
+
<li class="odd ">
|
264
288
|
<div class="item">
|
265
289
|
<span class='object_link'><a href="ASSLine.html#text-instance_method" title="ASSLine#text (method)">#text</a></span>
|
266
290
|
<small>ASSLine</small>
|
@@ -268,7 +292,7 @@
|
|
268
292
|
</li>
|
269
293
|
|
270
294
|
|
271
|
-
<li class="
|
295
|
+
<li class="even ">
|
272
296
|
<div class="item">
|
273
297
|
<span class='object_link'><a href="VTTLine.html#text-instance_method" title="VTTLine#text (method)">#text</a></span>
|
274
298
|
<small>VTTLine</small>
|
@@ -276,7 +300,7 @@
|
|
276
300
|
</li>
|
277
301
|
|
278
302
|
|
279
|
-
<li class="
|
303
|
+
<li class="odd ">
|
280
304
|
<div class="item">
|
281
305
|
<span class='object_link'><a href="ASSLine.html#time_end-instance_method" title="ASSLine#time_end (method)">#time_end</a></span>
|
282
306
|
<small>ASSLine</small>
|
@@ -284,7 +308,7 @@
|
|
284
308
|
</li>
|
285
309
|
|
286
310
|
|
287
|
-
<li class="
|
311
|
+
<li class="even ">
|
288
312
|
<div class="item">
|
289
313
|
<span class='object_link'><a href="VTTLine.html#time_end-instance_method" title="VTTLine#time_end (method)">#time_end</a></span>
|
290
314
|
<small>VTTLine</small>
|
@@ -292,7 +316,7 @@
|
|
292
316
|
</li>
|
293
317
|
|
294
318
|
|
295
|
-
<li class="
|
319
|
+
<li class="odd ">
|
296
320
|
<div class="item">
|
297
321
|
<span class='object_link'><a href="ASSLine.html#time_start-instance_method" title="ASSLine#time_start (method)">#time_start</a></span>
|
298
322
|
<small>ASSLine</small>
|
@@ -300,7 +324,7 @@
|
|
300
324
|
</li>
|
301
325
|
|
302
326
|
|
303
|
-
<li class="
|
327
|
+
<li class="even ">
|
304
328
|
<div class="item">
|
305
329
|
<span class='object_link'><a href="VTTLine.html#time_start-instance_method" title="VTTLine#time_start (method)">#time_start</a></span>
|
306
330
|
<small>VTTLine</small>
|
@@ -308,7 +332,7 @@
|
|
308
332
|
</li>
|
309
333
|
|
310
334
|
|
311
|
-
<li class="
|
335
|
+
<li class="odd ">
|
312
336
|
<div class="item">
|
313
337
|
<span class='object_link'><a href="ASSFile.html#title-instance_method" title="ASSFile#title (method)">#title</a></span>
|
314
338
|
<small>ASSFile</small>
|
@@ -316,7 +340,7 @@
|
|
316
340
|
</li>
|
317
341
|
|
318
342
|
|
319
|
-
<li class="
|
343
|
+
<li class="even ">
|
320
344
|
<div class="item">
|
321
345
|
<span class='object_link'><a href="ASSLine.html#toSubsTime-instance_method" title="ASSLine#toSubsTime (method)">#toSubsTime</a></span>
|
322
346
|
<small>ASSLine</small>
|
@@ -324,7 +348,7 @@
|
|
324
348
|
</li>
|
325
349
|
|
326
350
|
|
327
|
-
<li class="
|
351
|
+
<li class="odd ">
|
328
352
|
<div class="item">
|
329
353
|
<span class='object_link'><a href="ASSFile.html#to_s-instance_method" title="ASSFile#to_s (method)">#to_s</a></span>
|
330
354
|
<small>ASSFile</small>
|
@@ -332,7 +356,7 @@
|
|
332
356
|
</li>
|
333
357
|
|
334
358
|
|
335
|
-
<li class="
|
359
|
+
<li class="even ">
|
336
360
|
<div class="item">
|
337
361
|
<span class='object_link'><a href="ASSLine.html#to_s-instance_method" title="ASSLine#to_s (method)">#to_s</a></span>
|
338
362
|
<small>ASSLine</small>
|
@@ -340,7 +364,7 @@
|
|
340
364
|
</li>
|
341
365
|
|
342
366
|
|
343
|
-
<li class="
|
367
|
+
<li class="odd ">
|
344
368
|
<div class="item">
|
345
369
|
<span class='object_link'><a href="VTTFile.html#to_s-instance_method" title="VTTFile#to_s (method)">#to_s</a></span>
|
346
370
|
<small>VTTFile</small>
|
@@ -348,7 +372,7 @@
|
|
348
372
|
</li>
|
349
373
|
|
350
374
|
|
351
|
-
<li class="
|
375
|
+
<li class="even ">
|
352
376
|
<div class="item">
|
353
377
|
<span class='object_link'><a href="VTTLine.html#to_s-instance_method" title="VTTLine#to_s (method)">#to_s</a></span>
|
354
378
|
<small>VTTLine</small>
|
@@ -356,7 +380,7 @@
|
|
356
380
|
</li>
|
357
381
|
|
358
382
|
|
359
|
-
<li class="
|
383
|
+
<li class="odd ">
|
360
384
|
<div class="item">
|
361
385
|
<span class='object_link'><a href="ASSStyle.html#to_s-instance_method" title="ASSStyle#to_s (method)">#to_s</a></span>
|
362
386
|
<small>ASSStyle</small>
|
@@ -364,6 +388,14 @@
|
|
364
388
|
</li>
|
365
389
|
|
366
390
|
|
391
|
+
<li class="even ">
|
392
|
+
<div class="item">
|
393
|
+
<span class='object_link'><a href="MainCommand.html#version-instance_method" title="MainCommand#version (method)">#version</a></span>
|
394
|
+
<small>MainCommand</small>
|
395
|
+
</div>
|
396
|
+
</li>
|
397
|
+
|
398
|
+
|
367
399
|
<li class="odd ">
|
368
400
|
<div class="item">
|
369
401
|
<span class='object_link'><a href="ASSStyleParams.html#vertical_margin-instance_method" title="ASSStyleParams#vertical_margin (method)">#vertical_margin</a></span>
|
@@ -86,7 +86,7 @@
|
|
86
86
|
|
87
87
|
|
88
88
|
|
89
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="ASSFile.html" title="ASSFile (class)">ASSFile</a></span>, <span class='object_link'><a href="ASSLine.html" title="ASSLine (class)">ASSLine</a></span>, <span class='object_link'><a href="ASSStyle.html" title="ASSStyle (class)">ASSStyle</a></span>, <span class='object_link'><a href="ASSStyleParams.html" title="ASSStyleParams (class)">ASSStyleParams</a></span>, <span class='object_link'><a href="Application.html" title="Application (class)">Application</a></span>, <span class='object_link'><a href="VTTFile.html" title="VTTFile (class)">VTTFile</a></span>, <span class='object_link'><a href="VTTLine.html" title="VTTLine (class)">VTTLine</a></span>
|
89
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="ASSFile.html" title="ASSFile (class)">ASSFile</a></span>, <span class='object_link'><a href="ASSLine.html" title="ASSLine (class)">ASSLine</a></span>, <span class='object_link'><a href="ASSStyle.html" title="ASSStyle (class)">ASSStyle</a></span>, <span class='object_link'><a href="ASSStyleParams.html" title="ASSStyleParams (class)">ASSStyleParams</a></span>, <span class='object_link'><a href="Application.html" title="Application (class)">Application</a></span>, <span class='object_link'><a href="MainCommand.html" title="MainCommand (class)">MainCommand</a></span>, <span class='object_link'><a href="VTTFile.html" title="VTTFile (class)">VTTFile</a></span>, <span class='object_link'><a href="VTTLine.html" title="VTTLine (class)">VTTLine</a></span>
|
90
90
|
|
91
91
|
|
92
92
|
</p>
|
@@ -102,9 +102,9 @@
|
|
102
102
|
</div>
|
103
103
|
|
104
104
|
<div id="footer">
|
105
|
-
Generated on
|
105
|
+
Generated on Mon Nov 22 21:50:10 2021 by
|
106
106
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
107
|
-
0.9.26 (ruby-3.0.
|
107
|
+
0.9.26 (ruby-3.0.2).
|
108
108
|
</div>
|
109
109
|
|
110
110
|
</div>
|
data/exe/vtt2ass
CHANGED
data/lib/vtt2ass/ASSFile.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Relative imports
|
2
2
|
require_relative 'ASSLine'
|
3
3
|
require_relative 'ASSStyle'
|
4
|
+
require_relative 'CSSFile'
|
5
|
+
require_relative 'CSSRule'
|
4
6
|
|
5
7
|
##
|
6
8
|
# This class defines an ASS subtitle file.
|
@@ -10,9 +12,12 @@ class ASSFile
|
|
10
12
|
|
11
13
|
##
|
12
14
|
# Creates a new ASSFile instance and assigns the default values of instance variables.
|
13
|
-
def initialize(title, width, height)
|
15
|
+
def initialize(title, width, height, css_file_path = nil)
|
14
16
|
@width = width
|
15
17
|
@height = height
|
18
|
+
if not css_file_path.nil? then
|
19
|
+
@css_file = CSSFile.new(css_file_path)
|
20
|
+
end
|
16
21
|
@header = [
|
17
22
|
'[Script Info]',
|
18
23
|
"Title: #{title}",
|
@@ -41,6 +46,10 @@ class ASSFile
|
|
41
46
|
# each VTTLine. All those ASSLine are stored in an array. It also creates an array of ASSStyle that
|
42
47
|
# will be used in the ASS style list.
|
43
48
|
def convertVTTtoASS(vtt_file, font_family, font_size)
|
49
|
+
fs = font_size
|
50
|
+
font_color = '&H00FFFFFF'
|
51
|
+
is_italic = false
|
52
|
+
is_bold = false
|
44
53
|
vtt_file.lines.each do |line|
|
45
54
|
@ass_lines.push(ASSLine.new(line.style, line.time_start, line.time_end, line.text))
|
46
55
|
style_exists = false
|
@@ -51,7 +60,35 @@ class ASSFile
|
|
51
60
|
end
|
52
61
|
end
|
53
62
|
if not style_exists then
|
54
|
-
|
63
|
+
if defined?(@css_file) then
|
64
|
+
css_rule = @css_file.find_rule(line.style)
|
65
|
+
if not css_rule.nil? then
|
66
|
+
css_rule.properties.each do |property|
|
67
|
+
case property[:key]
|
68
|
+
when 'font-family'
|
69
|
+
font_family = property[:value].gsub('"', '').split(' ,').last
|
70
|
+
when 'font-size'
|
71
|
+
em_size = 1
|
72
|
+
#em_size = property[:value][0].eql? '.' ? "0#{property[:value]}" : property[:value]
|
73
|
+
if property[:value][0].eql? '.' then
|
74
|
+
em_size = "0#{property[:value]}".gsub('em', '').to_f
|
75
|
+
end
|
76
|
+
font_size = (fs * em_size).to_i
|
77
|
+
when 'color'
|
78
|
+
font_color = ASSStyle.convert_color(property[:value])
|
79
|
+
when 'font-weight'
|
80
|
+
if property[:value].eql? 'bold' then
|
81
|
+
is_bold = true
|
82
|
+
end
|
83
|
+
when 'font-style'
|
84
|
+
if property[:value].eql? 'italic' then
|
85
|
+
is_italic = true
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
@ass_styles.push(ASSStyle.new(line.style, line.params, font_family, font_size, font_color, is_bold, is_italic, @width, @height))
|
55
92
|
end
|
56
93
|
end
|
57
94
|
end
|
data/lib/vtt2ass/ASSStyle.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Relative imports
|
2
2
|
require_relative 'ASSStyleParams'
|
3
|
+
require_relative 'Validator'
|
4
|
+
require 'redgreenblue'
|
3
5
|
|
4
6
|
##
|
5
7
|
# This class defines an ASS style that can be applied on a subtitle line.
|
@@ -13,21 +15,31 @@ class ASSStyle
|
|
13
15
|
# * Requires +params+, a string of VTT styling as input.
|
14
16
|
# * Requires a video +width+ as input.
|
15
17
|
# * Requires a video +height+ as input.
|
16
|
-
def initialize(style_name, params, font_family, font_size, width, height)
|
18
|
+
def initialize(style_name, params, font_family, font_size, font_color, is_bold, is_italic, width, height)
|
17
19
|
@width = width
|
18
20
|
@height = height
|
19
21
|
@font_family = font_family
|
20
22
|
@font_size = font_size
|
23
|
+
@font_color = font_color
|
21
24
|
@style_name = style_name
|
22
25
|
@s_params = ASSStyleParams.new(params, width, height)
|
23
26
|
if style_name.eql? 'MainTop' then
|
24
27
|
@s_params.vertical_margin = 50
|
25
28
|
end
|
29
|
+
@is_italic = is_italic
|
30
|
+
@is_bold = is_bold
|
26
31
|
end
|
27
32
|
|
28
33
|
##
|
29
34
|
# This method assigns the object values to an ASS style line and outputs it.
|
30
35
|
def to_s
|
31
|
-
|
36
|
+
# Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
|
37
|
+
return "Style: #{@style_name},#{@font_family},#{@font_size},#{@font_color},&H000000FF,&H00020713,&H00000000,#{@is_bold ? '-1' : '0'},#{@is_italic ? '-1' : '0'},0,0,100,100,0,0,1,2.0,2.0,#{@s_params.alignment},#{@s_params.horizontal_margin},0,#{@s_params.vertical_margin},1"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.convert_color(color_value)
|
41
|
+
color_value.gsub!('#', '')
|
42
|
+
color = Validator.hex?(color_value) ? RGB.hex(color_value) : RGB.css(color_value)
|
43
|
+
return ("&H00%02x%02x%02x" % [color.b, color.g, color.r]).upcase
|
32
44
|
end
|
33
45
|
end
|
data/lib/vtt2ass/Application.rb
CHANGED
@@ -9,9 +9,9 @@ class Application
|
|
9
9
|
##
|
10
10
|
# Creates a new Application instance.
|
11
11
|
# It receives +options+ that can define the input and output directories.
|
12
|
-
def initialize(options)
|
13
|
-
@input =
|
14
|
-
@output = options[:output] ? options[:output].gsub('\\', '/').delete_suffix('/') :
|
12
|
+
def initialize(input, options)
|
13
|
+
@input = input ? input.gsub('\\', '/').delete_suffix('/') : "."
|
14
|
+
@output = options[:output] ? options[:output].gsub('\\', '/').delete_suffix('/') : nil
|
15
15
|
@width = 1920
|
16
16
|
@height = 1080
|
17
17
|
@font_family = options[:font_family] ? options[:font_family] : 'Open Sans Semibold'
|
@@ -20,7 +20,9 @@ class Application
|
|
20
20
|
@title = options[:title]
|
21
21
|
end
|
22
22
|
@quiet = options[:quiet]
|
23
|
-
|
23
|
+
if options[:css] then
|
24
|
+
@css = options[:css].gsub('\\', '/')
|
25
|
+
end
|
24
26
|
end
|
25
27
|
|
26
28
|
##
|
@@ -41,7 +43,9 @@ class Application
|
|
41
43
|
|
42
44
|
def convert(input_path)
|
43
45
|
ass_file = vtt_to_ass(input_path)
|
44
|
-
|
46
|
+
if (not @output.nil?) then
|
47
|
+
ass_file.writeToFile(@output + '/' + File.basename(input_path).gsub('.vtt', '.ass'))
|
48
|
+
end
|
45
49
|
puts ass_file.to_s unless @quiet
|
46
50
|
end
|
47
51
|
|
@@ -53,7 +57,8 @@ class Application
|
|
53
57
|
ass_file = ASSFile.new(
|
54
58
|
(defined?(@title) ? @title : File.basename(file_path).gsub('.vtt', '')),
|
55
59
|
@width,
|
56
|
-
@height
|
60
|
+
@height,
|
61
|
+
defined?(@css) ? @css : nil
|
57
62
|
)
|
58
63
|
ass_file.convertVTTtoASS(vtt_file, @font_family, @font_size)
|
59
64
|
return ass_file
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'css_parser'
|
2
|
+
require_relative 'CSSRule'
|
3
|
+
|
4
|
+
class CSSFile
|
5
|
+
attr_reader :rules
|
6
|
+
include CssParser
|
7
|
+
|
8
|
+
def initialize(file_path)
|
9
|
+
@file_path = file_path
|
10
|
+
parser = CssParser::Parser.new
|
11
|
+
parser.load_file!(file_path)
|
12
|
+
@rules = []
|
13
|
+
parser.each_selector do |selector, declarations, specificity|
|
14
|
+
css_obj = CSSRule.new(selector, declarations)
|
15
|
+
if not css_obj.name.empty? then
|
16
|
+
@rules.push(css_obj)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_rule(value)
|
22
|
+
return_rule = nil
|
23
|
+
@rules.each do |rule|
|
24
|
+
if rule.name == value then
|
25
|
+
return_rule = rule
|
26
|
+
break
|
27
|
+
end
|
28
|
+
end
|
29
|
+
return return_rule
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_s
|
33
|
+
return @file_path
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|