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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c790edef4adcadfac4f29207280dc95141dbbb9a
4
- data.tar.gz: a99b0660fb5c9c064740613b507c2cd44f3ed889
3
+ metadata.gz: 8c409b5f455b51d73437180114360b882aa70411
4
+ data.tar.gz: 1caa53faa741cf11327b18c123493699b8b94350
5
5
  SHA512:
6
- metadata.gz: 3cf67739da381c2abdbcb5c3bd346b07491654a00ee4b28be79db604e7774c5346e68f5ade7e6684147e578b73ae58d2155bb5c6fc0ceb0802c746f3a9589b99
7
- data.tar.gz: 451cdfc1b3d0a0c91a21cb762b42f8ed18b1d2cc93cb6a38abc338e5c667ae43d9f38ad7a6ec0cb71b5066540a51c6219249bca298d55118bc0d62608a01a0fa
6
+ metadata.gz: 78c6902030545ef5b10eef57b662ef49946eeb92a081fb41759d74047c31704442133034a3cb3f5b7ba35ce504563d47f7118cb31ca48c5705d88ee22008b395
7
+ data.tar.gz: cb2735eba9ba4c31d83144a83989d2928052f603f387866e11d67fbcf3eed1c7ca6b522a55a115e69ae5576dc739cf78cb2ef024a7ea037dd7b3f6dc4388f1af
data/.gitignore CHANGED
@@ -16,5 +16,4 @@ test.rb
16
16
  encode.log
17
17
  temp/
18
18
  log/
19
-
20
-
19
+ *.gem
@@ -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
@@ -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
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "dvd_ripper"
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 "irb"
13
+ require 'irb'
14
14
  IRB.start
@@ -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 = "dvd_ripper"
7
+ spec.name = 'dvd_ripper'
8
8
  spec.version = DvdRipper::VERSION
9
- spec.authors = ["matthew-nichols"]
10
- spec.email = ["matt@nichols.link"]
9
+ spec.authors = ['matthew-nichols']
10
+ spec.email = ['matt@nichols.link']
11
11
 
12
- spec.summary = %q{Quickly rip and tag DVDs}
13
- spec.description = %q{A command-line utility that makes it easy to rip and tag DVDs. Just install and run the utility. Then insert a DVD and follow prompts. Repeat.}
14
- spec.homepage = "https://github.com/mattnichols/dvd_ripper"
15
- spec.license = "MIT"
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 = "exe"
19
- spec.executables = ["dvd_ripper"]
20
- spec.require_paths = ["lib"]
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' #, :git => 'https://github.com/cparratto/atomic-parsley-ruby.git'
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 "bundler", "~> 1.10"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "rspec", '~> 3.2'
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
@@ -1,29 +1,29 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'dvd_ripper'
4
- require "thor"
4
+ require 'thor'
5
5
 
6
6
  module DvdRipper
7
7
  class Cli < ::Thor
8
- desc "start", "start tool"
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[--version -v] => :__print_version
14
+ map %w(--version -v) => :__print_version
15
15
 
16
- desc "--version, -v", "print the version"
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 "config", "configure dvd_ripper"
21
+ desc 'config', 'configure dvd_ripper'
22
22
  def config
23
23
  Config.instance.prompt!
24
24
  end
25
25
 
26
- desc "help", "display this help"
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
 
@@ -1,4 +1,4 @@
1
- require "dvd_ripper/version"
1
+ require 'dvd_ripper/version'
2
2
 
3
3
  require 'thread'
4
4
  require 'rb-fsevent'
@@ -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 "- Provide details for movie -"
22
- puts "Enter Movie Title:"
25
+ puts '- Provide details for movie -'
26
+ puts 'Enter Movie Title:'
23
27
  movie = ::Movie.new
24
28
  movie.title = $stdin.gets
25
- puts "Enter Movie Year:"
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(::DvdRipper::Config.instance.working_dir, "#{title.gsub(": ", " - ").gsub(":", " - ")}.m4v")
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 "Continue? (y/n) |y|"
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, ::DvdRipper::Config.instance.dest_dir)
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("wakeup")
56
+ @user_command.raise(DvdDetected, 'DVD Detected')
55
57
  end
56
58
 
57
59
  def start
58
- Tmdb::Api.key(::DvdRipper::Config.instance.tmdb_api_key)
60
+ Tmdb::Api.key(@config.tmdb_api_key)
59
61
 
60
62
  @user_command = Thread.new do
61
- while true
63
+ loop do
62
64
  begin
63
65
  if @command.nil?
64
- puts "Choose command [(r)ip, (s)pecify title, (q)uit, (e)ject] or insert a DVD"
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 Exception => e
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 %W(/Volumes) do |directories|
76
- if @command.nil? and @dvd.present? and (@last_volume != @dvd.volume)
77
- force_user_input("r")
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("INT") do
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
- while true
93
+ loop do
89
94
  begin
90
- while @command.nil?
91
- sleep 1
92
- end
93
- if @command == "r"
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 == "q"
102
- puts "Quitting..."
102
+ if @command == 'q'
103
+ puts 'Quitting...'
103
104
  fsevent.stop
104
105
  break
105
106
  end
106
- if @command == "e"
107
- @dvd.eject
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
@@ -8,11 +8,11 @@ module DvdRipper
8
8
  attr_accessor :config
9
9
 
10
10
  DEFAULTS = {
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
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("~/.dvd_ripper")
56
+ File.expand_path('~/.dvd_ripper')
57
57
  end
58
58
 
59
59
  def save!
60
- File.open(config_path, "w+") do |config_file|
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 (new_value.strip.blank?)
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
- # WORKING_DIR = "/Users/mnichols/Movies/Ripping"
80
- # DEST_DIR = "/Users/mnichols/Movies/Ripped"
81
- # POSTER_PATH = "./Posters"
82
- # DISTANCE_THRESHOLD = 0.2
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
- # @api_key = "867c178725a7e646a0f108ee78781a49"
84
+ # @api_key = "867c178725a7e646a0f108ee78781a49"
@@ -2,26 +2,25 @@ class Dvd
2
2
  attr_accessor :volumes
3
3
 
4
4
  def initialize
5
- @volumes = "/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 not [".", ".."].member?(video_dir)
12
- full_path = File.join(@volumes, video_dir)
13
- if Dir.exists?(File.join(full_path, "VIDEO_TS"))
14
- vol = full_path
15
- break
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
- raise "Invalid DVD Root or DVD not mounted at #{@volumes}" if not present?
24
- File.basename(volume).gsub("_", " ").capitalize
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.exists?(output)
31
+ File.delete(output) if File.exist?(output)
33
32
 
34
33
  state = :scanning
35
- percent = "0.0"
36
- eta = "unknown"
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
- while true do
41
+ loop do
43
42
  sleep(1)
44
- dc = dc + 1
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" + (" " * 50)) if ((dc % 20) == 0)
52
- print "\r#{spinner[dc%4]} Scanning Titles.#{"." * (dc % 20)}"
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("./encode.log", "w+") do |log|
60
- IO.popen("HandBrakeCLI -Z \"AppleTV 3\" --main-feature -i \"#{volume}\" -o \"#{output}\" 2>&1", "w+") do |f|
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) and (not last_line.nil?)
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" or buf[-1] == "\n"
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 Exception => e
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 "Encoding Failed. See encode.log"
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("drutil tray eject")
114
+ system('drutil tray eject')
118
115
  end
119
116
  end
@@ -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) if not Dir.exists?(::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, "wb")
19
+ poster = File.open(poster_file_path, 'wb')
20
20
  begin
21
- open("http://image.tmdb.org/t/p/w500#{poster_path}", "rb") do |download|
22
- poster.write(download.read)
23
- end
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
- poster.close()
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 "REMOVE_ALL"
32
- v.stik "remove"
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 "0"
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?
@@ -2,12 +2,12 @@ module MovieExtensions
2
2
  def title_distance
3
3
  @title_distance
4
4
  end
5
-
5
+
6
6
  def title_distance=(distance)
7
7
  @title_distance = distance
8
8
  end
9
-
9
+
10
10
  def year
11
11
  Date.parse(release_date).year
12
12
  end
13
- end
13
+ end
@@ -1,3 +1,3 @@
1
1
  class MovieStub
2
2
  attr_accessor :title, :year, :poster_path, :plot, :genres, :plot_summary
3
- end
3
+ end
@@ -1,28 +1,28 @@
1
1
  class Search
2
2
  def closest(title)
3
- searcher = SearchFactory.get("tmdb")
3
+ searcher = SearchFactory.get('tmdb')
4
4
 
5
5
  movies = leven_sort(title, searcher.search(title))
6
6
  while movies.empty?
7
- puts " - Title Not Found - "
8
- puts "Enter movie title (or enter to skip search):"
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? or ambiguous?(movies)
16
- puts "Please choose:"
17
- movies.each_with_index do |movie, i|
18
- puts "#{i}. #{movie.title} (#{movie.release_date}) (#{movie.title_distance.round(3)})"
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 "s. Skip"
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("imdb").search(title)[0]
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 { |m| m.title_distance }
36
+ movies.reverse.sort_by(&:title_distance)
37
37
  end
38
38
 
39
39
  def auto_select(movies)
40
- return movies[0] if (movies.size == 1) or ((not movies.empty?) and (movies[0].title_distance < ::DvdRipper::Config.instance.distance_threshold))
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
 
@@ -2,6 +2,6 @@ class SearchFactory
2
2
  def self.get(name)
3
3
  return SearchImdb.new if name == 'imdb'
4
4
  return SearchTmdb.new if name == 'tmdb'
5
- raise "Invalid Search Engine Name"
5
+ fail 'Invalid Search Engine Name'
6
6
  end
7
7
  end
@@ -4,6 +4,8 @@ class SearchImdb
4
4
  end
5
5
  end
6
6
 
7
- class Imdb::Movie
8
- include MovieExtensions
7
+ module Imdb
8
+ class Movie
9
+ include MovieExtensions
10
+ end
9
11
  end
@@ -4,6 +4,8 @@ class SearchTmdb
4
4
  end
5
5
  end
6
6
 
7
- class Tmdb::Movie
8
- include MovieExtensions
7
+ module Tmdb
8
+ class Movie
9
+ include MovieExtensions
10
+ end
9
11
  end
@@ -1,3 +1,3 @@
1
1
  module DvdRipper
2
- VERSION = "0.1.0"
2
+ VERSION = '0.1.1'
3
3
  end
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.0
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: '0'
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: '0'
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
- description: A command-line utility that makes it easy to rip and tag DVDs. Just install
154
- and run the utility. Then insert a DVD and follow prompts. Repeat.
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