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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 725876fe775e13997b8bfea4f1f8d1bd87fe18420c4adfabebc7aa6eced12464
4
- data.tar.gz: 13ebdd5f0542f75a9a886e028afb3f93621e68c6b61304d8976320d804d447f8
3
+ metadata.gz: 4ffa12943bef7e38d2fb319e2f496d32f43119fc5a7c5e65312140d62f3515d2
4
+ data.tar.gz: 044ad9174d1964b6f131b61f38691e4a58daa1b0fc7eab2eac19788a12e94af9
5
5
  SHA512:
6
- metadata.gz: 1656502fd7ff8f0b180a8826d593d763e855641e780b70f3e9f320a05c385c5ebfca97b5f037f87bacadabbbe86c35f9718fb6e9a5dd828bd3d9c7b2ede3ac37
7
- data.tar.gz: a6099e227e52f45783a9462b3041b272bbe01ff76c87f10c44508df3711a61559865dd180f06ea38c02b2db245a6a9ed48732626e8ef4dd95b664d1f3177ac8f
6
+ metadata.gz: 2b74ac18f31d97823f8ffac84a9f2b0ff0ebeade0909b7c578ad03a50545dce62af3fc9eeb9d963d0943f6b3849a742590227479127ce3c160f0f8a72d7b4d00
7
+ data.tar.gz: 522c37cb7f95263b064d8b6b36188b4e91cd3ebc496a6629e3e893a7943705bd303efeecd334b4b6a896e8fee070f776640080daf9d0381f385817aee0fbb4f7
@@ -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
@@ -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
- return "Style: #{@style_name},#{@font_family},#{@font_size},#{@font_color},&H000000FF,&H00020713,&H00000000,-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"
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)
@@ -3,8 +3,8 @@ class CSSRule
3
3
 
4
4
  def initialize(selector, declarations)
5
5
  @name = reduce_selector(selector)
6
+ @properties = []
6
7
  declarations.split(/;\s?/).each do |dec|
7
- @properties = []
8
8
  temp = dec.split(/:\s?/)
9
9
  @properties.push(
10
10
  { key: temp.first, value: temp.last}
@@ -4,5 +4,5 @@ module Vtt2ass
4
4
  ##
5
5
  # This is the version of the application.
6
6
  # This needs to be changed for each gem release.
7
- VERSION = "0.3.0"
7
+ VERSION = "0.3.1"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vtt2ass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis-Philippe Fortin