summaryrefslogtreecommitdiff
path: root/searx/engines/tokyotoshokan.py
diff options
context:
space:
mode:
authorBnyro <bnyro@tutanota.com>2024-06-12 22:35:13 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-06-15 15:42:29 +0200
commite9f8412a6e4b399a3335da73b3d321104bb0c4fb (patch)
tree0caf5c1bede7bb8739c5c2e5d107fa75455ecc24 /searx/engines/tokyotoshokan.py
parent16ce5612dd0ef426b6851ab97b248595f3933d8f (diff)
downloadsearxng-e9f8412a6e4b399a3335da73b3d321104bb0c4fb.tar.gz
searxng-e9f8412a6e4b399a3335da73b3d321104bb0c4fb.zip
[perf] torrents.html, files.html: don't parse and re-format filesize
Diffstat (limited to 'searx/engines/tokyotoshokan.py')
-rw-r--r--searx/engines/tokyotoshokan.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/searx/engines/tokyotoshokan.py b/searx/engines/tokyotoshokan.py
index 33f036428..ad0be1985 100644
--- a/searx/engines/tokyotoshokan.py
+++ b/searx/engines/tokyotoshokan.py
@@ -8,7 +8,7 @@ from datetime import datetime
from urllib.parse import urlencode
from lxml import html
-from searx.utils import extract_text, get_torrent_size, int_or_zero
+from searx.utils import extract_text, int_or_zero
# about
about = {
@@ -49,7 +49,7 @@ def response(resp):
return []
# regular expression for parsing torrent size strings
- size_re = re.compile(r'Size:\s*([\d.]+)(TB|GB|MB|B)', re.IGNORECASE)
+ size_re = re.compile(r'[\d.]+(T|G|M)?B', re.IGNORECASE)
# processing the results, two rows at a time
for i in range(0, len(rows), 2):
@@ -73,9 +73,7 @@ def response(resp):
item = item.strip()
if item.startswith('Size:'):
try:
- # ('1.228', 'GB')
- groups = size_re.match(item).groups()
- params['filesize'] = get_torrent_size(groups[0], groups[1])
+ params['filesize'] = size_re.search(item).group()
except: # pylint: disable=bare-except
pass
elif item.startswith('Date:'):