musical 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/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "trollop", ">=1.16.2"
4
+ gem "progressbar", ">=0.9.1"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.3.0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 ryo katsuma
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.
data/README.rdoc ADDED
@@ -0,0 +1,58 @@
1
+ = musical
2
+
3
+ Musical is a simple tool for your DVD.
4
+ It enables you to rip and convert it to wav data by chapter.
5
+
6
+
7
+ == Install
8
+
9
+ 1 Install dvdbackup and ffmpeg. For example,
10
+ brew install dvdbackup
11
+ brew install ffmpeg
12
+
13
+ 2 Install gem
14
+ gem install musical
15
+
16
+
17
+ == Usage
18
+ Set you DVD and type
19
+ musical <options>
20
+
21
+ Options:
22
+ --info, -i: Show your DVD data
23
+ --ignore-convert-sound, -g: Rip data only, NOT convert them to wav file
24
+ --dev, -d <s>: Set location of DVD device
25
+ --title, -t <s>: Set DVD title (default: LIVE)
26
+ --output, -o <s>: Set location of ripped data (default: ripped)
27
+ --version, -v: Print version and exit
28
+ --help, -h: Show this message
29
+
30
+
31
+ == FAQ
32
+
33
+ === On Mac OS X 10.7.x, I cannot install ffmpeg.
34
+
35
+ The latest Xcode doesn't include gcc. Install gcc-4.2[https://github.com/kennethreitz/osx-gcc-installer].
36
+
37
+ And try this.
38
+ brew install --use-clang --HEAD --use-gcc ffmpeg
39
+
40
+
41
+ === I got an error, /bin/sh: /usr/bin/pod2man: Permission denied
42
+
43
+ /usr/bin/pod2man may not have execute permission.
44
+
45
+ Try this.
46
+ sudo chmod +x /usr/bin/pod2man
47
+
48
+
49
+ === I got nothing 'musical --info'
50
+
51
+ Your DVD may be copy-protected. Try fairmount[http://www.metakine.com/products/fairmount/].
52
+
53
+
54
+ == Copyright
55
+
56
+ Copyright (c) 2011 ryo katsuma. See LICENSE.txt for
57
+ further details.
58
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "musical"
18
+ gem.homepage = "http://github.com/katsuma/musical"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A simple rip and convert tool for your DVD}
21
+ gem.description = %Q{Musical is a simple rip and convert tool for your DVD. It enables you to rip and convert it to wav data by chapter.}
22
+ gem.email = "katsuma@gmail.com"
23
+ gem.authors = ["ryo katsuma"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "musical #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/musical ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'musical'
4
+
5
+ include Musical
6
+
7
+ DVD.new
data/lib/musical.rb ADDED
@@ -0,0 +1,136 @@
1
+ require 'rubygems'
2
+ require 'trollop'
3
+ require 'progressbar'
4
+ require 'fileutils'
5
+
6
+ module Musical
7
+ class DVD
8
+ attr_accessor :opts
9
+
10
+ def self.detect
11
+ dev_infos = `df -h | awk {'print $1,$5,$6'}`.split("\n")
12
+ candidates = []
13
+ dev_infos.each do |dev_info|
14
+ info = dev_info.split(" ")
15
+ file_system = info[0]
16
+ capacity = info[1]
17
+ mounted = info[2]
18
+ if capacity == "100%" && mounted.include?("/Volumes")
19
+ candidates << mounted
20
+ end
21
+ end
22
+
23
+ raise "Not detect DVD device" if candidates.empty?
24
+ candidates
25
+ end
26
+
27
+ def initialize
28
+ @opts = Trollop::options do
29
+ version 'Musical 0.0.1'
30
+ opt :info, "Show your DVD data", :type => :boolean
31
+ opt :ignore_convert_sound, "Rip data only, NOT convert them to wav file", :type => :boolean
32
+ opt :dev, "Set location of DVD device"
33
+ opt :title, "Set DVD title", :default => 'LIVE'
34
+ opt :output, "Set location of ripped data", :default => 'ripped'
35
+ end
36
+ run
37
+ end
38
+
39
+ def run
40
+ check_env
41
+ return puts info if @opts[:info]
42
+ rip_by_chapter
43
+ convert_sound unless @opts[:ignore_convert_sound]
44
+ end
45
+
46
+ def dev
47
+ @_dev ||= DVD.detect.first
48
+ end
49
+
50
+ def info
51
+ raise "Not detect DVD device" if dev.empty?
52
+ @_info ||= `dvdbackup --input=#{dev} --info 2>/dev/null`
53
+ end
54
+
55
+ def title_with_chapters
56
+ return @_title_chapters unless @_title_chapters.nil?
57
+
58
+ @_title_chapters = []
59
+ info_str = info.split("\n")
60
+ info_str.each_with_index do |line, index|
61
+ if line =~ /\s*Title (\d):$/
62
+ @_title_chapters << { :title => $1.to_i, :line => index }
63
+ end
64
+ end
65
+
66
+ @_title_chapters.each do |title_chapter|
67
+ line = title_chapter[:line]
68
+ if info_str[line + 1] =~ /\s*Title (\d) has (\d*) chapter/
69
+ title_chapter[:chapter] = $2.to_i
70
+ title_chapter.delete(:line)
71
+ end
72
+ end
73
+ @_title_chapters
74
+ end
75
+
76
+ def rip_by_chapter
77
+ task_message "Ripping"
78
+
79
+ pbar = ProgressBar.new "Ripping", chapter_size
80
+ title_with_chapters.each_with_index do |title_chapter, title_index|
81
+ ripped_dir_base = "#{@opts[:output]}"
82
+ saved_dir = "#{ripped_dir_base}/#{@opts[:title]}/title_#{title_index+1}"
83
+ FileUtils.mkdir_p "#{saved_dir}"
84
+
85
+ 1.upto title_chapter[:chapter] do |chapter|
86
+ `dvdbackup --name=#{@opts[:title]} --input=#{dev} --title=#{title_index+1} --start=#{chapter} --end=#{chapter} --output=#{ripped_dir_base}_#{title_index}_#{chapter} 2>/dev/null`
87
+ pbar.inc
88
+
89
+ # moved file
90
+ vob_path = `find #{ripped_dir_base}_#{title_index}_#{chapter} -name "*.VOB"`.chomp
91
+ FileUtils.mv vob_path, "#{saved_dir}/chapter_#{chapter}.VOB"
92
+ FileUtils.rm_rf "#{ripped_dir_base}_#{title_index}_#{chapter}"
93
+ end
94
+ end
95
+ pbar.finish
96
+ end
97
+
98
+ def convert_sound
99
+ task_message "Converting"
100
+
101
+ pbar = ProgressBar.new "Converting", chapter_size
102
+ title_with_chapters.each_with_index do |title_chapter, title_index|
103
+ ripped_dir_base = "#{@opts[:output]}"
104
+ saved_dir = "#{ripped_dir_base}/#{@opts[:title]}/title_#{title_index+1}"
105
+
106
+ 1.upto title_chapter[:chapter] do |chapter|
107
+ `ffmpeg -i #{saved_dir}/chapter_#{chapter}.VOB #{saved_dir}/chapter_#{chapter}.wav 2>/dev/null`
108
+ FileUtils.rm_f "#{saved_dir}/chapter_#{chapter}.VOB"
109
+ pbar.inc
110
+ end
111
+ end
112
+ pbar.finish
113
+ end
114
+
115
+ def task_message(task)
116
+ raise "Not found any titles and chapters" if title_with_chapters.size == 0 && chapter_size == 0
117
+ puts "#{task} #{title_with_chapters.size} titles, #{chapter_size} chapters to #{@opts[:output]} directory"
118
+ end
119
+ private :task_message
120
+
121
+ def chapter_size
122
+ @_chapter_size ||= title_with_chapters.inject(0){ |count, t| count + t[:chapter]}
123
+ end
124
+ private :chapter_size
125
+
126
+ def check_env
127
+ ['dvdbackup', 'ffmpeg'].each do |app|
128
+ if `which #{app}`.empty?
129
+ raise RuntimeError, "\n\n'#{app}' is not installed.\n\ntry:\n brew install #{app}\n\n"
130
+ end
131
+ end
132
+ end
133
+ private :check_env
134
+
135
+ end
136
+ end
data/musical.gemspec ADDED
@@ -0,0 +1,68 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{musical}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["ryo katsuma"]
12
+ s.date = %q{2011-11-06}
13
+ s.default_executable = %q{musical}
14
+ s.description = %q{Musical is a simple rip and convert tool for your DVD. It enables you to rip and convert it to wav data by chapter.}
15
+ s.email = %q{katsuma@gmail.com}
16
+ s.executables = ["musical"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/musical",
30
+ "lib/musical.rb",
31
+ "musical.gemspec",
32
+ "spec/musical_spec.rb",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/katsuma/musical}
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.6.2}
39
+ s.summary = %q{A simple rip and convert tool for your DVD}
40
+
41
+ if s.respond_to? :specification_version then
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<trollop>, [">= 1.16.2"])
46
+ s.add_runtime_dependency(%q<progressbar>, [">= 0.9.1"])
47
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
50
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<trollop>, [">= 1.16.2"])
53
+ s.add_dependency(%q<progressbar>, [">= 0.9.1"])
54
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
55
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
57
+ s.add_dependency(%q<rcov>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<trollop>, [">= 1.16.2"])
61
+ s.add_dependency(%q<progressbar>, [">= 0.9.1"])
62
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
65
+ s.add_dependency(%q<rcov>, [">= 0"])
66
+ end
67
+ end
68
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Musical" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'musical'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: musical
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - ryo katsuma
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-11-06 00:00:00 +09:00
14
+ default_executable: musical
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: trollop
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.16.2
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: progressbar
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.9.1
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.3.0
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: bundler
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.0.0
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: jeweler
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 1.6.4
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: rcov
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ description: Musical is a simple rip and convert tool for your DVD. It enables you to rip and convert it to wav data by chapter.
83
+ email: katsuma@gmail.com
84
+ executables:
85
+ - musical
86
+ extensions: []
87
+
88
+ extra_rdoc_files:
89
+ - LICENSE.txt
90
+ - README.rdoc
91
+ files:
92
+ - .document
93
+ - .rspec
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.rdoc
97
+ - Rakefile
98
+ - VERSION
99
+ - bin/musical
100
+ - lib/musical.rb
101
+ - musical.gemspec
102
+ - spec/musical_spec.rb
103
+ - spec/spec_helper.rb
104
+ has_rdoc: true
105
+ homepage: http://github.com/katsuma/musical
106
+ licenses:
107
+ - MIT
108
+ post_install_message:
109
+ rdoc_options: []
110
+
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 785758502750108159
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: "0"
128
+ requirements: []
129
+
130
+ rubyforge_project:
131
+ rubygems_version: 1.6.2
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: A simple rip and convert tool for your DVD
135
+ test_files: []
136
+