vtt2ass 0.3.1 → 0.3.2

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: 4ffa12943bef7e38d2fb319e2f496d32f43119fc5a7c5e65312140d62f3515d2
4
- data.tar.gz: 044ad9174d1964b6f131b61f38691e4a58daa1b0fc7eab2eac19788a12e94af9
3
+ metadata.gz: 5e94988be1922e26d861f105404e3eff863a2df470aa3aa7fc5f35cdf26c3c71
4
+ data.tar.gz: 055641cfd88eef119e3c623adbae16b9eb70a7091c26b13410d8b94c2c8e55ec
5
5
  SHA512:
6
- metadata.gz: 2b74ac18f31d97823f8ffac84a9f2b0ff0ebeade0909b7c578ad03a50545dce62af3fc9eeb9d963d0943f6b3849a742590227479127ce3c160f0f8a72d7b4d00
7
- data.tar.gz: 522c37cb7f95263b064d8b6b36188b4e91cd3ebc496a6629e3e893a7943705bd303efeecd334b4b6a896e8fee070f776640080daf9d0381f385817aee0fbb4f7
6
+ metadata.gz: 785df255fc71e0479a8b124222e25033e2aca337765cdd17bf46c6ef0e11adae7fb854b01fa23959946f8d9ebd8bbfefcaf6cafc10b9a7089a52b11806f5e82a
7
+ data.tar.gz: 9cd4940b1d5667136aa51d9bff670a2d98e4a966ee898110230c15d710c87898aaf596afd6a6c7173f0ef06cf26eb57e7f2b3acd1c670f95209d97be9c5d5480
data/README.md CHANGED
@@ -43,6 +43,8 @@ Options:
43
43
  -f, [--font-family=FONT_FAMILY] # Specify a font family for the subtitles
44
44
  # Default: Open Sans Semibold
45
45
  -c, [--css=CSS] # Specify a CSS file path for Hidive subs
46
+ -l, [--line-offset=N] # Specify a line offset for the main dialog (e.g. 50 lowers the text line by 50px of the total height)
47
+ # Default: 0
46
48
  -q, [--quiet], [--no-quiet] # Don't output to the console
47
49
 
48
50
  Run the VTT to ASS conversion for the specified file(s)
@@ -45,12 +45,12 @@ class ASSFile
45
45
  # This method receives a VTTFile object and font arguments creates new ASSLine with the params of
46
46
  # each VTTLine. All those ASSLine are stored in an array. It also creates an array of ASSStyle that
47
47
  # will be used in the ASS style list.
48
- def convertVTTtoASS(vtt_file, font_family, font_size)
48
+ def convertVTTtoASS(vtt_file, font_family, font_size, line_offset = 0)
49
49
  fs = font_size
50
- font_color = '&H00FFFFFF'
51
- is_italic = false
52
- is_bold = false
53
50
  vtt_file.lines.each do |line|
51
+ font_color = '&H00FFFFFF'
52
+ is_italic = false
53
+ is_bold = false
54
54
  @ass_lines.push(ASSLine.new(line.style, line.time_start, line.time_end, line.text))
55
55
  style_exists = false
56
56
  @ass_styles.each do |style|
@@ -88,7 +88,7 @@ class ASSFile
88
88
  end
89
89
  end
90
90
  end
91
- @ass_styles.push(ASSStyle.new(line.style, line.params, font_family, font_size, font_color, is_bold, is_italic, @width, @height))
91
+ @ass_styles.push(ASSStyle.new(line.style, line.params, font_family, font_size, font_color, is_bold, is_italic, line_offset, @width, @height))
92
92
  end
93
93
  end
94
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, is_bold, is_italic, width, height)
18
+ def initialize(style_name, params, font_family, font_size, font_color, is_bold, is_italic, line_offset, width, height)
19
19
  @width = width
20
20
  @height = height
21
21
  @font_family = font_family
@@ -26,6 +26,9 @@ class ASSStyle
26
26
  if style_name.eql? 'MainTop' then
27
27
  @s_params.vertical_margin = 50
28
28
  end
29
+ if style_name.include? 'Subtitle' then
30
+ @s_params.vertical_margin -= line_offset
31
+ end
29
32
  @is_italic = is_italic
30
33
  @is_bold = is_bold
31
34
  end
@@ -23,6 +23,7 @@ class Application
23
23
  if options[:css] then
24
24
  @css = options[:css].gsub('\\', '/')
25
25
  end
26
+ @line_offset = options[:line_offset]
26
27
  end
27
28
 
28
29
  ##
@@ -60,7 +61,7 @@ class Application
60
61
  @height,
61
62
  defined?(@css) ? @css : nil
62
63
  )
63
- ass_file.convertVTTtoASS(vtt_file, @font_family, @font_size)
64
+ ass_file.convertVTTtoASS(vtt_file, @font_family, @font_size, @line_offset)
64
65
  return ass_file
65
66
  end
66
67
 
@@ -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.1"
7
+ VERSION = "0.3.2"
8
8
  end
data/lib/vtt2ass.rb CHANGED
@@ -16,6 +16,7 @@ class MainCommand < Thor
16
16
  method_option :font_size, :aliases => '-s', :desc => 'Specify a font size for the subtitles', :default => 52, :type => :numeric
17
17
  method_option :font_family, :aliases => '-f', :desc => 'Specify a font family for the subtitles', :default => 'Open Sans Semibold', :type => :string
18
18
  method_option :css, :aliases => '-c', :desc => 'Specify a CSS file path for Hidive subs', :type => :string
19
+ method_option :line_offset, :aliases => '-l', :desc => 'Specify a line offset for the main dialog (e.g. 50 lowers the text line by 50px of the total height)', :default => 0, :type => :numeric
19
20
  method_option :quiet, :aliases => '-q', :desc => 'Don\'t output to the console', :type => :boolean
20
21
  def convert(input)
21
22
  app = Application.new(input, options)
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis-Philippe Fortin