titlekit 1.0.0

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.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +22 -0
  6. data/README.md +335 -0
  7. data/Rakefile +8 -0
  8. data/lib/titlekit/have.rb +90 -0
  9. data/lib/titlekit/job.rb +446 -0
  10. data/lib/titlekit/parsers/ass.rb +175 -0
  11. data/lib/titlekit/parsers/ass.treetop +72 -0
  12. data/lib/titlekit/parsers/srt.rb +139 -0
  13. data/lib/titlekit/parsers/srt.treetop +73 -0
  14. data/lib/titlekit/parsers/ssa.rb +201 -0
  15. data/lib/titlekit/parsers/ssa.treetop +72 -0
  16. data/lib/titlekit/specification.rb +131 -0
  17. data/lib/titlekit/utilities.rb +3 -0
  18. data/lib/titlekit/version.rb +3 -0
  19. data/lib/titlekit/want.rb +24 -0
  20. data/lib/titlekit.rb +9 -0
  21. data/spec/ass_spec.rb +113 -0
  22. data/spec/automatic_grouping/automatic_grouping_spec.rb +55 -0
  23. data/spec/automatic_grouping/dual_tracks/expected.srt +15 -0
  24. data/spec/automatic_grouping/dual_tracks/one.srt +11 -0
  25. data/spec/automatic_grouping/dual_tracks/out.srt +15 -0
  26. data/spec/automatic_grouping/dual_tracks/two.srt +11 -0
  27. data/spec/automatic_grouping/single_track/expected.srt +24 -0
  28. data/spec/automatic_grouping/single_track/one.srt +11 -0
  29. data/spec/automatic_grouping/single_track/out.srt +24 -0
  30. data/spec/automatic_grouping/single_track/two.srt +11 -0
  31. data/spec/encoding_detection/a/in.ass +0 -0
  32. data/spec/encoding_detection/b/in.srt +2389 -0
  33. data/spec/encoding_detection/b/out.srt +2389 -0
  34. data/spec/encoding_detection/c/in.srt +5320 -0
  35. data/spec/encoding_detection/c/out.srt +5320 -0
  36. data/spec/encoding_detection/encoding_detection_spec.rb +81 -0
  37. data/spec/files/ass/authentic.ass +0 -0
  38. data/spec/files/ass/hard.ass +37 -0
  39. data/spec/files/ass/simple.ass +28 -0
  40. data/spec/files/srt/authentic.srt +2708 -0
  41. data/spec/files/srt/coordinates.srt +13 -0
  42. data/spec/files/srt/simple.srt +12 -0
  43. data/spec/files/ssa/simple.ssa +26 -0
  44. data/spec/files/try/unsupported-output.try +0 -0
  45. data/spec/files/try/unsupported.try +7 -0
  46. data/spec/format_conversion/ass_srt/expected.srt +2327 -0
  47. data/spec/format_conversion/ass_srt/in.ass +485 -0
  48. data/spec/format_conversion/ass_srt/out.srt +2327 -0
  49. data/spec/format_conversion/format_conversion_spec.rb +112 -0
  50. data/spec/format_conversion/srt_ass/expected.ass +19 -0
  51. data/spec/format_conversion/srt_ass/in.srt +12 -0
  52. data/spec/format_conversion/srt_ass/out.ass +19 -0
  53. data/spec/format_conversion/srt_ssa/expected.ssa +19 -0
  54. data/spec/format_conversion/srt_ssa/in.srt +12 -0
  55. data/spec/format_conversion/srt_ssa/out.ssa +19 -0
  56. data/spec/format_conversion/ssa_srt/expected.srt +9 -0
  57. data/spec/format_conversion/ssa_srt/in.ssa +26 -0
  58. data/spec/format_conversion/ssa_srt/out.srt +9 -0
  59. data/spec/job_spec.rb +162 -0
  60. data/spec/simultaneous_subtitles/dual/ass/expected.ass +22 -0
  61. data/spec/simultaneous_subtitles/dual/ass/out.ass +22 -0
  62. data/spec/simultaneous_subtitles/dual/one.srt +11 -0
  63. data/spec/simultaneous_subtitles/dual/srt/expected.srt +27 -0
  64. data/spec/simultaneous_subtitles/dual/srt/out.srt +27 -0
  65. data/spec/simultaneous_subtitles/dual/ssa/expected.ssa +22 -0
  66. data/spec/simultaneous_subtitles/dual/ssa/out.ssa +22 -0
  67. data/spec/simultaneous_subtitles/dual/two.srt +11 -0
  68. data/spec/simultaneous_subtitles/simultaneous_subtitles_spec.rb +220 -0
  69. data/spec/simultaneous_subtitles/triple/ass/expected.ass +25 -0
  70. data/spec/simultaneous_subtitles/triple/ass/out.ass +25 -0
  71. data/spec/simultaneous_subtitles/triple/one.srt +11 -0
  72. data/spec/simultaneous_subtitles/triple/srt/expected.srt +55 -0
  73. data/spec/simultaneous_subtitles/triple/srt/out.srt +55 -0
  74. data/spec/simultaneous_subtitles/triple/ssa/expected.ssa +25 -0
  75. data/spec/simultaneous_subtitles/triple/ssa/out.ssa +25 -0
  76. data/spec/simultaneous_subtitles/triple/three.srt +11 -0
  77. data/spec/simultaneous_subtitles/triple/two.srt +11 -0
  78. data/spec/simultaneous_subtitles/triple_plus/ass/expected.ass +93 -0
  79. data/spec/simultaneous_subtitles/triple_plus/ass/out.ass +93 -0
  80. data/spec/simultaneous_subtitles/triple_plus/five.srt +11 -0
  81. data/spec/simultaneous_subtitles/triple_plus/four.srt +11 -0
  82. data/spec/simultaneous_subtitles/triple_plus/one.srt +11 -0
  83. data/spec/simultaneous_subtitles/triple_plus/six.srt +11 -0
  84. data/spec/simultaneous_subtitles/triple_plus/srt/expected.srt +149 -0
  85. data/spec/simultaneous_subtitles/triple_plus/srt/out.srt +149 -0
  86. data/spec/simultaneous_subtitles/triple_plus/ssa/expected.ssa +93 -0
  87. data/spec/simultaneous_subtitles/triple_plus/ssa/out.ssa +93 -0
  88. data/spec/simultaneous_subtitles/triple_plus/three.srt +11 -0
  89. data/spec/simultaneous_subtitles/triple_plus/two.srt +11 -0
  90. data/spec/spec_helper.rb +7 -0
  91. data/spec/specifications_spec.rb +138 -0
  92. data/spec/srt_spec.rb +134 -0
  93. data/spec/ssa_spec.rb +90 -0
  94. data/spec/timecode_correction/double_reference/expected.srt +13 -0
  95. data/spec/timecode_correction/double_reference/in.srt +12 -0
  96. data/spec/timecode_correction/double_reference/out.srt +13 -0
  97. data/spec/timecode_correction/framerate/expected.srt +5 -0
  98. data/spec/timecode_correction/framerate/in.srt +4 -0
  99. data/spec/timecode_correction/framerate/out.srt +5 -0
  100. data/spec/timecode_correction/framerate_plus_reference/expected.srt +13 -0
  101. data/spec/timecode_correction/framerate_plus_reference/in.srt +12 -0
  102. data/spec/timecode_correction/framerate_plus_reference/out.srt +13 -0
  103. data/spec/timecode_correction/single_reference/expected.srt +13 -0
  104. data/spec/timecode_correction/single_reference/in.srt +12 -0
  105. data/spec/timecode_correction/single_reference/out.srt +13 -0
  106. data/spec/timecode_correction/timecode_correction_spec.rb +124 -0
  107. data/spec/transcoding/gb2312-ascii/in.srt +12 -0
  108. data/spec/transcoding/iso-8859-1_utf-8/expected.srt +12 -0
  109. data/spec/transcoding/iso-8859-1_utf-8/in.srt +11 -0
  110. data/spec/transcoding/iso-8859-1_utf-8/out.srt +12 -0
  111. data/spec/transcoding/transcoding_spec.rb +116 -0
  112. data/spec/transcoding/utf-8_gbk/expected.srt +12 -0
  113. data/spec/transcoding/utf-8_gbk/in.srt +11 -0
  114. data/spec/transcoding/utf-8_gbk/out.srt +12 -0
  115. data/spec/transcoding/windows-1252_utf-8/expected.srt +12 -0
  116. data/spec/transcoding/windows-1252_utf-8/in.srt +11 -0
  117. data/spec/transcoding/windows-1252_utf-8/out.srt +12 -0
  118. data/titlekit.gemspec +28 -0
  119. metadata +313 -0
