vtt2ass 0.3.0 → 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/lib/vtt2ass/ASSFile.rb +11 -1
- data/lib/vtt2ass/ASSStyle.rb +5 -2
- data/lib/vtt2ass/CSSRule.rb +1 -1
- data/lib/vtt2ass/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ffa12943bef7e38d2fb319e2f496d32f43119fc5a7c5e65312140d62f3515d2
|
4
|
+
data.tar.gz: 044ad9174d1964b6f131b61f38691e4a58daa1b0fc7eab2eac19788a12e94af9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b74ac18f31d97823f8ffac84a9f2b0ff0ebeade0909b7c578ad03a50545dce62af3fc9eeb9d963d0943f6b3849a742590227479127ce3c160f0f8a72d7b4d00
|
7
|
+
data.tar.gz: 522c37cb7f95263b064d8b6b36188b4e91cd3ebc496a6629e3e893a7943705bd303efeecd334b4b6a896e8fee070f776640080daf9d0381f385817aee0fbb4f7
|
data/lib/vtt2ass/ASSFile.rb
CHANGED
@@ -48,6 +48,8 @@ class ASSFile
|
|
48
48
|
def convertVTTtoASS(vtt_file, font_family, font_size)
|
49
49
|
fs = font_size
|
50
50
|
font_color = '&H00FFFFFF'
|
51
|
+
is_italic = false
|
52
|
+
is_bold = false
|
51
53
|
vtt_file.lines.each do |line|
|
52
54
|
@ass_lines.push(ASSLine.new(line.style, line.time_start, line.time_end, line.text))
|
53
55
|
style_exists = false
|
@@ -74,11 +76,19 @@ class ASSFile
|
|
74
76
|
font_size = (fs * em_size).to_i
|
75
77
|
when 'color'
|
76
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
|
77
87
|
end
|
78
88
|
end
|
79
89
|
end
|
80
90
|
end
|
81
|
-
@ass_styles.push(ASSStyle.new(line.style, line.params, font_family, font_size, font_color, @width, @height))
|
91
|
+
@ass_styles.push(ASSStyle.new(line.style, line.params, font_family, font_size, font_color, is_bold, is_italic, @width, @height))
|
82
92
|
end
|
83
93
|
end
|
84
94
|
end
|
data/lib/vtt2ass/ASSStyle.rb
CHANGED
@@ -15,7 +15,7 @@ class ASSStyle
|
|
15
15
|
# * Requires +params+, a string of VTT styling as input.
|
16
16
|
# * Requires a video +width+ as input.
|
17
17
|
# * Requires a video +height+ as input.
|
18
|
-
def initialize(style_name, params, font_family, font_size, font_color, width, height)
|
18
|
+
def initialize(style_name, params, font_family, font_size, font_color, is_bold, is_italic, width, height)
|
19
19
|
@width = width
|
20
20
|
@height = height
|
21
21
|
@font_family = font_family
|
@@ -26,12 +26,15 @@ class ASSStyle
|
|
26
26
|
if style_name.eql? 'MainTop' then
|
27
27
|
@s_params.vertical_margin = 50
|
28
28
|
end
|
29
|
+
@is_italic = is_italic
|
30
|
+
@is_bold = is_bold
|
29
31
|
end
|
30
32
|
|
31
33
|
##
|
32
34
|
# This method assigns the object values to an ASS style line and outputs it.
|
33
35
|
def to_s
|
34
|
-
|
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"
|
35
38
|
end
|
36
39
|
|
37
40
|
def self.convert_color(color_value)
|
data/lib/vtt2ass/CSSRule.rb
CHANGED
data/lib/vtt2ass/version.rb
CHANGED