lib/dvdprofiler2xbmc/media_files.rb in royw-dvdprofiler2xbmc-0.0.2 vs lib/dvdprofiler2xbmc/media_files.rb in royw-dvdprofiler2xbmc-0.0.3

- old
+ new

@@ -7,30 +7,31 @@ # directories Array of String directory pathspecs def initialize(directories) @medias = [] directories.each do |dir| Dir.chdir(dir) - @medias += Dir.glob("**/*.{#{AppConfig[:media_extensions].join(',')}}").collect do |filename| - Media.new(dir, filename) + @medias += Dir.glob("**/*.{#{AppConfig[:media_extensions].join(',')}}").collect do |filename| + Media.new(dir, filename) end end @titles = {} @medias.each do |media| title = media.title_with_year @titles[title] ||= [] @titles[title] << media end end - - + + # find duplicate titles and return them in a hash # where the key is the title and the value is an # array of Media objects def duplicate_titles duplicates = {} @titles.each do |title, medias| - if medias.length > 1 - duplicates[title] = medias + base_medias = medias.collect{|media| media.path_to(:base) }.uniq + if base_medias.length > 1 + duplicates[title] = medias end end duplicates end end