diff options
author | Marco Andronaco <andronacomarco@gmail.com> | 2023-07-09 16:17:26 +0200 |
---|---|---|
committer | Marco Andronaco <andronacomarco@gmail.com> | 2023-07-09 16:17:26 +0200 |
commit | 42abf95eba1f53e81a4e7e73827aa43a3269349d (patch) | |
tree | 2eb4dad9eeda3640c2a23527c8e275deba5431d2 | |
parent | eb08af3998f02f0445a6a0a70558592335a0e59d (diff) | |
download | tnt-search-42abf95eba1f53e81a4e7e73827aa43a3269349d.tar.gz |
fix paging
-rwxr-xr-x | main.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/main.py b/main.py index d0077d1..7660eac 100755 --- a/main.py +++ b/main.py @@ -50,11 +50,14 @@ def search_keyword(content, keyword: str, category=0): return [ x for x in results if category == x['CATEGORIA']] def get_last_torrents(content, page=1, amt=50): - tmp = sorted(content, key=lambda x:x['DATA']) + tmp = sorted(content, key=lambda x:x['DATA'], reverse=True) tmp_length = len(content) - start_from = tmp_length - (amt * page) - end_with = tmp_length + offset = amt * page + start_from = offset - amt + start_from = 0 if start_from < 0 else start_from + end_with = start_from + amt + end_with = tmp_length if end_with > tmp_length else end_with return tmp[start_from:end_with] def load_content(input_path=INPUT_PATH): @@ -76,7 +79,6 @@ def parse_values(result): tmp['CATEGORIA'] = CATEGORIE[int(tmp['CATEGORIA'])] tmp['HASH'] = MAGNET_STR.format(tmp['HASH']) tmp['DIMENSIONE'] = sizeof_fmt(tmp['DIMENSIONE']) - tmp['DESCRIZIONE'] = f"<span title='Autore: {tmp['AUTORE']}'>{tmp['DESCRIZIONE']}</span>" return tmp def format_results(results, headers=HEADER): |