subtitle 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 +4 -4
- data/bin/subtitle +47 -0
- data/lib/subtitle.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31b778660729c43a9407881dbac119e6b562f892c9baded377c1e596fcbc7fcc
|
4
|
+
data.tar.gz: 34b2d312d08990f96dbb0ca563faa9f8c133b6232060fb4f7fcbdb7f582e4e3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bfe29b6598d9429f7ae33fc405cf631388fb6ddb259f0129d4737385b1d669bcbcf808e1f43fb3d8bc03a534953c115a44c3cd14d16a2176ad16978567a1092
|
7
|
+
data.tar.gz: ef2e59be78556617a0070b053c6e57735161761882ca2f00ecb17964032c401769fc5369cec1f7ecaeb3256d251e1e66b17bd49746f78abe6c8eb89f6b783da4
|
data/bin/subtitle
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'subtitle'
|
4
|
+
require 'optimist'
|
5
|
+
|
6
|
+
SUB_COMMANDS = %w(detectlang translate transform)
|
7
|
+
global_opts = Optimist::options do
|
8
|
+
banner "Subtitle Utility for lingual detection, translation from one language to another & transform from one format to another"
|
9
|
+
opt :access_key_id, "AWS Key", :type => :string, :short => "k"
|
10
|
+
opt :secret_access_key, "AWS Secret", :type => :string, :short => "s"
|
11
|
+
opt :profile, "AWS Profile", :type => :string, :short => "p"
|
12
|
+
#opt :api_key, "Google Translate API Key", :type => :string, :short => "a"
|
13
|
+
opt :cc_file, "Closed caption File", :type => :string, :short => "i", :required => true
|
14
|
+
opt :dest_lang, "Language code to translate", :type => :string, :short => "d"
|
15
|
+
opt :src_lang, "Source language", :type => :string, :short => "l"
|
16
|
+
opt :outfile, "Destination file / directory", :type => :string, :short => "f"
|
17
|
+
opt :force_detect, "Will try to infer the language even if language is provided. By default false if not provided", :type => :boolean, :short => "w", :default => false
|
18
|
+
opt :types, "comma seperated lowercase formats to convert to. valid values are srt, scc, vtt, ttml and dfxp", :type=>:string, :short => "t"
|
19
|
+
end
|
20
|
+
Optimist::die :cc_file, "File Does not Exist" unless File.exist?(global_opts[:cc_file]) if global_opts[:cc_file]
|
21
|
+
cmd = ARGV.shift # get the subcommand
|
22
|
+
cmd_opts = case cmd
|
23
|
+
when "detectlang" # parse detectlang options
|
24
|
+
subtitle = Subtitle.new(global_opts[:cc_file])
|
25
|
+
puts subtitle.detect_language(global_opts)
|
26
|
+
when "translate" # parse translate options
|
27
|
+
if global_opts[:dest_lang].nil?
|
28
|
+
puts "Need to provide destination language code option[-d] missing"
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
subtitle = Subtitle.new(global_opts[:cc_file])
|
32
|
+
subtitle.translate(global_opts[:dest_lang], global_opts[:src_lang], global_opts[:outfile], global_opts)
|
33
|
+
when "transform" # parse transform options
|
34
|
+
if global_opts[:outfile].nil? || global_opts[:types].nil?
|
35
|
+
puts "Need to provide destination location using option[-f] & types using option[-t]"
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
subtitle = Subtitle.new(global_opts[:cc_file])
|
39
|
+
type_values = global_opts[:types]
|
40
|
+
types = type_values.split(",")
|
41
|
+
# strip any leading and trailing spaces
|
42
|
+
types = types.map {|x| x.strip}
|
43
|
+
subtitle.transform(types, global_opts, global_opts[:dest_lang], global_opts[:src_lang] )
|
44
|
+
else
|
45
|
+
Optimist::die "unknown subcommand #{cmd.inspect}"
|
46
|
+
end
|
47
|
+
|
data/lib/subtitle.rb
CHANGED
@@ -41,7 +41,7 @@ class Subtitle
|
|
41
41
|
outfile
|
42
42
|
end
|
43
43
|
|
44
|
-
def transform(types,
|
44
|
+
def transform(types, options = nil, target_lang = nil, src_lang = nil)
|
45
45
|
# A quick validation & translation to expected arguments
|
46
46
|
vals = []
|
47
47
|
invalid_vals = []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subtitle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maheshwaran G
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-11-
|
12
|
+
date: 2019-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -102,10 +102,12 @@ description: " Subtitle gem helps you to detect the langua
|
|
102
102
|
email:
|
103
103
|
- pgmaheshwaran@gmail.com
|
104
104
|
- arunjeyaprasad@gmail.com
|
105
|
-
executables:
|
105
|
+
executables:
|
106
|
+
- subtitle
|
106
107
|
extensions: []
|
107
108
|
extra_rdoc_files: []
|
108
109
|
files:
|
110
|
+
- bin/subtitle
|
109
111
|
- lib/allfather.rb
|
110
112
|
- lib/dfxp.rb
|
111
113
|
- lib/engines/aws.rb
|