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,830 @@
|
|
1
|
+
require 'subtitle-library'
|
2
|
+
require 'fakefs/safe'
|
3
|
+
|
4
|
+
describe SubsWriter do
|
5
|
+
include FakeFS
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.before(:each) do
|
9
|
+
FakeFS.activate!
|
10
|
+
FileSystem.clear
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.after(:each) do
|
16
|
+
FakeFS.deactivate!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def new_writer(path)
|
21
|
+
reader = SubsReader.new path
|
22
|
+
reader.load_cues
|
23
|
+
SubsWriter.new reader
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'saving from subrip to subrip format' do
|
27
|
+
path = 'subs.srt'
|
28
|
+
|
29
|
+
it 'saves the file as is when syntax is correct' do
|
30
|
+
FakeFS do
|
31
|
+
lines = "1\n"
|
32
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
33
|
+
lines += "You want some water with that?\n\n"
|
34
|
+
lines += "2\n"
|
35
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
36
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
37
|
+
lines += "3\n"
|
38
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
39
|
+
lines += "Looks like you had a night.\n\n"
|
40
|
+
|
41
|
+
File.open(path, 'w') do |subs|
|
42
|
+
subs.write(lines)
|
43
|
+
end
|
44
|
+
|
45
|
+
new_writer(path).save_as(path, 'sr')
|
46
|
+
|
47
|
+
File.open(path, 'r') do |subs|
|
48
|
+
subs.read.should eq lines
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'saves the valid cues when syntax is incorrect' do
|
55
|
+
FakeFS do
|
56
|
+
lines = "1\n"
|
57
|
+
lines += "00:03:40095 --> 00:03:41,429\n"
|
58
|
+
lines += "You want some water with that?\n\n"
|
59
|
+
lines += "2\n"
|
60
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
61
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
62
|
+
lines += "3\n"
|
63
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
64
|
+
lines += "Looks like you had a night.\n\n"
|
65
|
+
|
66
|
+
File.open(path, 'w') do |subs|
|
67
|
+
subs.write(lines)
|
68
|
+
end
|
69
|
+
|
70
|
+
new_writer(path).save_as(path, 'sr')
|
71
|
+
|
72
|
+
lines = "1\n"
|
73
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
74
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
75
|
+
lines += "2\n"
|
76
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
77
|
+
lines += "Looks like you had a night.\n\n"
|
78
|
+
|
79
|
+
File.open(path, 'r') do |subs|
|
80
|
+
subs.read.should eq lines
|
81
|
+
end
|
82
|
+
|
83
|
+
lines = "1\n"
|
84
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
85
|
+
lines += "You want some water with that?\n\n"
|
86
|
+
lines += "2\n"
|
87
|
+
lines += "00:03:41,513 -> 00:03:42,931\n"
|
88
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
89
|
+
lines += "3\n"
|
90
|
+
lines += "00:03:43,640 --> 0003:45,058\n"
|
91
|
+
lines += "Looks like you had a night.\n\n"
|
92
|
+
|
93
|
+
File.open(path, 'w') do |subs|
|
94
|
+
subs.write(lines)
|
95
|
+
end
|
96
|
+
|
97
|
+
new_writer(path).save_as(path, 'sr')
|
98
|
+
|
99
|
+
lines = "1\n"
|
100
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
101
|
+
lines += "You want some water with that?\n\n"
|
102
|
+
|
103
|
+
File.open(path, 'r') do |subs|
|
104
|
+
subs.read.should eq lines
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'saving from subrip to microdvd format' do
|
112
|
+
path = 'subs.sub'
|
113
|
+
|
114
|
+
it 'saves all the cues when syntax is correct' do
|
115
|
+
FakeFS do
|
116
|
+
lines = "1\n"
|
117
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
118
|
+
lines += "You want some water with that?\n\n"
|
119
|
+
lines += "2\n"
|
120
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
121
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
122
|
+
lines += "3\n"
|
123
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
124
|
+
lines += "Looks like you had a night.\n\n"
|
125
|
+
|
126
|
+
File.open(path, 'w') do |subs|
|
127
|
+
subs.write(lines)
|
128
|
+
end
|
129
|
+
|
130
|
+
new_writer(path).save_as(path, 'md')
|
131
|
+
|
132
|
+
lines = "{1}{1}23.976\n"
|
133
|
+
lines += "{5277}{5309}You want some water with that?\n"
|
134
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
135
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
136
|
+
|
137
|
+
File.open(path, 'r') do |subs|
|
138
|
+
subs.read.should eq lines
|
139
|
+
end
|
140
|
+
|
141
|
+
lines = "1\n"
|
142
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
143
|
+
lines += "You want some water with that?\n\n"
|
144
|
+
lines += "2\n"
|
145
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
146
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
147
|
+
lines += "3\n"
|
148
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
149
|
+
lines += "Looks like you had a night.\n\n"
|
150
|
+
|
151
|
+
File.open(path, 'w') do |subs|
|
152
|
+
subs.write(lines)
|
153
|
+
end
|
154
|
+
|
155
|
+
new_writer(path).save_as(path, 'md', 25)
|
156
|
+
|
157
|
+
lines = "{1}{1}25.0\n"
|
158
|
+
lines += "{5503}{5536}You want some water with that?\n"
|
159
|
+
lines += "{5538}{5574}No, no.|No, I don't.\n"
|
160
|
+
lines += "{5591}{5627}Looks like you had a night.\n"
|
161
|
+
|
162
|
+
File.open(path, 'r') do |subs|
|
163
|
+
subs.read.should eq lines
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'saves the valid cues when syntax is incorrect' do
|
170
|
+
FakeFS do
|
171
|
+
lines = "1\n"
|
172
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
173
|
+
lines += "You want some water with that?\n\n"
|
174
|
+
lines += "2\n"
|
175
|
+
lines += "00:03:41,513 -> 00:03:42,931\n"
|
176
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
177
|
+
lines += "3\n"
|
178
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
179
|
+
lines += "Looks like you had a night.\n\n"
|
180
|
+
|
181
|
+
File.open(path, 'w') do |subs|
|
182
|
+
subs.write(lines)
|
183
|
+
end
|
184
|
+
|
185
|
+
new_writer(path).save_as(path, 'md')
|
186
|
+
|
187
|
+
lines = "{1}{1}23.976\n"
|
188
|
+
lines += "{5277}{5309}You want some water with that?\n"
|
189
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
190
|
+
|
191
|
+
File.open(path, 'r') do |subs|
|
192
|
+
subs.read.should eq lines
|
193
|
+
end
|
194
|
+
|
195
|
+
lines = "1\n"
|
196
|
+
lines += "00:03:40095 --> 00:03:41,429\n"
|
197
|
+
lines += "You want some water with that?\n\n"
|
198
|
+
lines += "2\n"
|
199
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
200
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
201
|
+
lines += "3\n"
|
202
|
+
lines += "00:03:43,640 --> 00:035,058\n"
|
203
|
+
lines += "Looks like you had a night.\n\n"
|
204
|
+
|
205
|
+
File.open(path, 'w') do |subs|
|
206
|
+
subs.write(lines)
|
207
|
+
end
|
208
|
+
|
209
|
+
new_writer(path).save_as(path, 'md', 25)
|
210
|
+
|
211
|
+
lines = "{1}{1}25.0\n"
|
212
|
+
lines += "{5538}{5574}No, no.|No, I don't.\n"
|
213
|
+
|
214
|
+
File.open(path, 'r') do |subs|
|
215
|
+
subs.read.should eq lines
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe 'saving from subrip to subviewer format' do
|
224
|
+
path = 'subs.sub'
|
225
|
+
|
226
|
+
it 'saves all the cues when syntax is correct' do
|
227
|
+
FakeFS do
|
228
|
+
lines = "1\n"
|
229
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
230
|
+
lines += "You want some water with that?\n\n"
|
231
|
+
lines += "2\n"
|
232
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
233
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
234
|
+
lines += "3\n"
|
235
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
236
|
+
lines += "Looks like you had a night.\n\n"
|
237
|
+
|
238
|
+
File.open(path, 'w') do |subs|
|
239
|
+
subs.write(lines)
|
240
|
+
end
|
241
|
+
|
242
|
+
new_writer(path).save_as(path, 'sv')
|
243
|
+
|
244
|
+
lines = "[STYLE]no\n"
|
245
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
246
|
+
lines += "You want some water with that?\n\n"
|
247
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
248
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
249
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
250
|
+
lines += "Looks like you had a night.\n\n"
|
251
|
+
|
252
|
+
File.open(path, 'r') do |subs|
|
253
|
+
subs.read.should eq lines
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'saves the valid cues when syntax is incorrect' do
|
260
|
+
FakeFS do
|
261
|
+
lines = "1\n"
|
262
|
+
lines += "00:03:40095 --> 00:03:41,429\n"
|
263
|
+
lines += "You want some water with that?\n\n"
|
264
|
+
lines += "2\n"
|
265
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
266
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
267
|
+
lines += "3\n"
|
268
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
269
|
+
lines += "Looks like you had a night.\n\n"
|
270
|
+
|
271
|
+
File.open(path, 'w') do |subs|
|
272
|
+
subs.write(lines)
|
273
|
+
end
|
274
|
+
|
275
|
+
new_writer(path).save_as(path, 'sv')
|
276
|
+
|
277
|
+
lines = "[STYLE]no\n"
|
278
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
279
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
280
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
281
|
+
lines += "Looks like you had a night.\n\n"
|
282
|
+
|
283
|
+
File.open(path, 'r') do |subs|
|
284
|
+
subs.read.should eq lines
|
285
|
+
end
|
286
|
+
|
287
|
+
lines = "1\n"
|
288
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
289
|
+
lines += "You want some water with that?\n\n"
|
290
|
+
lines += "2\n"
|
291
|
+
lines += "00:03:41,513 -> 00:03:42,931\n"
|
292
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
293
|
+
lines += "3\n"
|
294
|
+
lines += "00:03:43,640 --> 0003:45,058\n"
|
295
|
+
lines += "Looks like you had a night.\n\n"
|
296
|
+
|
297
|
+
File.open(path, 'w') do |subs|
|
298
|
+
subs.write(lines)
|
299
|
+
end
|
300
|
+
|
301
|
+
new_writer(path).save_as(path, 'sv')
|
302
|
+
|
303
|
+
lines = "[STYLE]no\n"
|
304
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
305
|
+
lines += "You want some water with that?\n\n"
|
306
|
+
|
307
|
+
File.open(path, 'r') do |subs|
|
308
|
+
subs.read.should eq lines
|
309
|
+
end
|
310
|
+
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
describe 'saving from microdvd to subrip format' do
|
316
|
+
path = 'subs.srt'
|
317
|
+
|
318
|
+
it 'saves all the cues when syntax is correct' do
|
319
|
+
FakeFS do
|
320
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
321
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
322
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
323
|
+
|
324
|
+
File.open(path, 'w') do |subs|
|
325
|
+
subs.write(lines)
|
326
|
+
end
|
327
|
+
|
328
|
+
new_writer(path).save_as(path, 'sr')
|
329
|
+
|
330
|
+
lines = "1\n"
|
331
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
332
|
+
lines += "You want some water with that?\n\n"
|
333
|
+
lines += "2\n"
|
334
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
335
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
336
|
+
lines += "3\n"
|
337
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
338
|
+
lines += "Looks like you had a night.\n\n"
|
339
|
+
|
340
|
+
File.open(path, 'r') do |subs|
|
341
|
+
subs.read.should eq lines
|
342
|
+
end
|
343
|
+
|
344
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
345
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
346
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
347
|
+
|
348
|
+
File.open(path, 'w') do |subs|
|
349
|
+
subs.write(lines)
|
350
|
+
end
|
351
|
+
|
352
|
+
new_writer(path).save_as(path, 'sr', 25)
|
353
|
+
|
354
|
+
lines = "1\n"
|
355
|
+
lines += "00:03:31,080 --> 00:03:32,360\n"
|
356
|
+
lines += "You want some water with that?\n\n"
|
357
|
+
lines += "2\n"
|
358
|
+
lines += "00:03:32,439 --> 00:03:33,800\n"
|
359
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
360
|
+
lines += "3\n"
|
361
|
+
lines += "00:03:34,479 --> 00:03:35,840\n"
|
362
|
+
lines += "Looks like you had a night.\n\n"
|
363
|
+
|
364
|
+
File.open(path, 'r') do |subs|
|
365
|
+
subs.read.should eq lines
|
366
|
+
end
|
367
|
+
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
it 'saves the valid cues when syntax is incorrect' do
|
372
|
+
FakeFS do
|
373
|
+
lines = "{5277{5309}You want some water with that?\n"
|
374
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
375
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
376
|
+
|
377
|
+
File.open(path, 'w') do |subs|
|
378
|
+
subs.write(lines)
|
379
|
+
end
|
380
|
+
|
381
|
+
new_writer(path).save_as(path, 'sr')
|
382
|
+
|
383
|
+
lines = "1\n"
|
384
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
385
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
386
|
+
lines += "2\n"
|
387
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
388
|
+
lines += "Looks like you had a night.\n\n"
|
389
|
+
|
390
|
+
File.open(path, 'r') do |subs|
|
391
|
+
subs.read.should eq lines
|
392
|
+
end
|
393
|
+
|
394
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
395
|
+
lines += "{5311}{345}No, no.|No, I don't.\n"
|
396
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
397
|
+
|
398
|
+
File.open(path, 'w') do |subs|
|
399
|
+
subs.write(lines)
|
400
|
+
end
|
401
|
+
|
402
|
+
new_writer(path).save_as(path, 'sr', 25)
|
403
|
+
|
404
|
+
lines = "1\n"
|
405
|
+
lines += "00:03:31,080 --> 00:03:32,360\n"
|
406
|
+
lines += "You want some water with that?\n\n"
|
407
|
+
lines += "2\n"
|
408
|
+
lines += "00:03:34,479 --> 00:03:35,840\n"
|
409
|
+
lines += "Looks like you had a night.\n\n"
|
410
|
+
|
411
|
+
File.open(path, 'r') do |subs|
|
412
|
+
subs.read.should eq lines
|
413
|
+
end
|
414
|
+
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
describe 'saving from microdvd to microdvd format' do
|
420
|
+
path = 'subs.sub'
|
421
|
+
|
422
|
+
it 'saves the file as is when syntax is correct' do
|
423
|
+
FakeFS do
|
424
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
425
|
+
lines += "{5311}{5345}No, no. No, I don't.\n"
|
426
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
427
|
+
|
428
|
+
File.open(path, 'w') do |subs|
|
429
|
+
subs.write(lines)
|
430
|
+
end
|
431
|
+
|
432
|
+
new_writer(path).save_as(path, 'md')
|
433
|
+
|
434
|
+
lines = "{1}{1}23.976\n" + lines
|
435
|
+
|
436
|
+
File.open(path, 'r') do |subs|
|
437
|
+
subs.read.should eq lines
|
438
|
+
end
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
it 'saves only the valid cues when syntax is incorrect' do
|
443
|
+
FakeFS do
|
444
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
445
|
+
lines += "{5311}5345}No, no. No, I don't.\n"
|
446
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
447
|
+
|
448
|
+
File.open(path, 'w') do |subs|
|
449
|
+
subs.write(lines)
|
450
|
+
end
|
451
|
+
|
452
|
+
new_writer(path).save_as(path, 'md')
|
453
|
+
|
454
|
+
lines = "{1}{1}23.976\n" + "{5277}{5309}You want some water with that?\n"
|
455
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
456
|
+
|
457
|
+
File.open(path, 'r') do |subs|
|
458
|
+
subs.read.should eq lines
|
459
|
+
end
|
460
|
+
end
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
describe 'saving from microdvd to subviewer format' do
|
465
|
+
path = 'subs.sub'
|
466
|
+
|
467
|
+
it 'saves all the cues when syntax is correct' do
|
468
|
+
FakeFS do
|
469
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
470
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
471
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
472
|
+
|
473
|
+
File.open(path, 'w') do |subs|
|
474
|
+
subs.write(lines)
|
475
|
+
end
|
476
|
+
|
477
|
+
new_writer(path).save_as(path, 'sv')
|
478
|
+
|
479
|
+
lines = "[STYLE]no\n"
|
480
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
481
|
+
lines += "You want some water with that?\n\n"
|
482
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
483
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
484
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
485
|
+
lines += "Looks like you had a night.\n\n"
|
486
|
+
|
487
|
+
File.open(path, 'r') do |subs|
|
488
|
+
subs.read.should eq lines
|
489
|
+
end
|
490
|
+
|
491
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
492
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
493
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
494
|
+
|
495
|
+
File.open(path, 'w') do |subs|
|
496
|
+
subs.write(lines)
|
497
|
+
end
|
498
|
+
|
499
|
+
new_writer(path).save_as(path, 'sv', 25)
|
500
|
+
|
501
|
+
lines = "[STYLE]no\n"
|
502
|
+
lines += "00:03:31.080,00:03:32.360\n"
|
503
|
+
lines += "You want some water with that?\n\n"
|
504
|
+
lines += "00:03:32.439,00:03:33.800\n"
|
505
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
506
|
+
lines += "00:03:34.479,00:03:35.840\n"
|
507
|
+
lines += "Looks like you had a night.\n\n"
|
508
|
+
|
509
|
+
File.open(path, 'r') do |subs|
|
510
|
+
subs.read.should eq lines
|
511
|
+
end
|
512
|
+
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
it 'saves the valid cues when syntax is incorrect' do
|
517
|
+
FakeFS 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
|
+
new_writer(path).save_as(path, 'sv')
|
527
|
+
|
528
|
+
lines = "[STYLE]no\n"
|
529
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
530
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
531
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
532
|
+
lines += "Looks like you had a night.\n\n"
|
533
|
+
|
534
|
+
File.open(path, 'r') do |subs|
|
535
|
+
subs.read.should eq lines
|
536
|
+
end
|
537
|
+
|
538
|
+
lines = "{5277}{5309}You want some water with that?\n"
|
539
|
+
lines += "{5311}{345}No, no.|No, I don't.\n"
|
540
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
541
|
+
|
542
|
+
File.open(path, 'w') do |subs|
|
543
|
+
subs.write(lines)
|
544
|
+
end
|
545
|
+
|
546
|
+
new_writer(path).save_as(path, 'sv', 25)
|
547
|
+
|
548
|
+
lines = "[STYLE]no\n"
|
549
|
+
lines += "00:03:31.080,00:03:32.360\n"
|
550
|
+
lines += "You want some water with that?\n\n"
|
551
|
+
lines += "00:03:34.479,00:03:35.840\n"
|
552
|
+
lines += "Looks like you had a night.\n\n"
|
553
|
+
|
554
|
+
File.open(path, 'r') do |subs|
|
555
|
+
subs.read.should eq lines
|
556
|
+
end
|
557
|
+
|
558
|
+
end
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
562
|
+
describe 'saving from subviewer to subrip format' do
|
563
|
+
path = 'subs.srt'
|
564
|
+
|
565
|
+
it 'saves all the cues when syntax is correct' do
|
566
|
+
FakeFS do
|
567
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
568
|
+
lines += "You want some water with that?\n\n"
|
569
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
570
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
571
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
572
|
+
lines += "Looks like you had a night.\n\n"
|
573
|
+
|
574
|
+
File.open(path, 'w') do |subs|
|
575
|
+
subs.write(lines)
|
576
|
+
end
|
577
|
+
|
578
|
+
lines = "1\n"
|
579
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
580
|
+
lines += "You want some water with that?\n\n"
|
581
|
+
lines += "2\n"
|
582
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
583
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
584
|
+
lines += "3\n"
|
585
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
586
|
+
lines += "Looks like you had a night.\n\n"
|
587
|
+
|
588
|
+
new_writer(path).save_as(path, 'sr')
|
589
|
+
|
590
|
+
File.open(path, 'r') do |subs|
|
591
|
+
subs.read.should eq lines
|
592
|
+
end
|
593
|
+
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
it 'saves the valid cues when syntax is incorrect' do
|
598
|
+
FakeFS do
|
599
|
+
|
600
|
+
lines = "00:03:40,095,00:03:41.429\n"
|
601
|
+
lines += "You want some water with that?\n\n"
|
602
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
603
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
604
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
605
|
+
lines += "Looks like you had a night.\n\n"
|
606
|
+
|
607
|
+
File.open(path, 'w') do |subs|
|
608
|
+
subs.write(lines)
|
609
|
+
end
|
610
|
+
|
611
|
+
new_writer(path).save_as(path, 'sr')
|
612
|
+
|
613
|
+
lines = "1\n"
|
614
|
+
lines += "00:03:41,513 --> 00:03:42,931\n"
|
615
|
+
lines += "No, no.\nNo, I don't.\n\n"
|
616
|
+
lines += "2\n"
|
617
|
+
lines += "00:03:43,640 --> 00:03:45,058\n"
|
618
|
+
lines += "Looks like you had a night.\n\n"
|
619
|
+
|
620
|
+
File.open(path, 'r') do |subs|
|
621
|
+
subs.read.should eq lines
|
622
|
+
end
|
623
|
+
|
624
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
625
|
+
lines += "You want some water with that?\n\n"
|
626
|
+
lines += "00:03:41.,00:03:42.931\n"
|
627
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
628
|
+
lines += "00:03:43.64000:03:45.058\n"
|
629
|
+
lines += "Looks like you had a night.\n\n"
|
630
|
+
|
631
|
+
File.open(path, 'w') do |subs|
|
632
|
+
subs.write(lines)
|
633
|
+
end
|
634
|
+
|
635
|
+
new_writer(path).save_as(path, 'sr')
|
636
|
+
|
637
|
+
lines = "1\n"
|
638
|
+
lines += "00:03:40,095 --> 00:03:41,429\n"
|
639
|
+
lines += "You want some water with that?\n\n"
|
640
|
+
|
641
|
+
File.open(path, 'r') do |subs|
|
642
|
+
subs.read.should eq lines
|
643
|
+
end
|
644
|
+
|
645
|
+
end
|
646
|
+
end
|
647
|
+
end
|
648
|
+
|
649
|
+
describe 'saving from subviewer to microdvd format' do
|
650
|
+
path = 'subs.sub'
|
651
|
+
|
652
|
+
it 'saves all the cues when syntax is correct' do
|
653
|
+
FakeFS do
|
654
|
+
|
655
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
656
|
+
lines += "You want some water with that?\n\n"
|
657
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
658
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
659
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
660
|
+
lines += "Looks like you had a night.\n\n"
|
661
|
+
|
662
|
+
File.open(path, 'w') do |subs|
|
663
|
+
subs.write(lines)
|
664
|
+
end
|
665
|
+
|
666
|
+
new_writer(path).save_as(path, 'md')
|
667
|
+
|
668
|
+
lines = "{1}{1}23.976\n"
|
669
|
+
lines += "{5277}{5309}You want some water with that?\n"
|
670
|
+
lines += "{5311}{5345}No, no.|No, I don't.\n"
|
671
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
672
|
+
|
673
|
+
File.open(path, 'r') do |subs|
|
674
|
+
subs.read.should eq lines
|
675
|
+
end
|
676
|
+
|
677
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
678
|
+
lines += "You want some water with that?\n\n"
|
679
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
680
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
681
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
682
|
+
lines += "Looks like you had a night.\n\n"
|
683
|
+
|
684
|
+
File.open(path, 'w') do |subs|
|
685
|
+
subs.write(lines)
|
686
|
+
end
|
687
|
+
|
688
|
+
new_writer(path).save_as(path, 'md', 25)
|
689
|
+
|
690
|
+
lines = "{1}{1}25.0\n"
|
691
|
+
lines += "{5503}{5536}You want some water with that?\n"
|
692
|
+
lines += "{5538}{5574}No, no.|No, I don't.\n"
|
693
|
+
lines += "{5591}{5627}Looks like you had a night.\n"
|
694
|
+
|
695
|
+
File.open(path, 'r') do |subs|
|
696
|
+
subs.read.should eq lines
|
697
|
+
end
|
698
|
+
|
699
|
+
end
|
700
|
+
end
|
701
|
+
|
702
|
+
it 'saves the valid cues when syntax is incorrect' do
|
703
|
+
FakeFS do
|
704
|
+
|
705
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
706
|
+
lines += "You want some water with that?\n\n"
|
707
|
+
lines += "00:03:41.51300:03:42.931\n"
|
708
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
709
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
710
|
+
lines += "Looks like you had a night.\n\n"
|
711
|
+
|
712
|
+
File.open(path, 'w') do |subs|
|
713
|
+
subs.write(lines)
|
714
|
+
end
|
715
|
+
|
716
|
+
new_writer(path).save_as(path, 'md')
|
717
|
+
|
718
|
+
lines = "{1}{1}23.976\n"
|
719
|
+
lines += "{5277}{5309}You want some water with that?\n"
|
720
|
+
lines += "{5362}{5396}Looks like you had a night.\n"
|
721
|
+
|
722
|
+
File.open(path, 'r') do |subs|
|
723
|
+
subs.read.should eq lines
|
724
|
+
end
|
725
|
+
|
726
|
+
lines = "00:03:40.095,0003:41.429\n"
|
727
|
+
lines += "You want some water with that?\n\n"
|
728
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
729
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
730
|
+
lines += "00:03:43;640,00:03:45.058\n"
|
731
|
+
lines += "Looks like you had a night.\n\n"
|
732
|
+
|
733
|
+
File.open(path, 'w') do |subs|
|
734
|
+
subs.write(lines)
|
735
|
+
end
|
736
|
+
|
737
|
+
new_writer(path).save_as(path, 'md', 25)
|
738
|
+
|
739
|
+
lines = "{1}{1}25.0\n"
|
740
|
+
lines += "{5538}{5574}No, no.|No, I don't.\n"
|
741
|
+
|
742
|
+
File.open(path, 'r') do |subs|
|
743
|
+
subs.read.should eq lines
|
744
|
+
end
|
745
|
+
|
746
|
+
end
|
747
|
+
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
751
|
+
describe 'saving from subviewer to subviewer format' do
|
752
|
+
path = 'subs.sub'
|
753
|
+
|
754
|
+
it 'saves the file as is when syntax is correct' do
|
755
|
+
FakeFS do
|
756
|
+
|
757
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
758
|
+
lines += "You want some water with that?\n\n"
|
759
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
760
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
761
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
762
|
+
lines += "Looks like you had a night.\n\n"
|
763
|
+
|
764
|
+
File.open(path, 'w') do |subs|
|
765
|
+
subs.write(lines)
|
766
|
+
end
|
767
|
+
|
768
|
+
new_writer(path).save_as(path, 'sv')
|
769
|
+
|
770
|
+
lines = "[STYLE]no\n" + lines
|
771
|
+
|
772
|
+
File.open(path, 'r') do |subs|
|
773
|
+
subs.read.should eq lines
|
774
|
+
end
|
775
|
+
|
776
|
+
end
|
777
|
+
end
|
778
|
+
|
779
|
+
it 'saves the valid cues when syntax is incorrect' do
|
780
|
+
FakeFS do
|
781
|
+
|
782
|
+
lines = "00:03:40.095,00:03:34.429\n"
|
783
|
+
lines += "You want some water with that?\n\n"
|
784
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
785
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
786
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
787
|
+
lines += "Looks like you had a night.\n\n"
|
788
|
+
|
789
|
+
File.open(path, 'w') do |subs|
|
790
|
+
subs.write(lines)
|
791
|
+
end
|
792
|
+
|
793
|
+
new_writer(path).save_as(path, 'sv')
|
794
|
+
|
795
|
+
lines = "[STYLE]no\n"
|
796
|
+
lines += "00:03:41.513,00:03:42.931\n"
|
797
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
798
|
+
lines += "00:03:43.640,00:03:45.058\n"
|
799
|
+
lines += "Looks like you had a night.\n\n"
|
800
|
+
|
801
|
+
File.open(path, 'r') do |subs|
|
802
|
+
subs.read.should eq lines
|
803
|
+
end
|
804
|
+
|
805
|
+
lines = "00:03:40.095,00:03:41.429\n"
|
806
|
+
lines += "You want some water with that?\n\n"
|
807
|
+
lines += "00:03:41.513,00:03;42.931\n"
|
808
|
+
lines += "No, no.[br]No, I don't.\n\n"
|
809
|
+
lines += "00:03:43.640.00:03:45.058\n"
|
810
|
+
lines += "Looks like you had a night.\n\n"
|
811
|
+
|
812
|
+
File.open(path, 'w') do |subs|
|
813
|
+
subs.write(lines)
|
814
|
+
end
|
815
|
+
|
816
|
+
new_writer(path).save_as(path, 'sv')
|
817
|
+
|
818
|
+
lines = "[STYLE]no\n"
|
819
|
+
lines += "00:03:40.095,00:03:41.429\n"
|
820
|
+
lines += "You want some water with that?\n\n"
|
821
|
+
|
822
|
+
File.open(path, 'r') do |subs|
|
823
|
+
subs.read.should eq lines
|
824
|
+
end
|
825
|
+
|
826
|
+
end
|
827
|
+
end
|
828
|
+
end
|
829
|
+
|
830
|
+
end
|