Permalink
Browse files

clean filenames from kickass torrents

  • Loading branch information...
1 parent bfb592e commit c57d23b1d483b45c228e1f0b19fc395ff316049f @niklas committed May 13, 2012
Showing with 48 additions and 19 deletions.
  1. +2 −1 app/models/torrent.rb
  2. +46 −18 spec/models/torrent_spec.rb
View
3 app/models/torrent.rb
@@ -129,7 +129,8 @@ def clean_filename
tags << '720p' if filename =~ /720p/i
end
[filename.
- gsub(/(?:dvd|xvid|divx|hdtv|cam\b)/i,'').
+ gsub(/(?:dvd|xvid|divx|hdtv|cam|fqm|eztv\b)/i,'').
+ sub(/^_kat\.ph_/,'').
gsub(/\[.*?\]/,'').
gsub(/\(.*?\)/,'').
sub(/\d{5,}.TPB/,'').
View
64 spec/models/torrent_spec.rb
@@ -156,32 +156,60 @@
end
describe 'clean filenames' do
- let(:filename) { 'Fame of Bones 5x12 [720P - HDTV - OMMARZE].torrent' }
let(:torrent) { build(:torrent, filename: filename) }
let(:cleaned) { torrent.clean_filename }
- it "should keep the name" do
- cleaned.should include("Fame of Bones")
- end
- it "should keep season and episode" do
- cleaned.should include("5x12")
- end
+ describe "pirate-bay style" do
+ let(:filename) { 'Fame of Bones 5x12 [720P - HDTV - OMMARZE].torrent' }
+ it "should keep the name" do
+ cleaned.should include("Fame of Bones")
+ end
- it "should keep 720P info" do
- cleaned.should include("720")
- end
+ it "should keep season and episode" do
+ cleaned.should include("5x12")
+ end
- it "should remove brackets" do
- cleaned.should_not include("[")
- cleaned.should_not include("]")
- end
+ it "should keep 720P info" do
+ cleaned.should include("720")
+ end
+
+ it "should remove brackets" do
+ cleaned.should_not include("[")
+ cleaned.should_not include("]")
+ end
+
+ it "should remove extension" do
+ cleaned.should_not include(".torrent")
+ end
- it "should remove extension" do
- cleaned.should_not include(".torrent")
+ it "should remove release group" do
+ cleaned.should_not include("OMMARZE")
+ end
end
- it "should remove release group" do
- cleaned.should_not include("OMMARZE")
+ describe "Kickass-torrents style" do
+ let(:filename) { "_kat.ph_the.peanut.penguins.s01e03.friday.night.fnords.hdtv.xvid.fqm.eztv.torrent" }
+ it "should remove kat prefix" do
+ cleaned.should_not include("_kat.ph_")
+ cleaned.should_not include("kat")
+ cleaned.should_not include("ph")
+ end
+
+ it "should keep season and episode" do
+ cleaned.should include('s01e03')
+ end
+
+ it "should not include format" do
+ cleaned.should_not include('xvid')
+ end
+
+ it "should not include release group" do
+ cleaned.should_not include('fqm')
+ end
+
+ it "should not include eztv" do
+ cleaned.should_not include('eztv')
+ end
end
end

0 comments on commit c57d23b

Please sign in to comment.