vtt2ass 0.3.5 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3047227acbd6bf731e5dc95113a7d70081bed94392e3b00078b760ebbc4440a4
4
- data.tar.gz: e9bc514e5b41028d872d9e983cc4dbd4442fc648ab1065e2c3e5a2aca3c9b8fd
3
+ metadata.gz: bacdcc421becff18a39326c953658fb28c07eb06bd5a4dacc951098e661a9601
4
+ data.tar.gz: ef37756d00cdfa88d23a778fd2ad0718e1129e74e412aa77a5ceebfd0daeb5f7
5
5
  SHA512:
6
- metadata.gz: 388af342ebe22e69e52e92e4dadf5a04ea48cb6e491398e864ed1e9d5ae3a602601cddc070ae20f7e8edef0b652a87aa3e8a66f8b8128626315dbac0dd421873
7
- data.tar.gz: fa2f3b0fa33c3ee1ade343b14837e8f09d2b5145f41e60f68e1cc7236e17e23c67cb7a811f5abf145df7e7121fd651364870073b6ff74679f6c9ddfe375a2ddc
6
+ metadata.gz: 74ffa9400ecd804d00fe2a5649cb9a7e5b0ebb14b2cb7fd1fe4744517b047c4af4e05edf5e0f9ad1b8d34e47ece1d4c8f8e74c749b78f88a193258853fffceb9
7
+ data.tar.gz: e861fe563ab6ef59085062bd1e2269ca56f20eb939df05eaead50ff78fb754c8339fdb4291c3cf9f357fdd5712df7a2fcbacdf8d4bce2a2773e11c51694d37ce
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
+ # RubyMine
2
+ .idea/
3
+
1
4
  # Lock file
2
5
  Gemfile.lock
3
6
 
@@ -39,12 +39,14 @@ class Application
39
39
  puts 'ERROR: The application stopped unexpectedly. The conversion may not have been completed.'
40
40
  rescue StandardError => e
41
41
  puts e.message
42
+ puts e.backtrace
42
43
  end
43
44
 
44
45
  ##
45
46
  # This method launches the conversion process on the specified input file.
46
47
  def convert(input_path)
47
48
  output = sanitize_path(@options[:output])
49
+ output = '.' if output.nil?
48
50
  raise StandardError, 'ERROR: Output directory does not exist.' unless File.directory?(output)
49
51
 
50
52
  ass_file = vtt_to_ass(input_path)
@@ -72,7 +74,8 @@ class Application
72
74
  @options[:height],
73
75
  css_file
74
76
  )
75
- ass_file.convert_vtt_to_ass(vtt_file, @options[:font_family], @options[:font_size], @options[:line_offset])
77
+ ass_file.convert_vtt_to_ass(vtt_file, @options[:font_family], @options[:font_size],
78
+ { line: @options[:line_offset], caption: @options[:caption_offset] })
76
79
  ass_file
77
80
  end
78
81
  end
@@ -16,6 +16,7 @@ class ASSFile
16
16
  def initialize(title, width, height, css_file_path = nil)
17
17
  @width = width
18
18
  @height = height
19
+ @css_file = nil
19
20
  @css_file = CSSFile.new(css_file_path) unless css_file_path.nil?
20
21
  @header = <<~HEADER
21
22
  [Script Info]
@@ -44,7 +45,7 @@ class ASSFile
44
45
  # This method receives a VTTFile object and font arguments creates new ASSLine with the params of
45
46
  # each VTTLine. All those ASSLine are stored in an array. It also creates an array of ASSStyle that
46
47
  # will be used in the ASS style list.
47
- def convert_vtt_to_ass(vtt_file, font_family, font_size, line_offset = 0) # rubocop:disable Metrics/MethodLength
48
+ def convert_vtt_to_ass(vtt_file, font_family, font_size, offset = { line: 0, caption: 0 }) # rubocop:disable Metrics/MethodLength
48
49
  fs = font_size
49
50
  vtt_file.lines.each do |line| # rubocop:disable Metrics/BlockLength
50
51
  font_color = '&H00FFFFFF'
@@ -83,7 +84,7 @@ class ASSFile
83
84
  ASSStyle.new(
84
85
  line.style, line.params,
85
86
  font_family, font_size, font_color, is_bold, is_italic,
86
- line_offset, @width, @height
87
+ offset, @width, @height
87
88
  )
88
89
  )
89
90
  end
@@ -16,7 +16,7 @@ class ASSStyle
16
16
  # * Requires +params+, a string of VTT styling as input.
17
17
  # * Requires a video +width+ as input.
18
18
  # * Requires a video +height+ as input.
19
- def initialize(style_name, params, font_family, font_size, font_color, is_bold, is_italic, line_offset, width, height)
19
+ def initialize(style_name, params, font_family, font_size, font_color, is_bold, is_italic, offset, width, height)
20
20
  @width = width
21
21
  @height = height
22
22
  @font_family = font_family
@@ -25,7 +25,8 @@ class ASSStyle
25
25
  @style_name = style_name
26
26
  @s_params = ASSStyleParams.new(params, width, height)
27
27
  @s_params.vertical_margin = 50 if style_name.eql? 'MainTop'
