vtt2ass 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/ASSFile.html +546 -29
- data/doc/ASSLine.html +940 -0
- data/doc/ASSStyle.html +23 -147
- data/doc/ASSStyleParams.html +819 -0
- data/doc/Application.html +58 -149
- data/doc/VTTFile.html +454 -0
- data/doc/VTTLine.html +700 -0
- data/doc/Vtt2ass.html +61 -29
- data/doc/_index.html +12 -17
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +35 -8
- data/doc/index.html +35 -8
- data/doc/method_list.html +177 -49
- data/doc/top-level-namespace.html +3 -3
- data/lib/vtt2ass/ASSFile.rb +8 -0
- data/lib/vtt2ass/ASSLine.rb +1 -1
- data/lib/vtt2ass/ASSStyleParams.rb +13 -0
- data/lib/vtt2ass/Application.rb +7 -4
- data/lib/vtt2ass/VTTFile.rb +6 -0
- data/lib/vtt2ass/version.rb +6 -1
- metadata +6 -2
@@ -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="ASSStyle.html" title="ASSStyle (class)">ASSStyle</a></span>, <span class='object_link'><a href="
|
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>
|
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 Tue Mar 23 21:07:02 2021 by
|
106
106
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
107
|
-
0.9.26 (ruby-
|
107
|
+
0.9.26 (ruby-3.0.0).
|
108
108
|
</div>
|
109
109
|
|
110
110
|
</div>
|
data/lib/vtt2ass/ASSFile.rb
CHANGED
@@ -8,6 +8,8 @@ class ASSFile
|
|
8
8
|
attr_reader :title, :width, :height
|
9
9
|
attr_accessor :ass_styles, :ass_lines
|
10
10
|
|
11
|
+
##
|
12
|
+
# Creates a new ASSFile instance and assigns the default values of instance variables.
|
11
13
|
def initialize(title, width, height)
|
12
14
|
@width = width
|
13
15
|
@height = height
|
@@ -34,6 +36,10 @@ class ASSFile
|
|
34
36
|
@ass_lines = []
|
35
37
|
end
|
36
38
|
|
39
|
+
##
|
40
|
+
# This method receives a VTTFile object and font arguments creates new ASSLine with the params of
|
41
|
+
# each VTTLine. All those ASSLine are stored in an array. It also creates an array of ASSStyle that
|
42
|
+
# will be used in the ASS style list.
|
37
43
|
def convertVTTtoASS(vtt_file, font_family, font_size)
|
38
44
|
vtt_file.lines.each do |line|
|
39
45
|
@ass_lines.push(ASSLine.new(line.style, line.time_start, line.time_end, line.text))
|
@@ -50,6 +56,8 @@ class ASSFile
|
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
59
|
+
##
|
60
|
+
# This method writes the content of the ASSFile object into a file path that is provided.
|
53
61
|
def writeToFile(file_path)
|
54
62
|
File.open(file_path, 'w') do |line|
|
55
63
|
line.print "\ufeff"
|
data/lib/vtt2ass/ASSLine.rb
CHANGED
@@ -83,7 +83,7 @@ class ASSLine
|
|
83
83
|
end
|
84
84
|
|
85
85
|
##
|
86
|
-
#
|
86
|
+
# This method pads text so that time numbers are a fixed number of digit.
|
87
87
|
#
|
88
88
|
# * Requires +sep+, a string separator.
|
89
89
|
# * Requires +input+, an integer.
|
@@ -3,6 +3,10 @@
|
|
3
3
|
class ASSStyleParams
|
4
4
|
attr_reader :horizontal_margin, :vertical_margin, :alignment, :align
|
5
5
|
|
6
|
+
##
|
7
|
+
# Creates an instance of ASSStyleParams
|
8
|
+
# It takes VTT style arguments and assign them to their respectful instance variable.
|
9
|
+
# It calls methods to create ASS values from the VTT cue settings.
|
6
10
|
def initialize(params, width, height)
|
7
11
|
(params.split(' ').map { |p| p.split(':') }).each do |p|
|
8
12
|
case p[0]
|
@@ -20,6 +24,9 @@ class ASSStyleParams
|
|
20
24
|
createVerticalMargin(height)
|
21
25
|
end
|
22
26
|
|
27
|
+
##
|
28
|
+
# This method decides the alignement value in a 9 position grid based of the
|
29
|
+
# values in cue settings "align" and "line".
|
23
30
|
def createAlignment()
|
24
31
|
if (defined?(@line) and not defined?(@position)) then
|
25
32
|
if (defined?(@align)) then
|
@@ -50,6 +57,9 @@ class ASSStyleParams
|
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
60
|
+
##
|
61
|
+
# This method calculates the horizontal margin in px between the alignement position and
|
62
|
+
# and the content displayed by using the "position" cue setting.
|
53
63
|
def createHorizontalMargin(width)
|
54
64
|
steps = (width / 100).to_i
|
55
65
|
if defined?(@position) then
|
@@ -59,6 +69,9 @@ class ASSStyleParams
|
|
59
69
|
end
|
60
70
|
end
|
61
71
|
|
72
|
+
##
|
73
|
+
# This method calculates the vertical margin in px between the alignement position and
|
74
|
+
# and the content displayed by using the "line" cue setting.
|
62
75
|
def createVerticalMargin(height)
|
63
76
|
steps = (height / 100).to_i
|
64
77
|
if defined?(@line) then
|
data/lib/vtt2ass/Application.rb
CHANGED
@@ -13,8 +13,8 @@ class Application
|
|
13
13
|
# Creates a new Application instance.
|
14
14
|
# It receives +options+ that can define the input and output directories.
|
15
15
|
def initialize(options)
|
16
|
-
@input = options[:input] ? options[:input].gsub('\\', '/') : "
|
17
|
-
@output = options[:output] ? options[:output].gsub('\\', '/') : "
|
16
|
+
@input = options[:input] ? options[:input].gsub('\\', '/').delete_suffix('/') : "."
|
17
|
+
@output = options[:output] ? options[:output].gsub('\\', '/').delete_suffix('/') : "."
|
18
18
|
@width = 1920
|
19
19
|
@height = 1080
|
20
20
|
@font_family = options[:font_family] ? options[:font_family] : 'Open Sans Semibold'
|
@@ -31,15 +31,18 @@ class Application
|
|
31
31
|
def start
|
32
32
|
if File.directory?(@input) then
|
33
33
|
Dir["#{@input}/*.vtt"].each do |file_path|
|
34
|
-
vtt_to_ass(file_path).writeToFile(@output + File.basename(file_path).gsub('.vtt', '.ass'))
|
34
|
+
vtt_to_ass(file_path).writeToFile(@output + '/' + File.basename(file_path).gsub('.vtt', '.ass'))
|
35
35
|
end
|
36
36
|
elsif File.file?(@input) then
|
37
|
-
vtt_to_ass(@input).writeToFile(@output + File.basename(@input).gsub('.vtt', '.ass'))
|
37
|
+
vtt_to_ass(@input).writeToFile(@output + '/' + File.basename(@input).gsub('.vtt', '.ass'))
|
38
38
|
else
|
39
39
|
puts 'Error: input file or directory does not exist.'
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
##
|
44
|
+
# This method creates a new VTTFile object from the file path provided and convert its content
|
45
|
+
# inside a new ASSFile object.
|
43
46
|
def vtt_to_ass(file_path)
|
44
47
|
vtt_file = VTTFile.new(file_path)
|
45
48
|
ass_file = ASSFile.new(
|
data/lib/vtt2ass/VTTFile.rb
CHANGED
@@ -9,6 +9,8 @@ require_relative 'VTTLine'
|
|
9
9
|
class VTTFile
|
10
10
|
attr_accessor :lines
|
11
11
|
|
12
|
+
##
|
13
|
+
# Creates a new VTTFile instance and assigns the default values of instance variables.
|
12
14
|
def initialize(file_path)
|
13
15
|
@title = File.basename(file_path).gsub('.vtt', '')
|
14
16
|
@lines = []
|
@@ -22,6 +24,8 @@ class VTTFile
|
|
22
24
|
@lines.shift
|
23
25
|
end
|
24
26
|
|
27
|
+
##
|
28
|
+
# This method writes the content of the VTTFile object into a file path that is provided.
|
25
29
|
def writeToFile(file_path)
|
26
30
|
File.open(file_path, 'w') do |line|
|
27
31
|
line.print "\ufeff"
|
@@ -29,6 +33,8 @@ class VTTFile
|
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
36
|
+
##
|
37
|
+
# This method concatenates the object data in the right order for a string output.
|
32
38
|
def to_s
|
33
39
|
return "WEBVTT\n\n\n" + @lines
|
34
40
|
end
|
data/lib/vtt2ass/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vtt2ass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis-Philippe Fortin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|
@@ -97,9 +97,13 @@ files:
|
|
97
97
|
- bin/run
|
98
98
|
- bin/setup
|
99
99
|
- doc/ASSFile.html
|
100
|
+
- doc/ASSLine.html
|
100
101
|
- doc/ASSStyle.html
|
102
|
+
- doc/ASSStyleParams.html
|
101
103
|
- doc/ASSSubtitle.html
|
102
104
|
- doc/Application.html
|
105
|
+
- doc/VTTFile.html
|
106
|
+
- doc/VTTLine.html
|
103
107
|
- doc/VTTSubtitle.html
|
104
108
|
- doc/Vtt2ass.html
|
105
109
|
- doc/Vtt2ass/Error.html
|