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 +4 -4
- data/README.md +11 -2
- data/lib/vtt2ass.rb +5 -2
- data/lib/vtt2ass/ASSStyle.rb +3 -2
- data/lib/vtt2ass/Application.rb +19 -10
- data/lib/vtt2ass/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84bd1994e916924d34b397b785492675e5403fb9d3c9863c9c2bf0d7aabfc7d8
|
4
|
+
data.tar.gz: 300b7640c078c7e180be5504dae5f7c41c0742c274bae5427476c6ff6495fbce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
40
|
-
-o, --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
|
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
|
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
|
data/lib/vtt2ass/ASSStyle.rb
CHANGED
@@ -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}
|
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
|
data/lib/vtt2ass/Application.rb
CHANGED
@@ -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
|
-
@
|
20
|
-
@
|
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
|
-
|
32
|
-
|
33
|
-
|
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
|
data/lib/vtt2ass/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|