vtt2ass 0.2.3 → 0.2.4

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: 061b3d7694d3decb80b649ab5a069339c17004bd6f4db37d7922a994d45d9dc8
4
- data.tar.gz: de903fad378c9e804fe48b746ef0ccbdeb6b6957ce342e32d935417f4c1917f4
3
+ metadata.gz: 84bd1994e916924d34b397b785492675e5403fb9d3c9863c9c2bf0d7aabfc7d8
4
+ data.tar.gz: 300b7640c078c7e180be5504dae5f7c41c0742c274bae5427476c6ff6495fbce
5
5
  SHA512:
6
- metadata.gz: 97dbb70be67d5e0542a5f3c93e0405e99f0fd21c977187e1255b90373cff95a8cc2fe6e10727153ddffe83a7e0103c5eb25784c9d4d1ffdad7b02a25319e09e0
7
- data.tar.gz: af521ea9ee5e80438d6fe4cc5949e888eefae23b0751f907c01a91a8547b454487f97770c2a2dd9cc2638457affab13786539aaa7324d4178ee97361c57cac1b
6
+ metadata.gz: 3a6bf3fc3b1e18102d07561585db6d4ed8f5f2f816693ee407b0dd63d31a969f513be8ffb091407bb0724f2eb4009da8a98163d0c2e577ba47970498b3eab579
7
+ data.tar.gz: 85e7b794c2b6f7b251657bf0842216bc519bfedadd6fb8d775d3bae579944da97c8b8c62fb9f68c0d4659771b3b0db50675e39e36da86cbd926b3e0ce9e18c3a
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # VTT to ASS
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/vtt2ass.svg)](https://badge.fury.io/rb/vtt2ass)
4
+
3
5
  This is a simple application to convert VTT files to ASS subtitles.
4
6
 
5
7
  ## Requirements
@@ -36,8 +38,15 @@ $ vtt2ass -h
36
38
  Usage: vtt2ass [options]
37
39
 
38
40
  Specific options:
39
- -i, --input DIRECTORY Specify a custom input directory (default: './input')
40
- -o, --output DIRECTORY Specify a custom output directory (default: './output')
41
+ -i, --input PATH Specify a custom input file or directory (default: './')
42
+ -o, --output PATH Specify a custom output directory (default: './')
43
+ -f, --font-family SIZE Specify a font family for the subtitles (default: 'Open Sans Semibold')
41
44
  -s, --font-size SIZE Specify a font size for the subtitles (default: 52)
42
45
  -v, --version Show version
43
46
  ```
47
+
48
+ # Donate
49
+
50
+ If you want to support me, consider buying me a coffee.
51
+
52
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Y8Y136P0E)
data/lib/vtt2ass.rb CHANGED
@@ -17,12 +17,15 @@ module Vtt2ass
17
17
  opts.banner = "Usage: vtt2ass [options]"
18
18
  opts.separator ""
19
19
  opts.separator "Specific options:"
20
- opts.on("-i", "--input DIRECTORY", "Specify a custom input directory (default: './input')") do |dir|
20
+ opts.on("-i", "--input PATH", "Specify a custom input file or directory (default: './')") do |dir|
21
21
  options[:input] = dir
22
22
  end
23
- opts.on("-o", "--output DIRECTORY", "Specify a custom output directory (default: './output')") do |dir|
23
+ opts.on("-o", "--output PATH", "Specify a custom output directory (default: './')") do |dir|
24
24
  options[:output] = dir
25
25
  end
26
+ opts.on("-f", "--font-family SIZE", String, "Specify a font family for the subtitles (default: 'Open Sans Semibold')") do |size|
27
+ options[:font_family] = size
28
+ end
26
29
  opts.on("-s", "--font-size SIZE", Integer, "Specify a font size for the subtitles (default: 52)") do |size|
27
30
  options[:font_size] = size
28
31
  end
@@ -10,9 +10,10 @@ class ASSStyle
10
10
  # * Requires +params+, a string of VTT styling as input.
11
11
  # * Requires a video +width+ as input.
12
12
  # * Requires a video +height+ as input.
13
- def initialize(style_name, params, font_size, width, height)
13
+ def initialize(style_name, params, font_family, font_size, width, height)
14
14
  @width = width
15
15
  @height = height
16
+ @font_family = font_family
16
17
  @font_size = font_size
17
18
  @style_name = style_name
18
19
  @s_params = StyleParams.new(params, width, height)
@@ -84,6 +85,6 @@ class ASSStyle
84
85
  ##
85
86
  # This method assigns the object values to an ASS style line and outputs it.
86
87
  def to_s
87
- return "Style: #{@style_name},Open Sans Semibold,#{@font_size},&H00FFFFFF,&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"
88
+ return "Style: #{@style_name},#{@font_family},#{@font_size},&H00FFFFFF,&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"
88
89
  end
89
90
  end
@@ -1,6 +1,5 @@
1
1
  # Imports
2
2
  require 'os'
3
- require 'fileutils'
4
3
 
5
4
  # Relative imports
6
5
  require_relative 'VTTSubtitle'
@@ -16,10 +15,11 @@ class Application
16
15
  # Creates a new Application instance.
17
16
  # It receives +options+ that can define the input and output directories.
18
17
  def initialize(options)
19
- @input_dir = options[:input] ? options[:input].gsub('\\', '/') : "./input"
20
- @output_dir = options[:output] ? options[:output].gsub('\\', '/') : "./output"
18
+ @input = options[:input] ? options[:input].gsub('\\', '/') : "./"
19
+ @output = options[:output] ? options[:output].gsub('\\', '/') : "./"
21
20
  @width = 1920
22
21
  @height = 1080
22
+ @font_family = options[:font_family] ? options[:font_family] : 'Open Sans Semibold'
23
23
  @font_size = options[:font_size] ? options[:font_size] : 52
24
24
  end
25
25
 
@@ -28,13 +28,22 @@ class Application
28
28
  # It sends the file_paths of VTT files in the input directory to convertFileToASS method
29
29
  # and outputs the resulting ASS format to a new file.
30
30
  def start
31
- Dir["#{@input_dir}/*.vtt"].each do |file_path|
32
- file_name = File.basename(file_path).gsub('.vtt', '.ass')
33
- FileUtils.mkdir_p @output_dir
34
- File.open("#{@output_dir}/" + file_name, 'w') do |line|
35
- line.print "\ufeff"
36
- line.puts convertFileToASS(file_path)
31
+ if File.directory?(@input) then
32
+ Dir["#{@input}/*.vtt"].each do |file_path|
33
+ writeFile(file_path)
37
34
  end
35
+ elsif File.file?(@input) then
36
+ writeFile(@input)
37
+ else
38
+ puts 'Error: input file or directory does not exist.'
39
+ end
40
+ end
41
+
42
+ def writeFile(file_path)
43
+ file_name = File.basename(file_path).gsub('.vtt', '.ass')
44
+ File.open("#{@output}/" + file_name, 'w') do |line|
45
+ line.print "\ufeff"
46
+ line.puts convertFileToASS(file_path)
38
47
  end
39
48
  end
40
49
 
@@ -74,7 +83,7 @@ class Application
74
83
  end
75
84
  end
76
85
  if not style_exists then
77
- ass_styles.push(ASSStyle.new(sub.style, sub.params, @font_size, @width, @height))
86
+ ass_styles.push(ASSStyle.new(sub.style, sub.params, @font_family, @font_size, @width, @height))
78
87
  end
79
88
  end
80
89
  return ASSFile.new(File.basename(file_path).gsub('.vtt', ''), ass_styles, ass_subs, @width, @height).to_s
@@ -1,3 +1,3 @@
1
1
  module Vtt2ass
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  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.2.3
4
+ version: 0.2.4
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-02-14 00:00:00.000000000 Z
11
+ date: 2021-02-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: