From bc084c150b0c6cdca61555b22465fa03f7c709d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Astudillo?= Date: Sat, 11 Feb 2012 05:13:39 -0200 Subject: [PATCH] fixed cleaner for more cases: strip tags like {dvdrip}, (dvdrip) or [dvdrip] and save to @tags --- lib/movies/filter.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/movies/filter.rb b/lib/movies/filter.rb index 18503e7..a12ea3d 100644 --- a/lib/movies/filter.rb +++ b/lib/movies/filter.rb @@ -23,6 +23,7 @@ def to_param def cleaner string = @title + string = extract_tags(string) [/((19|20)\d{2}).*$/, /\./, /\s*-\s*/, /\s{2,}/].each do |regex| string = string.gsub(regex, ' ') end @@ -33,6 +34,17 @@ def cleaner string.strip end + # remove usual tags in filenames like {720p}, (2011) or [KingdomRelease], and save it + def extract_tags(string) + @tags = [] + [ /\[([^\[]*)\]/ , /\{([^\{]*)\}/ , /\(([^\(]*)\)/ ].each do |regex| + while(matched = string.match(regex)) do + @tags << matched[1] + string.gsub!(matched[0]) + end + end + end + private def excluded @_excluded ||= YAML.load_file("#{File.dirname(__FILE__)}/exclude.yml")["excluded"]