From 2557db7502114688f9463382d012b545ec37d37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Fri, 10 Oct 2025 16:57:34 +0200 Subject: [PATCH] fix: properly keep category order --- config.default.toml | 9 +++++++-- feather.py | 9 +++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config.default.toml b/config.default.toml index 12fd3ab..e76fa46 100644 --- a/config.default.toml +++ b/config.default.toml @@ -1,4 +1,6 @@ [server] +# Server API to use. Either "googlereader" for the Google Reader API (FreshRSS, Miniflux, etc.) or "ttrss" for the TinyTiny-RSS API. +# The Google Reader API do not support nested categories. api = "googlereader" # (Required) URL of your server's Google Reader API endpoint # Can be set through the environment variable SERVER_URL. @@ -10,7 +12,8 @@ user = "username" # Can be set through the environment variable SERVER_PASSWORD. password = "password" # How many items to retrieve at most from the server in a single request. Lower values will make synchronization slower, higher values might make the server complain. -# Most servers are supposedly okay with up to 1000, but tt-rss complained so I dropped it to 500 here. +# If you are using the Google Reader API: servers should be okay with up to 1000. +# If you are using the ttrss API: servers should be okay with up to 200. # Can be set through the environment variable SERVER_ITEMS_PER_REQUEST. items_per_request = 500 @@ -66,7 +69,9 @@ template = ''' # Filename template for generated HTML files. # Can be set through the environment variable HTML_FILENAME_TEMPLATE. filename_template = "[{{ feed_title }}]\t{{ title }} ({{ published_formatted }}).html" -category_template = "{{ title }}" +# Category directory name template for generated HTML files. +# Can be set through the environment variable HTML_CATEGORY_TEMPLATE. +category_template = "{% if order %}{{ '%02d' % order }} {% endif %}{{ title }}" # Maximum allowed filename length (in bytes assuming UTF-8 encoding) before truncating. Depending on your filesystem filename's limits it may be possible to increase the value, ask Wikipedia for details. # Can be set through the environment variable HTML_MAX_FILENAME_LENGTH. max_filename_length = 250 diff --git a/feather.py b/feather.py index d026cf7..2f58b89 100755 --- a/feather.py +++ b/feather.py @@ -235,20 +235,21 @@ class TRRSession(ClientSession): self.feeds = {} def get_categories_recursive(parent_category, parent_categories=[]): categories = [] - for i in range(len(parent_category["items"])): - item = parent_category["items"][i] + index = 0 + for item in parent_category["items"]: # skip special categories and feeds if item["bare_id"] <= 0: continue # category elif item.get("type") == "category": - category = Category(id=item["bare_id"], parents=parent_categories, title=item["name"], order=i) + category = Category(id=item["bare_id"], parents=parent_categories, title=item["name"], order=index) categories.append(category) categories += get_categories_recursive(item, parent_categories+[category]) # feeds elif "type" not in item: self.feeds[item["bare_id"]] = item - self.feeds[item["bare_id"]]["order"] = i + self.feeds[item["bare_id"]]["order"] = index + index += 1 return categories tree = self.ttrss.get_feed_tree() return get_categories_recursive(tree["categories"])