nofxx-subtitle_it 0.6.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.
Files changed (50) hide show
  1. data/.autotest +19 -0
  2. data/History.txt +30 -0
  3. data/License.txt +20 -0
  4. data/Manifest.txt +49 -0
  5. data/README.markdown +41 -0
  6. data/README.txt +84 -0
  7. data/Rakefile +4 -0
  8. data/bin/subtitle_it +115 -0
  9. data/config/hoe.rb +73 -0
  10. data/config/requirements.rb +15 -0
  11. data/lib/subtitle_it.rb +46 -0
  12. data/lib/subtitle_it/formats/ass.rb +14 -0
  13. data/lib/subtitle_it/formats/rsb.rb +33 -0
  14. data/lib/subtitle_it/formats/srt.rb +34 -0
  15. data/lib/subtitle_it/formats/sub.rb +31 -0
  16. data/lib/subtitle_it/formats/xml.rb +64 -0
  17. data/lib/subtitle_it/formats/yml.rb +20 -0
  18. data/lib/subtitle_it/subline.rb +25 -0
  19. data/lib/subtitle_it/subtime.rb +58 -0
  20. data/lib/subtitle_it/subtitle.rb +32 -0
  21. data/lib/subtitle_it/version.rb +9 -0
  22. data/script/console +10 -0
  23. data/script/destroy +14 -0
  24. data/script/generate +14 -0
  25. data/script/txt2html +82 -0
  26. data/setup.rb +1585 -0
  27. data/spec/fixtures/godfather.srt +2487 -0
  28. data/spec/fixtures/huge.ass +22 -0
  29. data/spec/fixtures/movie.xml +28 -0
  30. data/spec/fixtures/movie.yml +163 -0
  31. data/spec/fixtures/pseudo.rsb +6 -0
  32. data/spec/fixtures/pulpfiction.sub +2025 -0
  33. data/spec/fixtures/sincity.yml +12 -0
  34. data/spec/spec.opts +1 -0
  35. data/spec/spec_helper.rb +33 -0
  36. data/spec/subtitle_it/formats/ass_spec.rb +5 -0
  37. data/spec/subtitle_it/formats/rsb_spec.rb +42 -0
  38. data/spec/subtitle_it/formats/srt_spec.rb +42 -0
  39. data/spec/subtitle_it/formats/sub_spec.rb +46 -0
  40. data/spec/subtitle_it/formats/xml_spec.rb +46 -0
  41. data/spec/subtitle_it/formats/yml_spec.rb +20 -0
  42. data/spec/subtitle_it/subline_spec.rb +30 -0
  43. data/spec/subtitle_it/subtime_spec.rb +76 -0
  44. data/spec/subtitle_it/subtitle_spec.rb +1 -0
  45. data/spec/subtitle_it_spec.rb +11 -0
  46. data/subtitle_it.gemspec +41 -0
  47. data/tasks/deployment.rake +34 -0
  48. data/tasks/environment.rake +7 -0
  49. data/tasks/rspec.rake +21 -0
  50. metadata +128 -0
