-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed search failure due to unexpected parser state
- Loading branch information
Showing
5 changed files
with
34 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#VERSION: 4.8 | ||
#VERSION: 4.9 | ||
# AUTHORS: Lima66 | ||
# CONTRIBUTORS: Diego de las Heras ([email protected]) | ||
|
||
|
@@ -38,7 +38,7 @@ def __init__(self, url): | |
HTMLParser.__init__(self) | ||
self.url = url | ||
self.current_item = {} # dict for found item | ||
self.page_empty = 22000 | ||
self.page_items = 0 | ||
self.inside_table = False | ||
self.inside_tr = False | ||
self.column_index = -1 | ||
|
@@ -112,6 +112,7 @@ def handle_endtag(self, tag): | |
self.column_name = None | ||
if "link" in self.current_item: | ||
prettyPrinter(self.current_item) | ||
self.page_items += 1 | ||
|
||
def download_torrent(self, info): | ||
# since limetorrents provides torrent links in itorrent (cloudflare protected), | ||
|
@@ -128,14 +129,11 @@ def search(self, query, cat='all'): | |
query = query.replace("%20", "-") | ||
category = self.supported_categories[cat] | ||
|
||
parser = self.MyHtmlParser(self.url) | ||
page = 1 | ||
while True: | ||
page_url = "{0}/search/{1}/{2}/seeds/{3}/".format(self.url, category, query, page) | ||
for page in range(1, 5): | ||
page_url = f"{self.url}/search/{category}/{query}/seeds/{page}/" | ||
html = retrieve_url(page_url) | ||
lunghezza_html = len(html) | ||
if page > 6 or lunghezza_html <= parser.page_empty: | ||
return | ||
parser = self.MyHtmlParser(self.url) | ||
parser.feed(html) | ||
page += 1 | ||
parser.close() | ||
parser.close() | ||
if parser.page_items < 20: | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
#VERSION: 2.23 | ||
#VERSION: 2.24 | ||
# AUTHORS: Douman ([email protected]) | ||
# CONTRIBUTORS: Diego de las Heras ([email protected]) | ||
|
||
from re import compile as re_compile | ||
from html.parser import HTMLParser | ||
from datetime import datetime, timedelta | ||
|
||
|
@@ -35,6 +34,7 @@ def __init__(self, url): | |
self.item_bad = False # set to True for malicious links | ||
self.current_item = None # dict for found item | ||
self.item_name = None # key's name in current_item dict | ||
self.page_items = 0 | ||
self.parser_class = {"td": "pub_date", | ||
"ts": "size", | ||
"tul": "seeds", | ||
|
@@ -91,26 +91,19 @@ def handle_endtag(self, tag): | |
except Exception: | ||
self.current_item["pub_date"] = -1 | ||
prettyPrinter(self.current_item) | ||
self.page_items += 1 | ||
self.current_item = {} | ||
|
||
def search(self, query, cat='all'): | ||
""" Performs search """ | ||
query = query.replace("%20", "-") | ||
category = self.supported_categories[cat] | ||
|
||
parser = self.MyHtmlParser(self.url) | ||
page = "".join((self.url, "/", self.supported_categories[cat], | ||
"/torrents/", query, ".html?sort=seeds&page=1")) | ||
html = retrieve_url(page) | ||
parser.feed(html) | ||
|
||
counter = 1 | ||
additional_pages = re_compile(r"/{0}/torrents/{1}.html\?sort=seeds&page=[0-9]+" | ||
.format(self.supported_categories[cat], query)) | ||
list_searches = additional_pages.findall(html)[:-1] # last link is next(i.e. second) | ||
for page in map(lambda link: "".join((self.url, link)), list_searches): | ||
html = retrieve_url(page) | ||
for page in range(1, 5): | ||
parser = self.MyHtmlParser(self.url) | ||
page_url = f"{self.url}/{category}/torrents/{query}.html?sort=seeds&page={page}" | ||
html = retrieve_url(page_url) | ||
parser.feed(html) | ||
counter += 1 | ||
if counter > 3: | ||
parser.close() | ||
if parser.page_items < 20: | ||
break | ||
parser.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
eztv: 1.16 | ||
jackett: 4.0 | ||
limetorrents: 4.8 | ||
limetorrents: 4.9 | ||
piratebay: 3.3 | ||
solidtorrents: 2.3 | ||
torlock: 2.23 | ||
torrentproject: 1.4 | ||
solidtorrents: 2.4 | ||
torlock: 2.24 | ||
torrentproject: 1.5 | ||
torrentscsv: 1.4 |