fix paging
Marco Andronaco andronacomarco@gmail.com
Sun, 09 Jul 2023 16:17:26 +0200
1 files changed,
6 insertions(+),
4 deletions(-)
jump to
M
main.py
→
main.py
@@ -50,11 +50,14 @@ return results
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 @@ tmp['DATA'] = datetime.strptime(tmp['DATA'], "%Y-%m-%dT%H:%M:%S").strftime("%d/%m/%Y")
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):