dvd_ripper 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.rubocop.yml +19 -0
- data/.rubocop_todo.yml +24 -0
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/dvd_ripper.gemspec +21 -15
- data/exe/dvd_ripper +7 -10
- data/lib/dvd_ripper.rb +1 -1
- data/lib/dvd_ripper/client.rb +37 -38
- data/lib/dvd_ripper/config.rb +14 -14
- data/lib/dvd_ripper/dvd.rb +26 -29
- data/lib/dvd_ripper/movie.rb +10 -10
- data/lib/dvd_ripper/movie_extensions.rb +3 -3
- data/lib/dvd_ripper/movie_stub.rb +1 -1
- data/lib/dvd_ripper/search.rb +16 -11
- data/lib/dvd_ripper/search_factory.rb +1 -1
- data/lib/dvd_ripper/search_imdb.rb +4 -2
- data/lib/dvd_ripper/search_tmdb.rb +4 -2
- data/lib/dvd_ripper/version.rb +1 -1
- metadata +28 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c409b5f455b51d73437180114360b882aa70411
|
4
|
+
data.tar.gz: 1caa53faa741cf11327b18c123493699b8b94350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78c6902030545ef5b10eef57b662ef49946eeb92a081fb41759d74047c31704442133034a3cb3f5b7ba35ce504563d47f7118cb31ca48c5705d88ee22008b395
|
7
|
+
data.tar.gz: cb2735eba9ba4c31d83144a83989d2928052f603f387866e11d67fbcf3eed1c7ca6b522a55a115e69ae5576dc739cf78cb2ef024a7ea037dd7b3f6dc4388f1af
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
|
6
|
+
Lint/AssignmentInCondition:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Metrics/BlockNesting:
|
10
|
+
Max: 4
|
11
|
+
|
12
|
+
Metrics/ClassLength:
|
13
|
+
Max: 120
|
14
|
+
|
15
|
+
Metrics/LineLength:
|
16
|
+
Max: 120
|
17
|
+
|
18
|
+
Style/Documentation:
|
19
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2015-11-07 10:15:11 -0700 using RuboCop version 0.35.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 5
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 67
|
12
|
+
|
13
|
+
# Offense count: 3
|
14
|
+
Metrics/CyclomaticComplexity:
|
15
|
+
Max: 17
|
16
|
+
|
17
|
+
# Offense count: 5
|
18
|
+
# Configuration parameters: CountComments.
|
19
|
+
Metrics/MethodLength:
|
20
|
+
Max: 66
|
21
|
+
|
22
|
+
# Offense count: 2
|
23
|
+
Metrics/PerceivedComplexity:
|
24
|
+
Max: 18
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'dvd_ripper'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "dvd_ripper"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/dvd_ripper.gemspec
CHANGED
@@ -4,30 +4,36 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'dvd_ripper/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'dvd_ripper'
|
8
8
|
spec.version = DvdRipper::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['matthew-nichols']
|
10
|
+
spec.email = ['matt@nichols.link']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
|
15
|
-
|
12
|
+
spec.summary = 'Quickly rip and tag DVDs'
|
13
|
+
spec.description = <<-DESCRIPTION
|
14
|
+
A command-line utility that makes it easy to rip and tag DVDs.
|
15
|
+
Just install and run the utility. Then insert a DVD and follow prompts.
|
16
|
+
|
17
|
+
Repeat.
|
18
|
+
DESCRIPTION
|
19
|
+
spec.homepage = 'https://github.com/mattnichols/dvd_ripper'
|
20
|
+
spec.license = 'MIT'
|
16
21
|
|
17
22
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
19
|
-
spec.executables = [
|
20
|
-
spec.require_paths = [
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = ['dvd_ripper']
|
25
|
+
spec.require_paths = ['lib']
|
21
26
|
|
22
|
-
spec.add_runtime_dependency 'thor'
|
27
|
+
spec.add_runtime_dependency 'thor', '~> 0'
|
23
28
|
spec.add_runtime_dependency 'nokogiri', '~> 1.6.0'
|
24
29
|
spec.add_runtime_dependency 'themoviedb', '~> 0.0.20'
|
25
30
|
spec.add_runtime_dependency 'imdb', '~> 0.8.1'
|
26
31
|
spec.add_runtime_dependency 'rb-fsevent', '~> 0.9.4'
|
27
32
|
spec.add_runtime_dependency 'levenshtein', '~> 0.2.2'
|
28
|
-
spec.add_runtime_dependency 'atomic-parsley-ruby'
|
33
|
+
spec.add_runtime_dependency 'atomic-parsley-ruby', '~> 0.0.5' # , :git => 'https://github.com/cparratto/atomic-parsley-ruby.git'
|
29
34
|
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
36
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
37
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
38
|
+
spec.add_development_dependency 'rubocop', '~> 0.35'
|
33
39
|
end
|
data/exe/dvd_ripper
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'dvd_ripper'
|
4
|
-
require
|
4
|
+
require 'thor'
|
5
5
|
|
6
6
|
module DvdRipper
|
7
7
|
class Cli < ::Thor
|
8
|
-
desc
|
8
|
+
desc 'start', 'start tool'
|
9
9
|
def start
|
10
10
|
check_config!
|
11
11
|
dvd_ripper = ::DvdRipper::Client.new
|
12
12
|
dvd_ripper.start
|
13
13
|
end
|
14
|
-
map %w
|
14
|
+
map %w(--version -v) => :__print_version
|
15
15
|
|
16
|
-
desc
|
16
|
+
desc '--version, -v', 'print the version'
|
17
17
|
def __print_version
|
18
18
|
puts "DvdRipper v#{::DvdRipper::VERSION}"
|
19
19
|
end
|
20
20
|
|
21
|
-
desc
|
21
|
+
desc 'config', 'configure dvd_ripper'
|
22
22
|
def config
|
23
23
|
Config.instance.prompt!
|
24
24
|
end
|
25
25
|
|
26
|
-
desc
|
26
|
+
desc 'help', 'display this help'
|
27
27
|
def help_banner
|
28
28
|
puts <<-BANNER
|
29
29
|
Dvd Ripper
|
@@ -40,14 +40,11 @@ module DvdRipper
|
|
40
40
|
|
41
41
|
no_commands do
|
42
42
|
def check_config!
|
43
|
-
unless Config.instance.exists?
|
44
|
-
config
|
45
|
-
end
|
43
|
+
config unless Config.instance.exists?
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
49
47
|
# "www.themoviedb.org"
|
50
|
-
|
51
48
|
end
|
52
49
|
end
|
53
50
|
|
data/lib/dvd_ripper.rb
CHANGED
data/lib/dvd_ripper/client.rb
CHANGED
@@ -1,44 +1,46 @@
|
|
1
1
|
module DvdRipper
|
2
2
|
class Client
|
3
|
+
class DvdDetected < StandardError
|
4
|
+
end
|
5
|
+
|
3
6
|
def initialize
|
4
7
|
@command = nil
|
5
8
|
@title = nil
|
6
|
-
@last_volume =
|
9
|
+
@last_volume = ''
|
7
10
|
@dvd = Dvd.new
|
11
|
+
@config = ::DvdRipper::Config.instance
|
8
12
|
end
|
9
13
|
|
10
14
|
def process_dvd
|
11
15
|
puts
|
12
|
-
puts
|
16
|
+
puts '--------------------------------------------------------------'
|
13
17
|
puts "-- Volume: #{@dvd.volume}"
|
14
18
|
puts "-- Title: #{@dvd.title}"
|
15
|
-
puts
|
19
|
+
puts '--------------------------------------------------------------'
|
16
20
|
puts
|
17
21
|
|
18
22
|
searcher = Search.new
|
19
23
|
movie = searcher.closest(@title || @dvd.title)
|
20
24
|
if movie.nil?
|
21
|
-
puts
|
22
|
-
puts
|
25
|
+
puts '- Provide details for movie -'
|
26
|
+
puts 'Enter Movie Title:'
|
23
27
|
movie = ::Movie.new
|
24
28
|
movie.title = $stdin.gets
|
25
|
-
puts
|
29
|
+
puts 'Enter Movie Year:'
|
26
30
|
movie.release_date = "#{$stdin.gets.chomp}-01-01"
|
27
31
|
end
|
28
32
|
title = "#{movie.title} (#{movie.year})"
|
29
|
-
output = File.join(
|
33
|
+
output = File.join(@config.working_dir, "#{title.gsub(': ', ' - ').gsub(':', ' - ')}.m4v")
|
30
34
|
puts
|
31
|
-
puts
|
35
|
+
puts '--------------------------------------------------------------'
|
32
36
|
puts "-- Title: #{movie.title}"
|
33
37
|
puts "-- Year: #{movie.year}"
|
34
|
-
puts
|
38
|
+
puts '--------------------------------------------------------------'
|
35
39
|
puts
|
36
|
-
puts
|
40
|
+
puts 'Continue? (y/n) |y|'
|
37
41
|
continue = $stdin.gets.strip
|
38
42
|
continue = 'y' if continue.blank?
|
39
|
-
if continue != 'y'
|
40
|
-
return
|
41
|
-
end
|
43
|
+
return if continue != 'y'
|
42
44
|
|
43
45
|
@dvd.rip(output)
|
44
46
|
|
@@ -46,67 +48,64 @@ module DvdRipper
|
|
46
48
|
|
47
49
|
puts "\"#{output}\" complete"
|
48
50
|
@dvd.eject
|
49
|
-
FileUtils.mv(output,
|
51
|
+
FileUtils.mv(output, @config.dest_dir)
|
50
52
|
end
|
51
53
|
|
52
54
|
def force_user_input(input)
|
53
55
|
@command = input
|
54
|
-
@user_command.raise(
|
56
|
+
@user_command.raise(DvdDetected, 'DVD Detected')
|
55
57
|
end
|
56
58
|
|
57
59
|
def start
|
58
|
-
Tmdb::Api.key(
|
60
|
+
Tmdb::Api.key(@config.tmdb_api_key)
|
59
61
|
|
60
62
|
@user_command = Thread.new do
|
61
|
-
|
63
|
+
loop do
|
62
64
|
begin
|
63
65
|
if @command.nil?
|
64
|
-
puts
|
66
|
+
puts 'Choose command [(r)ip, (s)pecify title, (q)uit, (e)ject] or insert a DVD'
|
65
67
|
@command = $stdin.gets.chomp
|
66
68
|
end
|
67
69
|
sleep 1
|
68
|
-
rescue
|
70
|
+
rescue DvdDetected
|
71
|
+
next
|
72
|
+
rescue StandardError => e
|
73
|
+
puts e.class
|
69
74
|
puts e.message
|
70
75
|
end
|
71
76
|
end
|
72
77
|
end
|
73
78
|
|
74
79
|
fsevent = FSEvent.new
|
75
|
-
fsevent.watch %
|
76
|
-
if @command.nil?
|
77
|
-
force_user_input(
|
80
|
+
fsevent.watch %w(/Volumes) do |_directories|
|
81
|
+
if @command.nil? && @dvd.present? && (@last_volume != @dvd.volume)
|
82
|
+
force_user_input('r')
|
78
83
|
@last_volume = @dvd.volume
|
79
84
|
end
|
80
85
|
end
|
81
86
|
|
82
|
-
Signal.trap(
|
87
|
+
Signal.trap('INT') do
|
83
88
|
fsevent.stop
|
84
89
|
Kernel.exit(0)
|
85
90
|
end
|
86
91
|
|
87
92
|
message_thread = Thread.new do
|
88
|
-
|
93
|
+
loop do
|
89
94
|
begin
|
90
|
-
while @command.nil?
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
process_dvd
|
95
|
-
end
|
96
|
-
if @command == "s"
|
97
|
-
puts "Enter title:"
|
95
|
+
sleep 1 while @command.nil?
|
96
|
+
process_dvd if @command == 'r'
|
97
|
+
if @command == 's'
|
98
|
+
puts 'Enter title:'
|
98
99
|
@title = $stdin.gets
|
99
100
|
process_dvd
|
100
101
|
end
|
101
|
-
if @command ==
|
102
|
-
puts
|
102
|
+
if @command == 'q'
|
103
|
+
puts 'Quitting...'
|
103
104
|
fsevent.stop
|
104
105
|
break
|
105
106
|
end
|
106
|
-
if @command ==
|
107
|
-
|
108
|
-
end
|
109
|
-
rescue Exception => e
|
107
|
+
@dvd.eject if @command == 'e'
|
108
|
+
rescue StandardError => e
|
110
109
|
puts e.message
|
111
110
|
puts e.class
|
112
111
|
puts e.backtrace
|
data/lib/dvd_ripper/config.rb
CHANGED
@@ -8,11 +8,11 @@ module DvdRipper
|
|
8
8
|
attr_accessor :config
|
9
9
|
|
10
10
|
DEFAULTS = {
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
11
|
+
working_dir: '~/tmp/movies',
|
12
|
+
dest_dir: '~/movies',
|
13
|
+
poster_dir: '~/tmp/movies/posters',
|
14
|
+
distance_threshold: 0.2,
|
15
|
+
tmdb_api_key: nil
|
16
16
|
}.freeze
|
17
17
|
|
18
18
|
def load
|
@@ -20,7 +20,7 @@ module DvdRipper
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def read_config
|
23
|
-
yml =
|
23
|
+
yml = ''
|
24
24
|
yml = File.read(config_path) if exists?
|
25
25
|
|
26
26
|
return YAML.load(yml) unless yml.blank?
|
@@ -53,11 +53,11 @@ module DvdRipper
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def config_path
|
56
|
-
File.expand_path(
|
56
|
+
File.expand_path('~/.dvd_ripper')
|
57
57
|
end
|
58
58
|
|
59
59
|
def save!
|
60
|
-
File.open(config_path,
|
60
|
+
File.open(config_path, 'w+') do |config_file|
|
61
61
|
config_file.write(config.to_yaml)
|
62
62
|
end
|
63
63
|
end
|
@@ -66,7 +66,7 @@ module DvdRipper
|
|
66
66
|
config.each do |k, v|
|
67
67
|
puts "#{k} (ENTER: #{v}):"
|
68
68
|
new_value = $stdin.gets
|
69
|
-
config[k] = new_value.strip unless
|
69
|
+
config[k] = new_value.strip unless new_value.strip.blank?
|
70
70
|
end
|
71
71
|
|
72
72
|
save!
|
@@ -76,9 +76,9 @@ end
|
|
76
76
|
|
77
77
|
::DvdRipper::Config.instance.load
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
# WORKING_DIR = "/Users/mnichols/Movies/Ripping"
|
80
|
+
# DEST_DIR = "/Users/mnichols/Movies/Ripped"
|
81
|
+
# POSTER_PATH = "./Posters"
|
82
|
+
# DISTANCE_THRESHOLD = 0.2
|
83
83
|
|
84
|
-
|
84
|
+
# @api_key = "867c178725a7e646a0f108ee78781a49"
|
data/lib/dvd_ripper/dvd.rb
CHANGED
@@ -2,26 +2,25 @@ class Dvd
|
|
2
2
|
attr_accessor :volumes
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@volumes =
|
5
|
+
@volumes = '/Volumes'
|
6
6
|
end
|
7
7
|
|
8
8
|
def volume
|
9
9
|
vol = nil
|
10
10
|
Dir.entries(@volumes).each do |video_dir|
|
11
|
-
if
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
11
|
+
next if ['.', '..'].member?(video_dir)
|
12
|
+
full_path = File.join(@volumes, video_dir)
|
13
|
+
if Dir.exist?(File.join(full_path, 'VIDEO_TS'))
|
14
|
+
vol = full_path
|
15
|
+
break
|
17
16
|
end
|
18
17
|
end
|
19
18
|
vol
|
20
19
|
end
|
21
20
|
|
22
21
|
def title
|
23
|
-
|
24
|
-
File.basename(volume).
|
22
|
+
fail "Invalid DVD Root or DVD not mounted at #{@volumes}" unless present?
|
23
|
+
File.basename(volume).tr('_', ' ').capitalize
|
25
24
|
end
|
26
25
|
|
27
26
|
def present?
|
@@ -29,45 +28,45 @@ class Dvd
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def rip(output)
|
32
|
-
File.delete(output) if File.
|
31
|
+
File.delete(output) if File.exist?(output)
|
33
32
|
|
34
33
|
state = :scanning
|
35
|
-
percent =
|
36
|
-
eta =
|
34
|
+
percent = '0.0'
|
35
|
+
eta = 'unknown'
|
37
36
|
dc = 0
|
38
|
-
spinner = [
|
37
|
+
spinner = ['-', '\\', '|', '/']
|
39
38
|
|
40
39
|
encoding_reg = /Encoding: task \d+ of \d+, (?<percent>\d+\.\d+) %.*ETA (?<eta>\d{2}h\d{2}m\d{2}s)/i
|
41
40
|
status_update = Thread.new do
|
42
|
-
|
41
|
+
loop do
|
43
42
|
sleep(1)
|
44
|
-
dc
|
43
|
+
dc += 1
|
45
44
|
|
46
45
|
if state == :encoding
|
47
|
-
print "\r#{spinner[dc%4]} Encoding #{percent} % (time left #{eta})"
|
46
|
+
print "\r#{spinner[dc % 4]} Encoding #{percent} % (time left #{eta})"
|
48
47
|
end
|
49
48
|
|
50
49
|
if state == :scanning
|
51
|
-
print("\r" + (
|
52
|
-
print "\r#{spinner[dc%4]} Scanning Titles.#{
|
50
|
+
print("\r" + (' ' * 50)) if (dc % 20) == 0
|
51
|
+
print "\r#{spinner[dc % 4]} Scanning Titles.#{'.' * (dc % 20)}"
|
53
52
|
end
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
57
56
|
command_output = []
|
58
57
|
last_line = nil
|
59
|
-
File.open(
|
60
|
-
IO.popen("HandBrakeCLI -Z \"AppleTV 3\" --main-feature -i \"#{volume}\" -o \"#{output}\" 2>&1",
|
58
|
+
File.open('./encode.log', 'w+') do |log|
|
59
|
+
IO.popen("HandBrakeCLI -Z \"AppleTV 3\" --main-feature -i \"#{volume}\" -o \"#{output}\" 2>&1", 'w+') do |f|
|
61
60
|
begin
|
62
61
|
while buf = f.read(255)
|
63
62
|
lines = buf.split(/\r|\n/)
|
64
63
|
lines.compact!
|
65
64
|
|
66
|
-
if (lines.size > 1)
|
65
|
+
if (lines.size > 1) && (!last_line.nil?)
|
67
66
|
command_output << last_line + lines.shift
|
68
67
|
end
|
69
68
|
|
70
|
-
if buf[-1] == "\r"
|
69
|
+
if buf[-1] == "\r" || buf[-1] == "\n"
|
71
70
|
last_line = nil
|
72
71
|
else
|
73
72
|
last_line = lines.pop
|
@@ -80,9 +79,7 @@ class Dvd
|
|
80
79
|
ln = ln.strip unless ln.nil?
|
81
80
|
|
82
81
|
# Change to encoding as soon as a matching line is found
|
83
|
-
if encoding_reg =~ ln
|
84
|
-
state = :encoding
|
85
|
-
end
|
82
|
+
state = :encoding if encoding_reg =~ ln
|
86
83
|
|
87
84
|
if state == :encoding
|
88
85
|
if m = encoding_reg.match(ln)
|
@@ -95,18 +92,18 @@ class Dvd
|
|
95
92
|
end
|
96
93
|
command_output = []
|
97
94
|
end
|
98
|
-
rescue
|
95
|
+
rescue StandardError => e
|
99
96
|
puts e.message
|
100
97
|
puts e.class
|
101
98
|
puts e.backtrace
|
102
99
|
end
|
103
100
|
end
|
104
101
|
end
|
105
|
-
exit_code =
|
102
|
+
exit_code = $CHILD_STATUS
|
106
103
|
|
107
104
|
if exit_code.exitstatus != 0
|
108
105
|
`killall HandBrakeCLI`
|
109
|
-
puts
|
106
|
+
puts 'Encoding Failed. See encode.log'
|
110
107
|
end
|
111
108
|
ensure
|
112
109
|
status_update.kill
|
@@ -114,6 +111,6 @@ class Dvd
|
|
114
111
|
end
|
115
112
|
|
116
113
|
def eject
|
117
|
-
system(
|
114
|
+
system('drutil tray eject')
|
118
115
|
end
|
119
116
|
end
|
data/lib/dvd_ripper/movie.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Movie
|
2
2
|
extend Forwardable
|
3
3
|
|
4
|
-
def initialize(tmdb_info=nil, imdb_info=nil)
|
4
|
+
def initialize(tmdb_info = nil, imdb_info = nil)
|
5
5
|
@tmdb_info = tmdb_info.nil? ? ::MovieStub.new : tmdb_info
|
6
6
|
@imdb_info = imdb_info.nil? ? ::MovieStub.new : imdb_info
|
7
7
|
end
|
@@ -14,22 +14,22 @@ class Movie
|
|
14
14
|
def tag(output)
|
15
15
|
poster_file_path = nil
|
16
16
|
unless poster_path.nil?
|
17
|
-
Dir.mkdir(::DvdRipper::Config.instance.poster_dir)
|
17
|
+
Dir.mkdir(::DvdRipper::Config.instance.poster_dir) unless Dir.exist?(::DvdRipper::Config.instance.poster_dir)
|
18
18
|
poster_file_path = File.expand_path(File.join(::DvdRipper::Config.instance.poster_dir, poster_path))
|
19
|
-
poster = File.open(poster_file_path,
|
19
|
+
poster = File.open(poster_file_path, 'wb')
|
20
20
|
begin
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
open("http://image.tmdb.org/t/p/w500#{poster_path}", 'rb') do |download|
|
22
|
+
poster.write(download.read)
|
23
|
+
end
|
24
24
|
ensure
|
25
|
-
|
25
|
+
poster.close
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
# Remove stik and other artwork, just in case
|
30
30
|
v = AtomicParsleyRuby::Media.new(output)
|
31
|
-
v.artwork
|
32
|
-
v.stik
|
31
|
+
v.artwork 'REMOVE_ALL'
|
32
|
+
v.stik 'remove'
|
33
33
|
v.overwrite true
|
34
34
|
v.process
|
35
35
|
|
@@ -39,7 +39,7 @@ class Movie
|
|
39
39
|
v.comment plot unless plot.nil?
|
40
40
|
v.description plot unless plot.nil?
|
41
41
|
v.year year.to_s
|
42
|
-
v.stik
|
42
|
+
v.stik '0'
|
43
43
|
v.genre genres[0]
|
44
44
|
v.longdesc plot_summary unless plot_summary.nil?
|
45
45
|
v.artwork poster_file_path unless poster_file_path.nil?
|
data/lib/dvd_ripper/search.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
class Search
|
2
2
|
def closest(title)
|
3
|
-
searcher = SearchFactory.get(
|
3
|
+
searcher = SearchFactory.get('tmdb')
|
4
4
|
|
5
5
|
movies = leven_sort(title, searcher.search(title))
|
6
6
|
while movies.empty?
|
7
|
-
puts
|
8
|
-
puts
|
7
|
+
puts ' - Title Not Found - '
|
8
|
+
puts 'Enter movie title (or enter to skip search):'
|
9
9
|
title = $stdin.gets.chomp
|
10
10
|
return nil if title.empty?
|
11
11
|
movies = leven_sort(title, searcher.search(title))
|
12
12
|
end
|
13
13
|
|
14
14
|
movie = auto_select(movies)
|
15
|
-
if movie.nil?
|
16
|
-
puts
|
17
|
-
movies.each_with_index do |
|
18
|
-
puts "#{i}. #{
|
15
|
+
if movie.nil? || ambiguous?(movies)
|
16
|
+
puts 'Please choose:'
|
17
|
+
movies.each_with_index do |m, i|
|
18
|
+
puts "#{i}. #{m.title} (#{m.release_date}) (#{m.title_distance.round(3)})"
|
19
19
|
end
|
20
|
-
puts
|
20
|
+
puts 's. Skip'
|
21
21
|
title_sel = $stdin.gets.chomp
|
22
22
|
return nil if title_sel == 's'
|
23
23
|
movie = movies[title_sel.to_i]
|
24
24
|
end
|
25
|
-
info = SearchFactory.get(
|
25
|
+
info = SearchFactory.get('imdb').search(title)[0]
|
26
26
|
|
27
27
|
movie = Movie.new(movie, info)
|
28
28
|
movie
|
@@ -33,11 +33,16 @@ class Search
|
|
33
33
|
distance = Levenshtein.normalized_distance(search_title, movie.title)
|
34
34
|
movie.title_distance = distance
|
35
35
|
end
|
36
|
-
movies.reverse.sort_by
|
36
|
+
movies.reverse.sort_by(&:title_distance)
|
37
37
|
end
|
38
38
|
|
39
39
|
def auto_select(movies)
|
40
|
-
|
40
|
+
auto_select_distance = ::DvdRipper::Config.instance.distance_threshold
|
41
|
+
unless movies.empty?
|
42
|
+
return movies[0] if movies.size == 1
|
43
|
+
return movies[0] if movies[0].title_distance < auto_select_distance
|
44
|
+
end
|
45
|
+
|
41
46
|
nil
|
42
47
|
end
|
43
48
|
|
data/lib/dvd_ripper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dvd_ripper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- matthew-nichols
|
@@ -14,14 +14,14 @@ dependencies:
|
|
14
14
|
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: atomic-parsley-ruby
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.0.5
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.0.5
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: bundler
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,8 +150,25 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '3.2'
|
153
|
-
|
154
|
-
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.35'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.35'
|
167
|
+
description: |2
|
168
|
+
A command-line utility that makes it easy to rip and tag DVDs.
|
169
|
+
Just install and run the utility. Then insert a DVD and follow prompts.
|
170
|
+
|
171
|
+
Repeat.
|
155
172
|
email:
|
156
173
|
- matt@nichols.link
|
157
174
|
executables:
|
@@ -161,6 +178,8 @@ extra_rdoc_files: []
|
|
161
178
|
files:
|
162
179
|
- ".gitignore"
|
163
180
|
- ".rspec"
|
181
|
+
- ".rubocop.yml"
|
182
|
+
- ".rubocop_todo.yml"
|
164
183
|
- ".travis.yml"
|
165
184
|
- CODE_OF_CONDUCT.md
|
166
185
|
- Gemfile
|