ass2srt 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/ass2srt +15 -0
- data/lib/ass2srt.rb +64 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b722d1f27d54e833216d4763568cc67d582004ea
|
4
|
+
data.tar.gz: 0246675f817b4a8492c72314e804eeeb8578c210
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d603a4309562397ff01f70553a2baa1869dbc71928326745939447d6f74d4075800b32ae7feb9a1717ff5b448928d3512d1b737c7e6f892065540d4cf2e45b0b
|
7
|
+
data.tar.gz: c947e32d13059a48c05d71eed9ac32a6c28fa8acc7614f08451c540bb5f137ab250887d2acdc6e82982c5a853b6d271441b1cbfee61a64e11d5a0d0427d117a3
|
data/bin/ass2srt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'ass2srt'
|
4
|
+
=begin
|
5
|
+
(Just a Ruby programming language syntax review again!!!)
|
6
|
+
ASS (Advanced Sub Station Alpha) !!! file converter to srt file
|
7
|
+
=end
|
8
|
+
|
9
|
+
if ARGV.length == 1
|
10
|
+
|
11
|
+
ass_to_srt ARGV[0]
|
12
|
+
|
13
|
+
else
|
14
|
+
puts "\nPlease enter ass filename only!!!"
|
15
|
+
end
|
data/lib/ass2srt.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
def desc_to_tag(description, txt)
|
2
|
+
|
3
|
+
case
|
4
|
+
when description == "Bold"
|
5
|
+
"<b>" << txt << "</b>"
|
6
|
+
when description == "Italic"
|
7
|
+
"<i>" << txt << "</i>"
|
8
|
+
else
|
9
|
+
txt
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
def dec_to_int(tm)
|
15
|
+
splitted_time = tm.split(/\./)
|
16
|
+
int_mill = (("0." << splitted_time[1]).to_f * 1000).to_i
|
17
|
+
splitted_time[0] << "," << int_mill.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def ass_to_srt(fname)
|
21
|
+
begin
|
22
|
+
|
23
|
+
splitted_filename = fname.split(/\./)
|
24
|
+
line_counter = 2
|
25
|
+
|
26
|
+
if splitted_filename.length < 2
|
27
|
+
raise "Invalid filename - " << fname
|
28
|
+
end
|
29
|
+
|
30
|
+
if splitted_filename[1] != "ass"
|
31
|
+
raise "Invalid file extension - " << splitted_filename[1]
|
32
|
+
end
|
33
|
+
|
34
|
+
ass_file = File.open(fname, 'r') do |f|
|
35
|
+
srt_file = File.open(splitted_filename[0] << ".srt", "w") do |f2|
|
36
|
+
|
37
|
+
f2.puts "1\n00:00:01,100 --> 00:00:10,100\n<b>Ass File to Srt By: Ferdinand Silva</b>\n\n"
|
38
|
+
|
39
|
+
while ln = f.gets
|
40
|
+
#write to srt file
|
41
|
+
|
42
|
+
splitted_line = ln.split(/,/)
|
43
|
+
if splitted_line.length > 8
|
44
|
+
if splitted_line[0] =~ /Dialogue/i
|
45
|
+
#Write line #
|
46
|
+
f2.puts line_counter
|
47
|
+
#Write time
|
48
|
+
f2.puts dec_to_int(splitted_line[1]) << " --> " << dec_to_int(splitted_line[2]) << "\n" << desc_to_tag(splitted_line[3], splitted_line[9])
|
49
|
+
#Write linebreak
|
50
|
+
f2.puts "\n"
|
51
|
+
|
52
|
+
#increment counter
|
53
|
+
line_counter += 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
puts "\n" << splitted_filename[0] << " file generated!!!\n"
|
61
|
+
rescue => exc
|
62
|
+
puts "An error occurred while opening the file " << fname << ". The error is: " << exc.message << "."
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ass2srt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ferdinand Silva
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: ASS (Advanced Sub Station Alpha) file converter to srt file
|
14
|
+
email: ferdinandsilva@ferdinandsilva.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- bin/ass2srt
|
20
|
+
- lib/ass2srt.rb
|
21
|
+
homepage: http://ferdinandsilva.com
|
22
|
+
licenses: []
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.2.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: ASS to SRT
|
44
|
+
test_files: []
|