[0.7.11] RequireCat not working in RSS feed

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
Commodore
Newbie
Newbie
Posts: 1
Joined: April 22nd, 2013, 4:21 am

[0.7.11] RequireCat not working in RSS feed

Post by Commodore »

because it's missing some code

made the following changes to rss.py to fix it:

Code: Select all

@@ -418,20 +418,22 @@
                     for n in xrange(regcount):
                         if reEnabled[n]:
                             if category and reTypes[n] == 'C':
-                                found = re.search(regexes[n], category)
+                               found = regexes[n].search(category)
                                 if not found:
-                                    logging.debug("Filter rejected on rule %d", n)
+                                    logging.debug("Filter unmatched on rule %d", n)
                                     result = False
+                                else:
+                                    logging.debug("Filter matched on rule %d", n)
+                                    result = True
                                     break
                             else:
                                 if regexes[n]:
-                                    found = re.search(regexes[n], title)
+                                    found = regexes[n].search(title)
                                 else:
                                     found = False
                                 if reTypes[n] == 'M' and not found:
-                                    logging.debug("Filter rejected on rule %d", n)
+                                    logging.debug("Filter unmatched on rule %d", n)
                                     result = False
-                                    break
                                 if found and reTypes[n] == 'A':
                                     logging.debug("Filter matched on rule %d", n)
                                     result = True
The changes here solve three problems:

- without the additional "else", RequiresCat rules that pass are never counted.
- some of the "break" statements prevent rule fallthrough where it should not be prevented (in the previous code, only the first rule would ever be evaluated because it would "break" on a failure to match)
- it is unnecessary to use re.search because regexes[n] is already a compiled re object, so regexes[n].search is better.
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: [0.7.11] RequireCat not working in RSS feed

Post by shypike »

You misunderstand the meaning of RequireCat.
It will only ever trigger on a mismatch. When it matches, the next filter is tried.
This by design.
You "require" category "TV", but after that your show name filter comes.
Any item not being category "TV" is rejected immediately. Otherwise any "TV" show would download.

Using re.search vs. regexes[n].search is arbitrary, the re.search functions knows that it getting a pre-compiled regex.
It is indeed more common to use the regex.search form.
Post Reply