lib/movie-renamer.rb in movie-renamer-0.0.15 vs lib/movie-renamer.rb in movie-renamer-0.0.16
- old
+ new
@@ -271,11 +271,17 @@
def MovieRenamer::sanitizeInput(input)
# XXX naive sanitize
# simply removing all non standard characters
input.gsub(/[^A-Za-z0-9\_\-\s']/,'').gsub(/\s+/,' ').chomp.sub(/ +$/,'')
end
-
+
+ def MovieRenamer::imdbLookup(name)
+ s = Imdb::Search.new(name)
+ s.movies[0..4].each_with_index do |m,i|
+ @output.puts "#{i}, #{m.year} - #{m.director.to_s.gsub(/(\[")|("\])/,'')} - #{m.title.gsub(/ .*/,'')}"
+ end
+ end
# makes a query to imdb database
def MovieRenamer::suggestMovies(movie)
s = Imdb::Search.new(movie.title)
s.movies[0..4].each_with_index do |m,i|
@output.puts "#{i}, #{m.year} - #{m.director.to_s.gsub(/(\[")|("\])/,'')} - #{m.title.gsub(/ .*/,'')}"
@@ -283,10 +289,10 @@
cmd = ask("pick a choice [0..4], Manual search, Edit Manually", %w{0 1 2 3 4 m e}) do |q|
q.readline = true
end
if %w{0 1 2 3 4}.include?(cmd)
m = s.movies[cmd.to_i]
- movie.title = m.title.gsub(/ .*/,'').gsub(/\s*\([0-9]+\)/,'')
+ movie.title = m.title.gsub(/ .*/,'').gsub(/\s*\([0-9]+\)/,'').gsub(/\saka\s.*/,'') # aka removes other lang from title
movie.year = m.year
movie.director = m.director.to_s.gsub(/(\[")|("\])/,'')
elsif cmd == "m"
movie.title = ask("enter title")
MovieRenamer::suggestMovies(movie )