@@ -0,0 +1,19 @@
1
+ # #
2
+ # SMS AUTOTEST
3
+ #
4
+ #require 'autotest/growl'
5
+ #require 'autotest/html_report'
6
+ # require 'autotest/kdenotify'
7
+ require 'autotest/menu'
8
+ #require 'autotest/pretty'
9
+ require 'autotest/redgreen'
10
+ # require 'autotest/snarl'
11
+ require 'autotest/timestamp'
12
+
13
+
14
+ class Autotest
15
+ Autotest.add_hook :initialize do |at|
16
+ %w{.svn .hg .git .DS_store}.each {|exception|at.add_exception(exception)}
17
+ end
18
+ end
19
+
@@ -0,0 +1,30 @@
1
+ == 0.1.0 2008-09-04
2
+
3
+ * 1 major enhancement:
4
+ * Support yml
5
+
6
+ == 0.2.0 2008-09-07
7
+
8
+ * 1 major enhancement:
9
+ * Support sub
10
+
11
+ == 0.3.0 2008-09-07
12
+
13
+ * 2 major enhancement:
14
+ * Support srt
15
+ * subtitle_it tool
16
+
17
+ == 0.4.0 2008-09-07
18
+
19
+ * 1 major enhancement:
20
+ * Adds yml generator
21
+
22
+ == 0.5.1 2008-09-08
23
+
24
+ * 1 major enhancement:
25
+ * Adds rsb support
26
+
27
+ == 0.6.1 2008-09-09
28
+
29
+ * 1 major enhancement:
30
+ * Adds xml tt support
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Marcos Piccinini, Warlley Rezende, Marcin (tiraeth) Chwedziak
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ .autotest
2
+ History.txt
3
+ License.txt
4
+ Manifest.txt
5
+ README.markdown
6
+ README.txt
7
+ Rakefile
8
+ bin/subtitle_it
9
+ config/hoe.rb
10
+ config/requirements.rb
11
+ lib/subtitle_it.rb
12
+ lib/subtitle_it/formats/ass.rb
13
+ lib/subtitle_it/formats/rsb.rb
14
+ lib/subtitle_it/formats/srt.rb
15
+ lib/subtitle_it/formats/sub.rb
16
+ lib/subtitle_it/formats/xml.rb
17
+ lib/subtitle_it/formats/yml.rb
18
+ lib/subtitle_it/subline.rb
19
+ lib/subtitle_it/subtime.rb
20
+ lib/subtitle_it/subtitle.rb
21
+ lib/subtitle_it/version.rb
22
+ script/console
23
+ script/destroy
24
+ script/generate
25
+ script/txt2html
26
+ setup.rb
27
+ spec/fixtures/godfather.srt
28
+ spec/fixtures/huge.ass
29
+ spec/fixtures/movie.xml
30
+ spec/fixtures/movie.yml
31
+ spec/fixtures/pseudo.rsb
32
+ spec/fixtures/pulpfiction.sub
33
+ spec/fixtures/sincity.yml
34
+ spec/spec.opts
35
+ spec/spec_helper.rb
36
+ spec/subtitle_it/formats/ass_spec.rb
37
+ spec/subtitle_it/formats/rsb_spec.rb
38
+ spec/subtitle_it/formats/srt_spec.rb
39
+ spec/subtitle_it/formats/sub_spec.rb
40
+ spec/subtitle_it/formats/xml_spec.rb
41
+ spec/subtitle_it/formats/yml_spec.rb
42
+ spec/subtitle_it/subline_spec.rb
43
+ spec/subtitle_it/subtime_spec.rb
44
+ spec/subtitle_it/subtitle_spec.rb
45
+ spec/subtitle_it_spec.rb
46
+ subtitle_it.gemspec
47
+ tasks/deployment.rake
48
+ tasks/environment.rake
49
+ tasks/rspec.rake
@@ -0,0 +1,41 @@
1
+ h1. Subtitle It
2
+
3
+ Ruby tool to work with subtitle files.
4
+
5
+ h1. FEATURES:
6
+
7
+ * Converts to and from: yml/srt/sub/rsb nice subtitle code
8
+ * Fixes delays. (SrtResync)
9
+
10
+ h2. TODO:
11
+
12
+ * Compatibility with "sube" (http://github.com/vic/sube)
13
+ * Download subtitles. (http://github.com/johanlunds/downsub/tree)
14
+
15
+ h1. SYNOPSIS:
16
+
17
+ Bash tool:
18
+
19
+ Convert a srt to sub:
20
+ subtitle_it in.srt out.sub
21
+
22
+ Add a delay of 1 minute:
23
+ subtitle_it -d 60 in.srt
24
+
25
+ Create a template
26
+ subtitle_it unexistent.file
27
+
28
+
29
+ h1. INSTALL:
30
+
31
+ sudo gem install SubtitleIt
32
+
33
+
34
+ h1. THE "Ruby Subtitle" Format - RSB
35
+
36
+ It`s just a easy way, proof of concept to edit subtitles. Here is what it looks like:
37
+
38
+ 00:32 => 00:33 == Nice police work! | Thank you!
39
+ MM:SS => N == TEXT | NEWLINE
40
+
41
+ Create a template to check it out.
@@ -0,0 +1,84 @@
1
+ = Subtitle It
2
+
3
+ Ruby tool to work with subtitle files.
4
+
5
+
6
+ == FEATURES:
7
+
8
+ * Converts to and from: SRT, SUB, XML(TT), YML, RSB and ASS
9
+ * Fixes delays. (SrtResync)
10
+
11
+ TODO:
12
+
13
+ * Compatibility with "sube" (http://github.com/vic/sube)
14
+ * Download subtitles. (http://github.com/johanlunds/downsub/tree)
15
+ * Download from http://trac.opensubtitles.org/projects/opensubtitles/wiki/XMLRPC
16
+ * Fix delays
17
+ * Convert 1 to 2 CD`s and versa-vice
18
+ * ASS Format (Yes, for the funny of it...)
19
+
20
+
21
+ == REQUIREMENTS:
22
+
23
+ * hpricot
24
+
25
+
26
+ == SYNOPSIS:
27
+
28
+ Bash tool:
29
+
30
+ Convert a srt to sub:
31
+ subtitle_it in.srt out.sub
32
+
33
+ Add a delay of 1 minute:
34
+ subtitle_it -d 60 in.srt
35
+
36
+ Create a template
37
+ subtitle_it unexistent.file
38
+
39
+
40
+ == INSTALL:
41
+
42
+ sudo gem install SubtitleIt
43
+
44
+
45
+ == THE "Ruby Subtitle" Format - RSB
46
+
47
+ It`s just a easy way, proof of concept to edit subtitles. Here is what it looks like:
48
+
49
+ 00:32 => 00:33 == Nice police work! | Thank you!
50
+ MM:SS => N == TEXT | NEWLINE
51
+
52
+ Create a template to check it out.
53
+
54
+
55
+ == OTHER TOOLS:
56
+
57
+ Aegisub: http://www.malakith.net/aegiwiki/Main_Page
58
+
59
+
60
+ == LICENSE:
61
+
62
+ (The MIT License)
63
+
64
+ Copyright (c) 2008 Warlley Rezende, Marcos Piccinini
65
+ Parts of subrip code by Marcin (tiraeth) Chwedziak
66
+
67
+ Permission is hereby granted, free of charge, to any person obtaining
68
+ a copy of this software and associated documentation files (the
69
+ 'Software'), to deal in the Software without restriction, including
70
+ without limitation the rights to use, copy, modify, merge, publish,
71
+ distribute, sublicense, and/or sell copies of the Software, and to
72
+ permit persons to whom the Software is furnished to do so, subject to
73
+ the following conditions:
74
+
75
+ The above copyright notice and this permission notice shall be
76
+ included in all copies or substantial portions of the Software.
77
+
78
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
79
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
80
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
81
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
82
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
83
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
84
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created on 2008-9-4.
4
+ # Copyright (c) 2008. All rights reserved.
5
+
6
+ begin
7
+ require 'rubygems'
8
+ rescue LoadError
9
+ # no rubygems to load, so we fail silently
10
+ end
11
+
12
+ require 'optparse'
13
+ require 'subtitle_it'
14
+
15
+ include SubtitleIt
16
+ # NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
17
+
18
+ OPTIONS = {
19
+ # :path => '~',
20
+ :format => nil,
21
+ :delay => nil
22
+ }
23
+ MANDATORY_OPTIONS = %w( )
24
+
25
+ parser = OptionParser.new do |opts|
26
+ opts.banner = <<BANNER
27
+ SubtitleIt - Convert and create subtitles.
28
+
29
+ Usage: #{File.basename($0)} [options] file_in [file_out]
30
+
31
+ Options are:
32
+ -c FORMAT --convert=FORMAT Format to convert to: yml, srt or sub.
33
+
34
+ -d DELAY --delay=DELAY Fix the delay of the file.
35
+
36
+ BANNER
37
+ opts.separator ""
38
+ # opts.on("-p", "--path=PATH", String,
39
+ # "The root path for selecting files",
40
+ # "Default: ~") { |OPTIONS[:path]| }
41
+
42
+ opts.on("-c", "--convert=FORMAT", String,
43
+ "Format to convert to") { |OPTIONS[:format]| }
44
+
45
+ opts.on("-d", "--delay=DELAY", Float,
46
+ "Delay to add/remove") { |OPTIONS[:delay]| }
47
+
48
+ opts.on("-h", "--help",
49
+ "Show this help message.") { puts opts; exit }
50
+
51
+ opts.on("-v", "--version",
52
+ "Show program version") { OPTIONS[:version] = true }
53
+
54
+ opts.parse!(ARGV)
55
+
56
+ if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
57
+ puts opts; exit
58
+ end
59
+ end
60
+ t = Time.now
61
+ if OPTIONS[:version]
62
+ include SubtitleIt
63
+ puts a
64
+ exit
65
+ end
66
+
67
+ if ARGV.empty?
68
+ puts parser.banner
69
+ exit
70
+ end
71
+
72
+ filein, filein_ext = ARGV[0].split('.')
73
+ fileout, fileout_ext = ARGV[1] ? ARGV[1].split('.') : [filein, filein_ext]
74
+
75
+ if File.exists?(ARGV[0])
76
+ content = File.open(ARGV[0], 'r')
77
+ if OPTIONS[:delay]
78
+ ARGV[1] ||= ARGV[0] + "_new"
79
+ SubtitleIt.srt_delay(ARGV[0],ARGV[1])
80
+ else
81
+ include SubtitleIt
82
+ puts "Working on file #{filein}..."
83
+ sub = Subtitle.new(content, filein_ext)
84
+ format = OPTIONS[:format]
85
+ format ||= fileout_ext unless fileout_ext == filein_ext
86
+ out = case format
87
+ when 'yml' then sub.to_yml
88
+ when 'sub' then sub.to_sub
89
+ when 'srt' then sub.to_srt
90
+ else
91
+ puts "Dunno what to do with this file!"
92
+ exit
93
+ end
94
+ end
95
+ else
96
+ out = <<GEN
97
+ header:
98
+ title: #{ARGV[0]}
99
+ authors: FIXME
100
+ version: FIXME
101
+
102
+ lines:
103
+ - ['00:05:26.5', '2', 'worth killing for...']
104
+ GEN
105
+ OPTIONS[:format] = 'rsb'
106
+ end
107
+
108
+ fout = "#{fileout}.#{OPTIONS[:format]}"
109
+
110
+ if File.writable?(fout)
111
+ File.open(fout, 'w') {|f| f.write(out) }
112
+ puts "Done. Total time: #{Time.now - t}"
113
+ else
114
+ puts "Can`t write to #{fout}"
115
+ end
@@ -0,0 +1,73 @@
1
+ require 'subtitle_it/version'
2
+
3
+ AUTHOR = 'FIXME full name' # can also be an array of Authors
4
+ EMAIL = "FIXME email"
5
+ DESCRIPTION = "description of gem"
6
+ GEM_NAME = 'subtitle_it' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'subtitle_it' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ # ['activesupport', '>= 1.3.1']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "unknown"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = SubtitleIt::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'subtitle_it documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README",
42
+ "--inline-source"]
43
+
44
+ class Hoe
45
+ def extra_deps
46
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
+ @extra_deps
48
+ end
49
+ end
50
+
51
+ # Generate all the Rake tasks
52
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
+ p.developer(AUTHOR, EMAIL)
55
+ p.description = DESCRIPTION
56
+ p.summary = DESCRIPTION
57
+ p.url = HOMEPATH
58
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
+ p.test_globs = ["test/**/test_*.rb"]
60
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
+
62
+ # == Optional
63
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
+ #p.extra_deps = EXTRA_DEPENDENCIES
65
+
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+ end
68
+
69
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
+ $hoe.rsync_args = '-av --delete --ignore-errors'
73
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))