Skip to content
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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions sickchill/oldbeard/providers/zamunda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import time
from urllib.parse import quote_plus

from requests.utils import dict_from_cookiejar
Expand Down Expand Up @@ -31,6 +32,7 @@ def __init__(self):

self.url = self.urls["base_url"]
self.categories = "&c7=1&c33=1&c55=1"
self.pattern = r'<table[^>]*id=["\']zbtable["\'][^>]*>'

self.cache = tvcache.TVCache(self, min_time=30) # only poll Zamunda every 30 minutes max

Expand Down Expand Up @@ -95,10 +97,11 @@ def search(self, search_strings):
# Search result page contains some invalid html that prevents html parser from returning all data.
# We cut everything before the table that contains the data we are interested in thus eliminating
# the invalid html portions
try:
index = data.lower().index('<table align="center" id="zbtable"')
except ValueError:
logger.debug(_("Could not find table of torrents zbtable"))
match = re.search(self.pattern, data, re.IGNORECASE)
if match:
index = match.start()
else:
logger.debug(_("Table not found"))
continue

data = data[index:]
Expand Down Expand Up @@ -159,5 +162,7 @@ def search(self, search_strings):
items.sort(key=lambda d: try_int(d.get("seeders", 0)), reverse=True)

results += items
logger.debug(_("Waiting to prevent flood protection..."))
time.sleep(2)

return results
Loading