-
-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Zamunda provider search #8819
base: develop
Are you sure you want to change the base?
Fixed Zamunda provider search #8819
Conversation
WalkthroughThe changes update the Changes
Sequence Diagram(s)sequenceDiagram
participant C as Caller
participant P as Provider
C->>P: call search()
alt HTML table found via regex
P->>P: Process search results & log info
else HTML table not found
P->>P: Log debug message (table not found)
end
P->>P: Execute time.sleep(2) (delay for flood protection)
P->>C: Return search results
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
sickchill/oldbeard/providers/zamunda.py (1)
35-35
: Consider making the table pattern more specific.While the pattern will match the target table, it could be more specific to ensure robustness against future HTML changes.
- self.pattern = r'<table[^>]*id=["\']zbtable["\'][^>]*>' + self.pattern = r'<table[^>]*(?:class="[^"]*responsivetable[^"]*"|id="zbtable")[^>]*>'
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
sickchill/oldbeard/providers/zamunda.py
(7 hunks)
🔇 Additional comments (4)
sickchill/oldbeard/providers/zamunda.py (4)
2-2
: LGTM!The
time
module import is correctly added to support the flood protection delay.
55-55
: LGTM!The logging messages have been simplified while maintaining clarity and consistency.
Also applies to: 62-62, 66-66
83-83
: LGTM!The logging messages have been modernized using f-strings, improving readability while maintaining the same information.
Also applies to: 86-86, 90-90, 94-94, 104-104, 111-111, 120-120, 150-150
100-105
: LGTM!The table search logic has been improved by:
- Using explicit pattern matching instead of try-except
- Adding proper error handling with debug logging
logger.debug("Waiting to prevent flood protection...") | ||
time.sleep(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider improving the flood protection mechanism.
The current implementation has two potential issues:
- The 2-second delay might be insufficient for some scenarios
- The delay at the end of the search won't help prevent flood protection during the search loop
Consider moving the delay inside the search loop and making the delay time configurable.
for search_string in {*search_strings[mode]}:
+ logger.debug("Waiting to prevent flood protection...")
+ time.sleep(self.flood_protection_delay) # Add this as a configurable class attribute
search_url = self.urls["search"] % quote_plus(search_string) + self.categories
logger.debug(f"Search String: {search_string}")
data = self.get_url(search_url, returns="text")
- logger.debug("Waiting to prevent flood protection...")
- time.sleep(2)
Also, add the delay configuration in __init__
:
def __init__(self):
super().__init__("Zamunda")
self.flood_protection_delay = 2 # seconds
Cutting out all the logger prefix _ removes the detail of the call
Also |
Fixes #
The search for the Zamunda provider was not working.
Proposed changes in this pull request:
added pattern for the search format
reformatted the logging instances
added wait for 2 seconds to prevent Flood Protection when searching for multiple episodes.
PR is based on the DEVELOP branch
Don't send big changes all at once. Split up big PRs into multiple smaller PRs that are easier to manage and review
Read contribution guide
Summary by CodeRabbit