forked from Icycoide/searxng
[perf] torrents.html, files.html: don't parse and re-format filesize
This commit is contained in:
parent
16ce5612dd
commit
e9f8412a6e
13 changed files with 23 additions and 86 deletions
|
@ -6,7 +6,7 @@
|
|||
from urllib.parse import quote, urljoin
|
||||
|
||||
from lxml import html
|
||||
from searx.utils import extract_text, get_torrent_size
|
||||
from searx.utils import extract_text
|
||||
|
||||
# about
|
||||
about = {
|
||||
|
@ -58,13 +58,9 @@ def response(resp):
|
|||
content = content.strip().replace('\n', ' | ')
|
||||
content = ' '.join(content.split())
|
||||
|
||||
filesize = result.xpath('.//span[@class="torrent_size"]/text()')[0].split()[0]
|
||||
filesize_multiplier = result.xpath('.//span[@class="torrent_size"]/text()')[0].split()[1]
|
||||
filesize = result.xpath('.//span[@class="torrent_size"]/text()')[0]
|
||||
files = (result.xpath('.//span[@class="torrent_files"]/text()') or ['1'])[0]
|
||||
|
||||
# convert filesize to byte if possible
|
||||
filesize = get_torrent_size(filesize, filesize_multiplier)
|
||||
|
||||
# convert files to int if possible
|
||||
try:
|
||||
files = int(files)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue