Skip to content
This repository
Browse code

clean filenames from kickass torrents

  • Loading branch information...
commit c57d23b1d483b45c228e1f0b19fc395ff316049f 1 parent bfb592e
Niklas H authored

Showing 2 changed files with 48 additions and 19 deletions. Show diff stats Hide diff stats

  1. +2 1  app/models/torrent.rb
  2. +46 18 spec/models/torrent_spec.rb
3  app/models/torrent.rb
@@ -129,7 +129,8 @@ def clean_filename
129 129 tags << '720p' if filename =~ /720p/i
130 130 end
131 131 [filename.
132   - gsub(/(?:dvd|xvid|divx|hdtv|cam\b)/i,'').
  132 + gsub(/(?:dvd|xvid|divx|hdtv|cam|fqm|eztv\b)/i,'').
  133 + sub(/^_kat\.ph_/,'').
133 134 gsub(/\[.*?\]/,'').
134 135 gsub(/\(.*?\)/,'').
135 136 sub(/\d{5,}.TPB/,'').
64 spec/models/torrent_spec.rb
@@ -156,32 +156,60 @@
156 156 end
157 157
158 158 describe 'clean filenames' do
159   - let(:filename) { 'Fame of Bones 5x12 [720P - HDTV - OMMARZE].torrent' }
160 159 let(:torrent) { build(:torrent, filename: filename) }
161 160 let(:cleaned) { torrent.clean_filename }
162   - it "should keep the name" do
163   - cleaned.should include("Fame of Bones")
164   - end
165 161
166   - it "should keep season and episode" do
167   - cleaned.should include("5x12")
168   - end
  162 + describe "pirate-bay style" do
  163 + let(:filename) { 'Fame of Bones 5x12 [720P - HDTV - OMMARZE].torrent' }
  164 + it "should keep the name" do
  165 + cleaned.should include("Fame of Bones")
  166 + end
169 167
170   - it "should keep 720P info" do
171   - cleaned.should include("720")
172   - end
  168 + it "should keep season and episode" do
  169 + cleaned.should include("5x12")
  170 + end
173 171
174   - it "should remove brackets" do
175   - cleaned.should_not include("[")
176   - cleaned.should_not include("]")
177   - end
  172 + it "should keep 720P info" do
  173 + cleaned.should include("720")
  174 + end
  175 +
  176 + it "should remove brackets" do
  177 + cleaned.should_not include("[")
  178 + cleaned.should_not include("]")
  179 + end
  180 +
  181 + it "should remove extension" do
  182 + cleaned.should_not include(".torrent")
  183 + end
178 184
179   - it "should remove extension" do
180   - cleaned.should_not include(".torrent")
  185 + it "should remove release group" do
  186 + cleaned.should_not include("OMMARZE")
  187 + end
181 188 end
182 189
183   - it "should remove release group" do
184   - cleaned.should_not include("OMMARZE")
  190 + describe "Kickass-torrents style" do
  191 + let(:filename) { "_kat.ph_the.peanut.penguins.s01e03.friday.night.fnords.hdtv.xvid.fqm.eztv.torrent" }
  192 + it "should remove kat prefix" do
  193 + cleaned.should_not include("_kat.ph_")
  194 + cleaned.should_not include("kat")
  195 + cleaned.should_not include("ph")
  196 + end
  197 +
  198 + it "should keep season and episode" do
  199 + cleaned.should include('s01e03')
  200 + end
  201 +
  202 + it "should not include format" do
  203 + cleaned.should_not include('xvid')
  204 + end
  205 +
  206 + it "should not include release group" do
  207 + cleaned.should_not include('fqm')
  208 + end
  209 +
  210 + it "should not include eztv" do
  211 + cleaned.should_not include('eztv')
  212 + end
185 213 end
186 214 end
187 215

0 comments on commit c57d23b

Please sign in to comment.
Something went wrong with that request. Please try again.