lib/movie.rb in pirate-autonzb-0.4.4 vs lib/movie.rb in pirate-autonzb-0.4.5

- old
+ new

@@ -26,11 +26,11 @@ end def score @score ||= imdb.score end - + def dirname "#{name} (#{year}) #{tags.join(' ')} #{format} #{source} #{sound} #{encoding} #{lang} {#{imdb_id}} [#{srt.join(',')}]".gsub(/\s+/,' ') end def <=>(other_movie) @@ -179,11 +179,16 @@ end end def add_imdb_id_to_file dir_name = File.dirname(path) - ext_name = File.extname(path) - base_name = File.basename(path, ext_name) + if File.directory?(path) + base_name = File.basename(path) + ext_name = '' + else + ext_name = path.include?('.nzb') ? '.nzb' : File.extname(path) + base_name = File.basename(path, ext_name) + end if matched = base_name.match(/^(.*)\s(\[{1}.*\]{1})$/) base_name_without_srts = matched[1] srts = matched[2] new_base_name = "#{base_name_without_srts} {#{imdb_id}} #{srts}#{ext_name}" else \ No newline at end of file