28
- @s_params.vertical_margin -= line_offset if style_name.include? 'Subtitle'
28
+ @s_params.vertical_margin -= offset[:line] if style_name.include?('Subtitle') || style_name.eql?('Main')
29
+ @s_params.vertical_margin += offset[:caption] if style_name.include?('Caption') || style_name.eql?('MainTop')
29
30
  @is_italic = is_italic
30
31
  @is_bold = is_bold
31
32
  end
@@ -10,6 +10,7 @@ class ASSStyleParams
10
10
  # It takes VTT style arguments and assign them to their respectful instance variable.
11
11
  # It calls methods to create ASS values from the VTT cue settings.
12
12
  def initialize(params, width, height)
13
+ @align = nil
13
14
  split_params(params)
14
15
  create_alignment
15
16
  create_horizontal_margin(width)
@@ -6,5 +6,5 @@ module Vtt2ass
6
6
  ##
7
7
  # This is the version of the application.
8
8
  # This needs to be changed for each gem release.
9
- VERSION = '0.3.5'
9
+ VERSION = '0.3.6'
10
10
  end
data/lib/vtt2ass.rb CHANGED
@@ -13,41 +13,56 @@ class MainCommand < Thor
13
13
  end
14
14
 
15
15
  desc 'convert INPUT', 'Run the VTT to ASS conversion for the specified file(s)'
16
- method_option :output, aliases: '-o',
17
- desc: 'Output directory of the converted file',
18
- lazy_default: './',
19
- type: :string
20
- method_option :title, aliases: '-t',
21
- desc: 'Specify a title for you file. If the input is a directory, '\
22
- 'all files will share the same title.',
23
- type: :string
24
- method_option :font_size, aliases: '-s',
25
- desc: 'Specify a font size for the subtitles',
26
- default: 52,
27
- type: :numeric
28
- method_option :font_family, aliases: '-f',
29
- desc: 'Specify a font family for the subtitles',
30
- default: 'Open Sans Semibold',
31
- type: :string
32
- method_option :css, aliases: '-c',
33
- desc: 'Specify a CSS file path for Hidive subs',
34
- type: :string
35
- method_option :line_offset, aliases: '-l',
36
- desc: 'Specify a line offset for the main dialog (e.g. 50 lowers the '\
37
- 'text line by 50px of the total height)',
38
- default: 0,
39
- type: :numeric
40
- method_option :width, aliases: '-w',
41
- desc: 'Specify the video width',
42
- default: 1920,
43
- type: :numeric
44
- method_option :height, aliases: '-h',
45
- desc: 'Specify the video height',
46
- default: 1080,
47
- type: :numeric
48
- method_option :quiet, aliases: '-q',
49
- desc: 'Don\'t output to the console',
50
- type: :boolean
16
+ method_option :output,
17
+ aliases: '-o',
18
+ desc: 'Output directory of the converted file',
19
+ lazy_default: './',
20
+ type: :string
21
+ method_option :title,
22
+ aliases: '-t',
23
+ desc: 'Specify a title for you file. If the input is a directory, '\
24
+ 'all files will share the same title.',
25
+ type: :string
26
+ method_option :font_size,
27
+ aliases: '-s',
28
+ desc: 'Specify a font size for the subtitles',
29
+ default: 52,
30
+ type: :numeric
31
+ method_option :font_family,
32
+ aliases: '-f',
33
+ desc: 'Specify a font family for the subtitles',
34
+ default: 'Open Sans Semibold',
35
+ type: :string
36
+ method_option :css,
37
+ aliases: '-c',
38
+ desc: 'Specify a CSS file path for Hidive subs',
39
+ type: :string
40
+ method_option :line_offset,
41
+ aliases: '-l',
42
+ desc: 'Specify a line offset for the main dialog (e.g. 50 lowers the '\
43
+ 'text line by 50px of the total height)',
44
+ default: 0,
45
+ type: :numeric
46
+ method_option :caption_offset,
47
+ aliases: '-z',
48
+ desc: 'Specify a line offset for the captions (e.g. 50 lowers the '\
49
+ 'text line by 50px of the total height)',
50
+ default: 0,
51
+ type: :numeric
52
+ method_option :width,
53
+ aliases: '-w',
54
+ desc: 'Specify the video width',
55
+ default: 1920,
56
+ type: :numeric
57
+ method_option :height,
58
+ aliases: '-h',
59
+ desc: 'Specify the video height',
60
+ default: 1080,
61
+ type: :numeric
62
+ method_option :quiet,
63
+ aliases: '-q',
64
+ desc: 'Don\'t output to the console',
65
+ type: :boolean
51
66
  def convert(input)
52
67
  app = Application.new(input, options)
53
68
  app.start
data/vtt2ass.gemspec CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.add_development_dependency 'minitest', '~> 5.0'
36
36
  spec.add_development_dependency 'rake', '~> 12.0'
37
+ spec.add_development_dependency 'rubocop', '~> 1.38'
37
38
  spec.add_development_dependency 'yard', '~> 0.9'
38
39
  spec.metadata['rubygems_mfa_required'] = 'true'
39
40
  end
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.3.5
4
+ version: 0.3.6
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: 2022-06-05 00:00:00.000000000 Z
11
+ date: 2022-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: css_parser
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '12.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.38'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.38'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: yard
99
113
  requirement: !ruby/object:Gem::Requirement