Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/movies/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand Down