subtitle-library 0.0.1
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.
- data/bin/subtitle-library +113 -0
- data/lib/subtitle-library.rb +3 -0
- data/lib/subtitle-library/changer.rb +117 -0
- data/lib/subtitle-library/cue.rb +16 -0
- data/lib/subtitle-library/reader.rb +357 -0
- data/lib/subtitle-library/regex-patterns.rb +8 -0
- data/lib/subtitle-library/writer.rb +93 -0
- data/test/integration/command-line-spec.rb +626 -0
- data/test/unit/changer-spec.rb +891 -0
- data/test/unit/reader-spec.rb +1053 -0
- data/test/unit/writer-spec.rb +830 -0
- metadata +84 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
module Patterns
|
2
|
+
SUB_RIP_TIMING = /\d{1,2}:\d{1,2}:\d{1,2},\d{1,3}/
|
3
|
+
SUB_RIP_LINE = /\s*#{SUB_RIP_TIMING}[ \t\r\f\v]?\-\->[ \t\r\f\v]?#{SUB_RIP_TIMING}$/
|
4
|
+
MICRO_DVD_LINE = /\s*\{\d+\}( |\t)?\{\d+\}( |\t)?(\{(y|Y):[ibus]{1,4}\})?(\{C:$[0-9a-fA-F]{6}\})?/
|
5
|
+
SUBVIEWER_LINE = /\s*\d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3},\d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3}$/
|
6
|
+
SUBVIEWER_METADATA = /(\[information\](\[title\][^\[]+)?(\[author\][^\[]+)?(\[source\][^\[]+)?(\[filepath\][^\[]+)?(\[delay\][ \t\r\f\v]*\d+[ \t\r\f\v]*)?(\[comment\][^\[]+)?\[end information\])?((\[subtitle\])?(\[colf\]&[0-9a-fA-F]{6,6})?(\[style\][^\[]+)?(\[size\][ \t\r\f\v]*\d+[ \t\r\f\v]*)?(\[font\][^\[]+)?)?$/i
|
7
|
+
end
|
8
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
class SubsWriter
|
2
|
+
def initialize(subs_reader)
|
3
|
+
@cues = subs_reader.cues
|
4
|
+
@fps = subs_reader.fps
|
5
|
+
@subs_type = subs_reader.type
|
6
|
+
end
|
7
|
+
|
8
|
+
def save_as(new_path, new_type, fps = -1)
|
9
|
+
fps = @fps if fps == -1
|
10
|
+
if @subs_type == 'md'
|
11
|
+
if new_type == 'md'
|
12
|
+
save_frames_to_frames new_path
|
13
|
+
else
|
14
|
+
save_frames_to_timing new_path, new_type, fps
|
15
|
+
end
|
16
|
+
else
|
17
|
+
if new_type == 'md'
|
18
|
+
save_timing_to_frames new_path, fps
|
19
|
+
else
|
20
|
+
save_timing_to_timing new_path, new_type
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def save_frames_to_frames(new_path)
|
26
|
+
File.open(new_path, 'w') do |subs|
|
27
|
+
subs.write('{1}{1}' + @fps.to_s + "\n")
|
28
|
+
@cues.each do |cue|
|
29
|
+
subs.write('{' + cue.start.to_s + '}{' + cue.ending.to_s + '}' + cue.text.gsub("\n", "|") + "\n")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def save_frames_to_timing(new_path, new_type, fps)
|
35
|
+
fps = fps.to_f
|
36
|
+
line_count = 1
|
37
|
+
bef_mil, bet_start_end = new_type == 'sr' ? [',', ' --> '] : ['.', ',']
|
38
|
+
File.open(new_path, 'w') do |subs|
|
39
|
+
subs.write("[STYLE]no\n") if new_type == 'sv'
|
40
|
+
@cues.each do |cue|
|
41
|
+
start = Time.mktime(1,1,1) + cue.start / fps
|
42
|
+
ending = Time.mktime(1,1,1) + cue.ending / fps
|
43
|
+
timing_line = start.to_s.split(' ')[1] + bef_mil + ("%03d" % (start.usec / 1000)) + bet_start_end
|
44
|
+
timing_line += ending.to_s.split(' ')[1] + bef_mil + ("%03d" % (ending.usec / 1000))
|
45
|
+
if start.year + start.month + start.day + ending.year + ending.month + ending.day != 6
|
46
|
+
puts 'Invalid timing'
|
47
|
+
break
|
48
|
+
end
|
49
|
+
if new_type == 'sr'
|
50
|
+
subs.write(line_count.to_s + "\n" + timing_line + "\n")
|
51
|
+
subs.write(cue.text + "\n\n")
|
52
|
+
line_count += 1
|
53
|
+
else
|
54
|
+
subs.write(timing_line + "\n")
|
55
|
+
subs.write(cue.text.gsub("\n", '[br]') + "\n\n")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def save_timing_to_frames(new_path, fps)
|
62
|
+
fps = fps.to_f
|
63
|
+
File.open(new_path, 'w') do |subs|
|
64
|
+
subs.write('{1}{1}' + fps.to_s + "\n")
|
65
|
+
bottom_time = Time.mktime 1, 1, 1
|
66
|
+
@cues.each do |cue|
|
67
|
+
start_frame = ((cue.start - bottom_time) * fps).ceil
|
68
|
+
end_frame = ((cue.ending - bottom_time) * fps).ceil
|
69
|
+
subs.write('{' + start_frame.to_s + '}{' + end_frame.to_s + '}' + cue.text.gsub("\n", "|") + "\n")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def save_timing_to_timing(new_path, new_type)
|
75
|
+
line_count = 1
|
76
|
+
bef_mil, bet_start_end = new_type == 'sr' ? [',', ' --> '] : ['.', ',']
|
77
|
+
File.open(new_path, 'w') do |subs|
|
78
|
+
subs.write("[STYLE]no\n") if new_type == 'sv'
|
79
|
+
@cues.each do |cue|
|
80
|
+
timing_line = cue.start.to_s.split(' ')[1] + bef_mil + ("%03d" % (cue.start.usec / 1000)) + bet_start_end
|
81
|
+
timing_line += cue.ending.to_s.split(' ')[1] + bef_mil + ("%03d" % (cue.ending.usec / 1000))
|
82
|
+
if new_type == 'sr'
|
83
|
+
subs.write(line_count.to_s + "\n" + timing_line + "\n")
|
84
|
+
subs.write(cue.text + "\n\n")
|
85
|
+
line_count += 1
|
86
|
+
else
|
87
|
+
subs.write(timing_line + "\n")
|
88
|
+
subs.write(cue.text.gsub("\n", '[br]') + "\n\n")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,626 @@
|
|
1
|
+
describe 'Command line tool' do
|
2
|
+
path = File.join(File.dirname(__FILE__), 'temp')
|
3
|
+
exec = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'subtitle-library')
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.after(:each) do
|
7
|
+
File.delete(path) if File.exists? path
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'recognises SubRip format' do
|
12
|
+
File.open(path, 'w') do |subs|
|
13
|
+
subs.write(<<-eos
|
14
|
+
12
|
15
|
+
00:02:04,240 --> 00:02:05,593
|
16
|
+
It was funny, huh?
|
17
|
+
|
18
|
+
13
|
19
|
+
00:02:06,320 --> 00:02:07,639
|
20
|
+
Yes, but I have to go.
|
21
|
+
|
22
|
+
14
|
23
|
+
00:02:07,840 --> 00:02:09,831
|
24
|
+
That'll teach you to excite yourself like this.
|
25
|
+
|
26
|
+
15
|
27
|
+
00:02:10,040 --> 00:02:12,508
|
28
|
+
Stop somewhere if you can.
|
29
|
+
|
30
|
+
16
|
31
|
+
00:02:43,560 --> 00:02:46,028
|
32
|
+
Honey, you're not at school.
|
33
|
+
Don't bother poor Elly.
|
34
|
+
eos
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
`ruby #{exec} -f #{path} -op recognise`.should eq "SubRip format.\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'recognises MicroDVD format' do
|
42
|
+
File.open(path, 'w') do |subs|
|
43
|
+
subs.write(<<-eos
|
44
|
+
{5277}{5309}You want some water with that?
|
45
|
+
{5311}{5345}No, no. No, I don't.
|
46
|
+
{5362}{5396}Looks like you had a night.
|
47
|
+
{5529}{5562}They look perfect.
|
48
|
+
eos
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
`ruby #{exec} -f #{path} -op recognise`.should eq "MicroDVD format.\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'recognises SubViewer format' do
|
56
|
+
File.open(path, 'w') do |subs|
|
57
|
+
subs.write(<<-eos
|
58
|
+
00:02:04.240,00:2:5.593
|
59
|
+
It was funny, huh?
|
60
|
+
|
61
|
+
00:02:06.20,00:02:07.639
|
62
|
+
Yes, but I have to go.
|
63
|
+
|
64
|
+
00:2:07.840,00:02:09.831
|
65
|
+
That'll teach you to excite yourself like this.
|
66
|
+
|
67
|
+
00:02:10.00,00:02:12.5
|
68
|
+
Stop somewhere if you can.
|
69
|
+
eos
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
`ruby #{exec} -f #{path} -op recognise`.should eq "SubViewer format.\n"
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'validates SubRip syntax' do
|
77
|
+
File.open(path, 'w') do |subs|
|
78
|
+
subs.write(<<-eos
|
79
|
+
12
|
80
|
+
00:02:04,240 --> 00:02:05,593
|
81
|
+
It was funny, huh?
|
82
|
+
|
83
|
+
13
|
84
|
+
00:02:06,320 -> 00:02:07,639
|
85
|
+
Yes, but I have to go.
|
86
|
+
|
87
|
+
14
|
88
|
+
00:02:07,840 --> 00:02:09,831
|
89
|
+
That'll teach you to excite yourself like this.
|
90
|
+
|
91
|
+
15
|
92
|
+
00:02:10,040 --> 00:02:12,508
|
93
|
+
Stop somewhere if you can.
|
94
|
+
|
95
|
+
16
|
96
|
+
00:02:43,560 --> 00:02:46,028
|
97
|
+
Honey, you're not at school.
|
98
|
+
Don't bother poor Elly.
|
99
|
+
eos
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
`ruby #{exec} -f #{path} -op verify`.should eq "Syntax error at line 6.\n"
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'validates MicroDVD syntax' do
|
107
|
+
File.open(path, 'w') do |subs|
|
108
|
+
subs.write(<<-eos
|
109
|
+
{5277}{5309}You want some water with that?
|
110
|
+
{5311}{5345}No, no. No, I don't.
|
111
|
+
{5362}{5396Looks like you had a night.
|
112
|
+
{5529}{5562}They look perfect.
|
113
|
+
eos
|
114
|
+
)
|
115
|
+
end
|
116
|
+
|
117
|
+
`ruby #{exec} -f #{path} -op verify`.should eq "Syntax error at line 3.\n"
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'validates SubViewer syntax' do
|
121
|
+
File.open(path, 'w') do |subs|
|
122
|
+
subs.write(<<-eos
|
123
|
+
00:02:04.240,00:2:5.593
|
124
|
+
It was funny, huh?
|
125
|
+
|
126
|
+
00:02:06.20,00:02:07.639
|
127
|
+
Yes, but I have to go.
|
128
|
+
d
|
129
|
+
|
130
|
+
00:2:07.840,00:02:09.831
|
131
|
+
That'll teach you to excite yourself like this.
|
132
|
+
|
133
|
+
00:02:10.00,00:02:12.5
|
134
|
+
Stop somewhere if you can.
|
135
|
+
eos
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
`ruby #{exec} -f #{path} -op verify`.should eq "Syntax error at line 6.\n"
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'sets the max line length of SubRip format' do
|
143
|
+
lines = "1\n"
|
144
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
145
|
+
lines += "You want some water with that?\n\n"
|
146
|
+
lines += "2\n"
|
147
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
148
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
149
|
+
lines += "3\n"
|
150
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
151
|
+
lines += "Looks like you had a night.\n\n"
|
152
|
+
|
153
|
+
File.open(path, 'w') do |subs|
|
154
|
+
subs.write(lines)
|
155
|
+
end
|
156
|
+
|
157
|
+
`ruby #{exec} -f #{path} -op carriage -cr 14`
|
158
|
+
|
159
|
+
lines = "1\n"
|
160
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
161
|
+
lines += "You want some water\nwith that?\n\n"
|
162
|
+
lines += "2\n"
|
163
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
164
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
165
|
+
lines += "3\n"
|
166
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
167
|
+
lines += "Looks like you had\na night.\n\n"
|
168
|
+
|
169
|
+
File.open(path, 'r') do |subs|
|
170
|
+
subs.read.should eq lines
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'sets the max line length of MicroDVD format' do
|
175
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
176
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
177
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
178
|
+
|
179
|
+
File.open(path, 'w') do |subs|
|
180
|
+
subs.write(lines)
|
181
|
+
end
|
182
|
+
|
183
|
+
`ruby #{exec} -f #{path} -op carriage -cr 14`
|
184
|
+
|
185
|
+
lines = "{1}{1}23.976\n"
|
186
|
+
lines += "{5277}{5309}You want some water|with that?\n"
|
187
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
188
|
+
lines += "{5362}{5396}Looks like you had|a night.\n"
|
189
|
+
|
190
|
+
File.open(path, 'r') do |subs|
|
191
|
+
subs.read.should eq lines
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'sets the max line length of SubViewer format' do
|
197
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
198
|
+
lines += "You want some water with that?\n\n"
|
199
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
200
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
201
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
202
|
+
lines += "Looks like you had a night.\n\n"
|
203
|
+
|
204
|
+
File.open(path, 'w') do |subs|
|
205
|
+
subs.write(lines)
|
206
|
+
end
|
207
|
+
|
208
|
+
`ruby #{exec} -f #{path} -op carriage -cr 14`
|
209
|
+
|
210
|
+
lines = "[STYLE]no\n"
|
211
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
212
|
+
lines += "You want some water[br]with that?\n\n"
|
213
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
214
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
215
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
216
|
+
lines += "Looks like you had[br]a night.\n\n"
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'shifts subtitles of SubRip format' do
|
221
|
+
lines = "1\n"
|
222
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
223
|
+
lines += "You want some water with that?\n\n"
|
224
|
+
lines += "2\n"
|
225
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
226
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
227
|
+
lines += "3\n"
|
228
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
229
|
+
lines += "Looks like you had a night.\n\n"
|
230
|
+
|
231
|
+
File.open(path, 'w') do |subs|
|
232
|
+
subs.write(lines)
|
233
|
+
end
|
234
|
+
|
235
|
+
`ruby #{exec} -f #{path} -op shift -ss 1.5`
|
236
|
+
|
237
|
+
lines = "1\n"
|
238
|
+
lines += "00:03:41,595 --> 00:03:42,929\n"
|
239
|
+
lines += "You want some water with that?\n\n"
|
240
|
+
lines += "2\n"
|
241
|
+
lines += "00:03:43,013 --> 00:03:44,431\n"
|
242
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
243
|
+
lines += "3\n"
|
244
|
+
lines += "00:03:45,140 --> 00:03:46,558\n"
|
245
|
+
lines += "Looks like you had a night.\n\n"
|
246
|
+
|
247
|
+
File.open(path, 'r') do |subs|
|
248
|
+
subs.read.should eq lines
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'shift subtitles of MicroDVD format' do
|
253
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
254
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
255
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
256
|
+
|
257
|
+
File.open(path, 'w') do |subs|
|
258
|
+
subs.write(lines)
|
259
|
+
end
|
260
|
+
|
261
|
+
`ruby #{exec} -f #{path} -op shift -fs 80`
|
262
|
+
|
263
|
+
lines = "{1}{1}23.976\n"
|
264
|
+
lines += "{5357}{5389}You want some water with that?\n"
|
265
|
+
lines += "{5391}{5425}No, no.|No, I don't.\n"
|
266
|
+
lines += "{5442}{5476}Looks like you had a night.\n"
|
267
|
+
|
268
|
+
File.open(path, 'r') do |subs|
|
269
|
+
subs.read.should eq lines
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'shifts subtitles of SubViewer format' do
|
274
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
275
|
+
lines += "You want some water with that?\n\n"
|
276
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
277
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
278
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
279
|
+
lines += "Looks like you had a night.\n\n"
|
280
|
+
|
281
|
+
File.open(path, 'w') do |subs|
|
282
|
+
subs.write(lines)
|
283
|
+
end
|
284
|
+
|
285
|
+
`ruby #{exec} -f #{path} -op shift -ss 1.5`
|
286
|
+
|
287
|
+
lines = "[STYLE]no\n"
|
288
|
+
lines += "00:03:41.595,00:03:42.929\n"
|
289
|
+
lines += "You want some water with that?\n\n"
|
290
|
+
lines += "00:03:43.013,00:03:44.431\n"
|
291
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
292
|
+
lines += "00:03:45.140,00:03:46.558\n"
|
293
|
+
lines += "Looks like you had a night.\n\n"
|
294
|
+
|
295
|
+
File.open(path, 'r') do |subs|
|
296
|
+
subs.read.should eq lines
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'stretches subtitles of SubRip format' do
|
301
|
+
lines = "1\n"
|
302
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
303
|
+
lines += "You want some water with that?\n\n"
|
304
|
+
lines += "2\n"
|
305
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
306
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
307
|
+
lines += "3\n"
|
308
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
309
|
+
lines += "Looks like you had a night.\n\n"
|
310
|
+
|
311
|
+
File.open(path, 'w') do |subs|
|
312
|
+
subs.write(lines)
|
313
|
+
end
|
314
|
+
|
315
|
+
`ruby #{exec} -f #{path} -op stretch -ss 1.5`
|
316
|
+
|
317
|
+
lines = "1\n"
|
318
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
319
|
+
lines += "You want some water with that?\n\n"
|
320
|
+
lines += "2\n"
|
321
|
+
lines += "00:03:43,013 --> 00:03:44,431\n"
|
322
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
323
|
+
lines += "3\n"
|
324
|
+
lines += "00:03:46,640 --> 00:03:48,058\n"
|
325
|
+
lines += "Looks like you had a night.\n\n"
|
326
|
+
|
327
|
+
File.open(path, 'r') do |subs|
|
328
|
+
subs.read.should eq lines
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
it 'strecthes subtitles of MicroDVD format' do
|
333
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
334
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
335
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
336
|
+
|
337
|
+
File.open(path, 'w') do |subs|
|
338
|
+
subs.write(lines)
|
339
|
+
end
|
340
|
+
|
341
|
+
`ruby #{exec} -f #{path} -op stretch -fs 80`
|
342
|
+
|
343
|
+
lines = "{1}{1}23.976\n"
|
344
|
+
lines += "{5277}{5309}You want some water with that?\n"
|
345
|
+
lines += "{5391}{5425}No, no.|No, I don't.\n"
|
346
|
+
lines += "{5522}{5556}Looks like you had a night.\n"
|
347
|
+
|
348
|
+
File.open(path, 'r') do |subs|
|
349
|
+
subs.read.should eq lines
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
it 'stretches subtitles of SubViewer format' do
|
354
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
355
|
+
lines += "You want some water with that?\n\n"
|
356
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
357
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
358
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
359
|
+
lines += "Looks like you had a night.\n\n"
|
360
|
+
|
361
|
+
File.open(path, 'w') do |subs|
|
362
|
+
subs.write(lines)
|
363
|
+
end
|
364
|
+
|
365
|
+
`ruby #{exec} -f #{path} -op stretch -ss 1.5`
|
366
|
+
|
367
|
+
lines = "[STYLE]no\n"
|
368
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
369
|
+
lines += "You want some water with that?\n\n"
|
370
|
+
lines += "00:03:43.013,00:03:44.431\n"
|
371
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
372
|
+
lines += "00:03:46.640,00:03:48.058\n"
|
373
|
+
lines += "Looks like you had a night.\n\n"
|
374
|
+
|
375
|
+
File.open(path, 'r') do |subs|
|
376
|
+
subs.read.should eq lines
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'saves from SubRip to Subrip format' do
|
381
|
+
lines = "1\n"
|
382
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
383
|
+
lines += "You want some water with that?\n\n"
|
384
|
+
lines += "2\n"
|
385
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
386
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
387
|
+
lines += "3\n"
|
388
|
+
lines += "00:03:43640 --> 00:03:45,058\n"
|
389
|
+
lines += "Looks like you had a night.\n\n"
|
390
|
+
|
391
|
+
File.open(path, 'w') do |subs|
|
392
|
+
subs.write(lines)
|
393
|
+
end
|
394
|
+
|
395
|
+
`ruby #{exec} -f #{path} -op save -nf #{path} -t sr`
|
396
|
+
|
397
|
+
lines = "1\n"
|
398
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
399
|
+
lines += "You want some water with that?\n\n"
|
400
|
+
lines += "2\n"
|
401
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
402
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
403
|
+
|
404
|
+
File.open(path, 'r') do |subs|
|
405
|
+
subs.read.should eq lines
|
406
|
+
end
|
407
|
+
|
408
|
+
end
|
409
|
+
|
410
|
+
it 'saves from SubRip to MicroDVD format' do
|
411
|
+
lines = "1\n"
|
412
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
413
|
+
lines += "You want some water with that?\n\n"
|
414
|
+
lines += "2\n"
|
415
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
416
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
417
|
+
lines += "3\n"
|
418
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
419
|
+
lines += "Looks like you had a night.\n\n"
|
420
|
+
|
421
|
+
File.open(path, 'w') do |subs|
|
422
|
+
subs.write(lines)
|
423
|
+
end
|
424
|
+
|
425
|
+
`ruby #{exec} -f #{path} -op save -nf #{path} -t md`
|
426
|
+
|
427
|
+
lines = "{1}{1}23.976\n"
|
428
|
+
lines += "{5277}{5309}You want some water with that?\n"
|
429
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
430
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
431
|
+
|
432
|
+
File.open(path, 'r') do |subs|
|
433
|
+
subs.read.should eq lines
|
434
|
+
end
|
435
|
+
|
436
|
+
end
|
437
|
+
|
438
|
+
it 'saves from SubRip to SubViewer format' do
|
439
|
+
lines = "1\n"
|
440
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
441
|
+
lines += "You want some water with that?\n\n"
|
442
|
+
lines += "2\n"
|
443
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
444
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
445
|
+
lines += "3\n"
|
446
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
447
|
+
lines += "Looks like you had a night.\n\n"
|
448
|
+
|
449
|
+
File.open(path, 'w') do |subs|
|
450
|
+
subs.write(lines)
|
451
|
+
end
|
452
|
+
|
453
|
+
`ruby #{exec} -f #{path} -op save -nf #{path} -t sv`
|
454
|
+
|
455
|
+
lines = "[STYLE]no\n"
|
456
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
457
|
+
lines += "You want some water with that?\n\n"
|
458
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
459
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
460
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
461
|
+
lines += "Looks like you had a night.\n\n"
|
462
|
+
|
463
|
+
File.open(path, 'r') do |subs|
|
464
|
+
subs.read.should eq lines
|
465
|
+
end
|
466
|
+
|
467
|
+
end
|
468
|
+
|
469
|
+
it 'saves from MicroDVD to SubRip format' do
|
470
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
471
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
472
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
473
|
+
|
474
|
+
File.open(path, 'w') do |subs|
|
475
|
+
subs.write(lines)
|
476
|
+
end
|
477
|
+
|
478
|
+
`ruby #{exec} -f #{path} -op save -nf #{path} -t sr`
|
479
|
+
|
480
|
+
lines = "1\n"
|
481
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
482
|
+
lines += "You want some water with that?\n\n"
|
483
|
+
lines += "2\n"
|
484
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
485
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
486
|
+
lines += "3\n"
|
487
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
488
|
+
lines += "Looks like you had a night.\n\n"
|
489
|
+
|
490
|
+
File.open(path, 'r') do |subs|
|
491
|
+
subs.read.should eq lines
|
492
|
+
end
|
493
|
+
|
494
|
+
end
|
495
|
+
|
496
|
+
it 'saves from MicroDVD to MicroDVD format' do
|
497
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
498
|
+
lines += "{5311{5345}No, no.|No, I don't.\n"
|
499
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
500
|
+
|
501
|
+
File.open(path, 'w') do |subs|
|
502
|
+
subs.write(lines)
|
503
|
+
end
|
504
|
+
|
505
|
+
`ruby #{exec} -f #{path} -op save -nf #{path} -t md`
|
506
|
+
|
507
|
+
lines = "{1}{1}23.976\n"
|
508
|
+
lines += "{5277}{5309}You want some water with that?\n"
|
509
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
510
|
+
|
511
|
+
File.open(path, 'r') do |subs|
|
512
|
+
subs.read.should eq lines
|
513
|
+
end
|
514
|
+
|
515
|
+
end
|
516
|
+
|
517
|
+
it 'saves from MicroDVD to SubViewer format' do
|
518
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
519
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
520
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
521
|
+
|
522
|
+
File.open(path, 'w') do |subs|
|
523
|
+
subs.write(lines)
|
524
|
+
end
|
525
|
+
|
526
|
+
`ruby #{exec} -f #{path} -op save -nf #{path} -t sv`
|
527
|
+
|
528
|
+
lines = "[STYLE]no\n"
|
529
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
530
|
+
lines += "You want some water with that?\n\n"
|
531
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
532
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
533
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
534
|
+
lines += "Looks like you had a night.\n\n"
|
535
|
+
|
536
|
+
File.open(path, 'r') do |subs|
|
537
|
+
subs.read.should eq lines
|
538
|
+
end
|
539
|
+
|
540
|
+
end
|
541
|
+
|
542
|
+
it 'saves from SubViewer to SubRip format' do
|
543
|
+
lines = "[STYLE]no\n"
|
544
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
545
|
+
lines += "You want some water with that?\n\n"
|
546
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
547
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
548
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
549
|
+
lines += "Looks like you had a night.\n\n"
|
550
|
+
|
551
|
+
File.open(path, 'w') do |subs|
|
552
|
+
subs.write(lines)
|
553
|
+
end
|
554
|
+
|
555
|
+
`ruby #{exec} -f #{path} -op save -nf #{path} -t sr`
|
556
|
+
|
557
|
+
lines = "1\n"
|
558
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
559
|
+
lines += "You want some water with that?\n\n"
|
560
|
+
lines += "2\n"
|
561
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
562
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
563
|
+
lines += "3\n"
|
564
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
565
|
+
lines += "Looks like you had a night.\n\n"
|
566
|
+
|
567
|
+
File.open(path, 'r') do |subs|
|
568
|
+
subs.read.should eq lines
|
569
|
+
end
|
570
|
+
|
571
|
+
end
|
572
|
+
|
573
|
+
it 'saves from SubViewer to MicroDVD format' do
|
574
|
+
lines = "[STYLE]no\n"
|
575
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
576
|
+
lines += "You want some water with that?\n\n"
|
577
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
578
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
579
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
580
|
+
lines += "Looks like you had a night.\n\n"
|
581
|
+
|
582
|
+
File.open(path, 'w') do |subs|
|
583
|
+
subs.write(lines)
|
584
|
+
end
|
585
|
+
|
586
|
+
`ruby #{exec} -f #{path} -op save -nf #{path} -t md`
|
587
|
+
|
588
|
+
lines = "{1}{1}23.976\n"
|
589
|
+
lines += "{5277}{5309}You want some water with that?\n"
|
590
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
591
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
592
|
+
|
593
|
+
File.open(path, 'r') do |subs|
|
594
|
+
subs.read.should eq lines
|
595
|
+
end
|
596
|
+
|
597
|
+
end
|
598
|
+
|
599
|
+
it 'saves from SubViewer to SubViewer format' do
|
600
|
+
lines = "[STYLE]no\n"
|
601
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
602
|
+
lines += "You want some water with that?\n\n"
|
603
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
604
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
605
|
+
lines += "00:03:43640,00:03:45.058\n"
|
606
|
+
lines += "Looks like you had a night.\n\n"
|
607
|
+
|
608
|
+
File.open(path, 'w') do |subs|
|
609
|
+
subs.write(lines)
|
610
|
+
end
|
611
|
+
|
612
|
+
`ruby #{exec} -f #{path} -op save -nf #{path} -t sv`
|
613
|
+
|
614
|
+
lines = "[STYLE]no\n"
|
615
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
616
|
+
lines += "You want some water with that?\n\n"
|
617
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
618
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
619
|
+
|
620
|
+
File.open(path, 'r') do |subs|
|
621
|
+
subs.read.should eq lines
|
622
|
+
end
|
623
|
+
|
624
|
+
end
|
625
|
+
|
626
|
+
end
|