@@ -0,0 +1,81 @@
1
+ require File.join(File.expand_path(__dir__), '../spec_helper')
2
+
3
+ describe Titlekit::Job do
4
+
5
+ describe 'Encoding detection' do
6
+
7
+ context 'with exhibit A' do
8
+ before(:all) do
9
+ @in = File.join(__dir__, 'a', 'in.ass')
10
+ @out = File.join(__dir__, 'a', 'out.ass')
11
+ @expected = File.join(__dir__, 'a', 'expected.ass')
12
+
13
+ File.delete(@out) if File.exist?(@out)
14
+ end
15
+
16
+ it 'tries its best and takes graceful actions no matter what' do
17
+ job = Titlekit::Job.new
18
+
19
+ have = job.have
20
+ have.file(@in)
21
+
22
+ want = job.want
23
+ want.file(@out)
24
+
25
+ job.run
26
+
27
+ expect(job.report.join).to include('detected')
28
+ end
29
+ end
30
+
31
+ context 'with exhibit B' do
32
+
33
+ before(:all) do
34
+ @in = File.join(__dir__, 'b', 'in.srt')
35
+ @out = File.join(__dir__, 'b', 'out.srt')
36
+ @expected = File.join(__dir__, 'b', 'expected.srt')
37
+
38
+ File.delete(@out) if File.exist?(@out)
39
+ end
40
+
41
+ it 'tries its best and takes graceful actions no matter what' do
42
+ job = Titlekit::Job.new
43
+
44
+ have = job.have
45
+ have.file(@in)
46
+
47
+ want = job.want
48
+ want.file(@out)
49
+
50
+ job.run
51
+
52
+ expect(job.report.join).to include('detected')
53
+ end
54
+ end
55
+
56
+ context 'with exhibit C' do
57
+
58
+ before(:all) do
59
+ @in = File.join(__dir__, 'c', 'in.srt')
60
+ @out = File.join(__dir__, 'c', 'out.srt')
61
+ @expected = File.join(__dir__, 'c', 'expected.srt')
62
+
63
+ File.delete(@out) if File.exist?(@out)
64
+ end
65
+
66
+ it 'tries its best and takes graceful actions no matter what' do
67
+ job = Titlekit::Job.new
68
+
69
+ have = job.have
70
+ have.file(@in)
71
+
72
+ want = job.want
73
+ want.file(@out)
74
+
75
+ job.run
76
+
77
+ expect(job.report.join).to include('detected')
78
+ end
79
+ end
80
+ end
81
+ end
Binary file
@@ -0,0 +1,37 @@
1
+ [Script Info]
2
+ ; Script generated by Aegisub 2.1.8
3
+ ; http://www.aegisub.org/
4
+ Title: Default Aegisub file
5
+ ScriptType: v4.00+
6
+ WrapStyle: 0
7
+ PlayResX: 640
8
+ PlayResY: 480
9
+ ScaledBorderAndShadow: yes
10
+ Video Aspect Ratio: 0
11
+ Video Zoom: 6
12
+ Video Position: 0
13
+ Last Style Storage: Default
14
+
15
+ [V4+ Styles]
16
+ Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
17
+ Style: Default,Arial,25,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,1,2,10,10,10,1
18
+
19
+ [Events]
20
+ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
21
+ Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,This line has some Arabic text to check for basic support.
22
+ Dialogue: 0,0:00:00.00,0:00:02.00,Default,,0000,0000,0000,,هل تعمل اللغة العربية؟
23
+ Comment: 0,0:00:02.00,0:00:02.00,Default,,0000,0000,0000,,These are typeset words with diacritics. They also demonstrate some "ligatures".
24
+ Dialogue: 0,0:00:02.00,0:00:04.00,Default,,0000,0000,0000,,{\pos(323,84)\frz345.949}نَصٌّ
25
+ Dialogue: 0,0:00:02.00,0:00:04.00,Default,,0000,0000,0000,,{\frx28\fry322\fscx251.25\fscy308.75\pos(318,177)}تجريبيّ
26
+ Dialogue: 0,0:00:02.00,0:00:04.00,Default,,0000,0000,0000,,{\frz25.57\fscx368.75\fscy352.5\pos(346,305)}عَرَبيّ
27
+ Dialogue: 0,0:00:02.00,0:00:04.00,Default,,0000,0000,0000,,{\pos(319,430)\fscx260\fscy258.75\clip(305,327,353,460)}مقطوع
28
+ Comment: 0,0:00:04.00,0:00:04.00,Default,,0000,0000,0000,,This line test a common bug. Using tags on a word in an RTL line usually messes up its order.
29
+ Dialogue: 0,0:00:04.00,0:00:06.00,Default,,0000,0000,0000,,{\frz328.582\fscx357.5\fscy445\frx58\fry6\pos(292,250)}{\1c&H0000FF&}هذا {\1c&H00FF00&}نص {\1c&HFF0000&}ملون
30
+ Comment: 0,0:00:06.00,0:00:06.00,Default,,0000,0000,0000,,Numbers in a RTL line. They should be displayed as 1432 and 2011.
31
+ Dialogue: 0,0:00:06.00,0:00:08.00,Default,,0000,0000,0000,,كُتب هذا الملف عام 1432 هـ الموافق 2011 م
32
+ Comment: 0,0:00:08.00,0:00:08.00,Default,,0000,0000,0000,,Another common problem: punctuations at the beginning or the end of a line are sometimes rendered at the wrong end of the line.
33
+ Dialogue: 0,0:00:08.00,0:00:10.00,Default,,0000,0000,0000,,- علامات الترقيم تعمل!
34
+ Comment: 0,0:00:10.00,0:00:10.00,Default,,0000,0000,0000,,A LTR word in a punctuated RTL context and vice-versa.
35
+ Dialogue: 0,0:00:10.00,0:00:12.00,Default,,0000,0000,0000,,- اللغة الرسمية في Germany هي الألمانية.\N- The official language in مصر is Arabic.
36
+ Comment: 0,0:00:12.00,0:00:12.00,Default,,0000,0000,0000,,Bidi karaoke has never worked before. Say hello to kickass-libass!!
37
+ Dialogue: 0,0:00:12.00,0:00:18.00,Default,,0000,0000,0000,,{\k59}كا{\k58}ر{\k54}يو{\k59}كي {\k63}La{\k55}tin {\k52}و{\k58}ع{\k54}ر{\k53}بي!
@@ -0,0 +1,28 @@
1
+ [Script Info]
2
+ ; This is an Advanced Sub Station Alpha v4+ script.
3
+ ; For Sub Station Alpha info and downloads,
4
+ ; go to http://www.eswat.demon.co.uk/
5
+ ; or email kotus@eswat.demon.co.uk
6
+ ;
7
+ ; Advanced Sub Station Alpha script format developed by #Anime-Fansubs@EfNET
8
+ ; http://www.anime-fansubs.org
9
+ ;
10
+ ; For additional info and downloads go to http://vobsub.edensrising.com/
11
+ ; or email gabest@freemail.hu
12
+ ;
13
+ ; Note: This file was saved by Subresync.
14
+ ;
15
+ ScriptType: v4.00+
16
+ Collisions: Normal
17
+ PlayResX: 384
18
+ PlayResY: 288
19
+ Timer: 100.0000
20
+
21
+ [V4+ Styles]
22
+ Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
23
+ Style: Default,Tahoma,16,&H00000000,&H00ffffff,&H00ffffff,&H00c0c0c0,-1,0,0,0,100,100,0,0.00,1,2,3,2,20,20,20,1
24
+
25
+ [Events]
26
+ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
27
+ Dialogue: 0,0:01:41.70,0:01:46.84,Default,,0000,0000,0000,,Le rugissement des larmes !\NTu es mon ami.
28
+ Dialogue: 0,0:02:00.99,0:02:02.87,Default,,0000,0000,0000,,Est-ce vraiment Naruto ?