It is currently Sat Nov 26, 2011 8:16 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Patch for Fake WMV files
PostPosted: Wed Mar 25, 2009 12:19 am 
Offline
Developer

Joined: Mon Apr 28, 2008 11:33 pm
Posts: 36
Regarding the bug https://ted.nu/forum/viewtopic.php?t=1831 , i have written a small patch that now checks every file inside a torrent for a match with the keywords. so if you add wmv to the filter list, rather than just checking in the feed/torrent name for a match, if the file itself matches one of the keywords, it will be ignored.

Code:
Index: ted/TedParser.java
===================================================================
--- ted/TedParser.java   (revision 731)
+++ ted/TedParser.java   (working copy)
@@ -731,6 +731,12 @@
            }
         }

+         if(containsFilteredItems(torrent, serie))
+         {
+             // Log message not translated!
+             parseLogInfo[itemNr][1] = "Contains filtered keywors";
+             return;
+         }
         // get torrent state (for seeders)
         try {
            int torrentSeeders = 0;
@@ -971,6 +977,36 @@
      return matchesHDKeywords && matchesNormalKeywords;
   }

+   private boolean containsFilteredItems(TorrentImpl torrent,TedSerie serie)
+   {
+       boolean containsFilteredItems = false;
+       TorrentInfo torrentInfo = torrent.getInfo();
+       TorrentFile[] files;
+      
+       // check if the torrent contains multpile files
+       if(!torrentInfo.isSingleFile())
+       {
+      files = torrentInfo.getMultiFile();
+      String name;
+      
+      for(int i = 0; i < files.length;i++)
+      {
+          name = files[i].getPath().toString();
+          if(tPKeyChecker.checkKeywords(name, serie.getKeywords()))
+          {
+         containsFilteredItems = true;
+          }
+      }
+       } else
+       {
+      if(tPKeyChecker.checkKeywords(torrentInfo.getName(),serie.getKeywords()))
+      {
+          containsFilteredItems = true;
+      }
+       }
+       return containsFilteredItems;
+   }
+   
   /**
    * Checks if torrent contains compressed files
    *
@@ -993,7 +1029,8 @@
         for (int i = 0; i < files.length; i++)
         {
            name = files[i].getPath().toString();
-            type = name.substring(name.length() - 3);
+            // get the file type
+            type = name.substring(name.lastIndexOf(".")+1);

            if (isCompressedFile(type))
            {
@@ -1008,8 +1045,7 @@
      } else
      {
         // check to see if the single file is compressed
-         if (isCompressedFile(torrentInfo.getName().substring(
-               torrentInfo.getName().length() - 3)))
+         if (isCompressedFile(torrentInfo.getName().substring(torrentInfo.getName().lastIndexOf("."))))
         {
            TedLog.debug(Lang.getString("TedParser.CompressedFiles"));
            return true;

This also means that torrents with multiple files in it will be scanned for matching keywords also.

regards,

gb


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 25, 2009 12:12 pm 
Offline
Lead Developer
User avatar

Joined: Mon Jan 16, 2006 5:46 pm
Posts: 904
Location: Netherlands
Thanks for the patch!

I added it to the bug tracker so we won't forget to implement it for the next version of ted.

And feel free to fix more bugs if you encounter them ;)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 25, 2009 12:30 pm 
Offline
Developer

Joined: Mon Apr 28, 2008 11:33 pm
Posts: 36
not a problem! this is the first open source project i've felt like contributing to. hope it all helps!


Top
 Profile  
 
 Post subject: New version with patch
PostPosted: Fri Mar 27, 2009 1:40 pm 
Offline

Joined: Fri Mar 27, 2009 1:35 pm
Posts: 2
Hi all,

It would be great if there were a new TED version with the patch included! What do you think?


Ducem.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 29, 2009 2:10 pm 
Offline
Lead Developer
User avatar

Joined: Mon Jan 16, 2006 5:46 pm
Posts: 904
Location: Netherlands
(This reply was also posted in the other thread)
I'd finally time to look into this. Couldn't you use the option in the Preferences menu -> Advanced tab where you can specify file extensions that you want to filter out. I think in the current version it's called something like Filter out compressed files, in the next version this will be renamed to a more general option.


Top
 Profile  
 
 Post subject: wmv
PostPosted: Tue Mar 31, 2009 12:13 am 
Offline
User avatar

Joined: Tue Mar 24, 2009 4:48 am
Posts: 2
:DThank you for looking into the wmv problem ..will look forward to an upgraded version down the road ..wish i knew how to develop stuff like this..then i could help..thanks again and tc


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group