|
@@ -12,7 +12,7 @@
|
|
|
from lxml import html
|
|
|
from searx.engines.xpath import extract_text
|
|
|
from searx.url_utils import urlencode
|
|
|
-from searx.utils import get_torrent_size
|
|
|
+from searx.utils import get_torrent_size, int_or_zero
|
|
|
|
|
|
|
|
|
categories = ['files', 'images', 'videos', 'music']
|
|
@@ -49,14 +49,14 @@ def response(resp):
|
|
|
for result in dom.xpath(xpath_results):
|
|
|
|
|
|
filesize = 0
|
|
|
- seed = 0
|
|
|
- leech = 0
|
|
|
- downloads = 0
|
|
|
magnet_link = ""
|
|
|
torrent_link = ""
|
|
|
|
|
|
|
|
|
- category = result.xpath(xpath_category)[0].attrib.get('title')
|
|
|
+ try:
|
|
|
+ category = result.xpath(xpath_category)[0].attrib.get('title')
|
|
|
+ except:
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
page_a = result.xpath(xpath_title)[0]
|
|
@@ -74,12 +74,14 @@ def response(resp):
|
|
|
|
|
|
torrent_link = url
|
|
|
|
|
|
-
|
|
|
- try:
|
|
|
- seed = int(result.xpath(xpath_seeds)[0])
|
|
|
- leech = int(result.xpath(xpath_leeches)[0])
|
|
|
- except:
|
|
|
- pass
|
|
|
+
|
|
|
+ seed = int_or_zero(result.xpath(xpath_seeds))
|
|
|
+
|
|
|
+
|
|
|
+ leech = int_or_zero(result.xpath(xpath_leeches))
|
|
|
+
|
|
|
+
|
|
|
+ downloads = int_or_zero(result.xpath(xpath_downloads))
|
|
|
|
|
|
|
|
|
try:
|
|
@@ -89,12 +91,6 @@ def response(resp):
|
|
|
except:
|
|
|
pass
|
|
|
|
|
|
-
|
|
|
- try:
|
|
|
- downloads = result.xpath(xpath_downloads)[0]
|
|
|
- except:
|
|
|
- pass
|
|
|
-
|
|
|
|
|
|
content = 'Category: "{category}". Downloaded {downloads} times.'
|
|
|
content = content.format(category=category, downloads=downloads)
|