lib/movie-renamer.rb in movie-renamer-0.0.19 vs lib/movie-renamer.rb in movie-renamer-0.0.20
- old
+ new
@@ -67,12 +67,13 @@
@renamepattern = $config['filename']
end
if $config['savepath']
@newpath = File.expand_path($config['savepath'])
- puts @newpath
end
+
+ puts "Renamed movies will be saved in #{@newpath}"
class Movie
def initialize(filename,opts={})
opts = { :year => '', :director => '', :title => '', :part => '', :imdb =>''}.merge(opts)
@@ -138,10 +139,14 @@
filename = File.basename(filename)
title =MovieRenamer::titleExtract(File.basename(filename,'.*'))
return Movie.new(filename,:title => title)
end
+ def MovieRenamer::parseMovie(filename)
+
+ Movie.new(filename)
+ end
# attempt to remove the divx part from a filename
def MovieRenamer::titleExtract(filename)
r1 = %r{\s*\[?\(?\s*[dD](i|I)(v|V)(x|X)\s?(-|_)?\s?\w+\s*\)?\]?\s*}
r2 = %r{\s*\[?\(?\s*(x|X)(v|V)(i|I)(d|D)\s?(-|_)?\s?\w+\s*\)?\]?\s*}
r3 = %r{\s*\[?\(?\s*(d|D)(v|V)(d|D)(r|R)(i|I)(p|P)\s?(-|_)?\s*\)?\]?\s*}
@@ -324,10 +329,11 @@
def MovieRenamer::suggestMovies(movie)
coder = HTMLEntities.new
s = Imdb::Search.new(movie.title)
s.movies[0..4].each_with_index do |m,i|
m.title = coder.decode(m.title)#.encode("iso-8859-1")
- @output.puts "#{i}, #{m.year} - #{m.director.to_s.gsub(/(\[")|("\])/,'')} - #{m.title.gsub(/ .*/,'')}"
+ out = "#{i}, #{m.year} - #{m.director.to_s.gsub(/(\[")|("\])/,'')} - #{m.title.gsub(/ .*/,'')}"
+ say(HighLine.new.color(out, :green))
end
mt = s.movies[0..4]
cmd = ask("pick a choice [0..#{(mt.length) -1 }], Manual search, Edit manually, Skip Movie, Quit", ((0...mt.length).to_a.map{ |e| e.to_s} << %w{m e s q}).flatten)
if (0..mt.length).to_a.map{|e| e.to_s}.include?(cmd)
m = s.movies[cmd.to_i]