diff --git a/main.py b/main.py index 4129de0..ad4f6f1 100644 --- a/main.py +++ b/main.py @@ -115,13 +115,15 @@ def get_html_path(config, item_json): folder_directory = config.html_root / escape_filename(item_json["folder"]) folder_directory.mkdir(exist_ok=True) - datetime_published = datetime.fromtimestamp(item_json["published"], config.timezone).strftime(config.time_format) - html_name = escape_filename(f"{datetime_published}\t[{item_json["origin_title"]}]\t{item_json["title"]}.html") + html_name = escape_filename(f"{item_json["published_formatted"]}\t[{item_json["origin_title"]}]\t{item_json["title"]}.html") html_name = html_name[:max_filename_length] + '….html' if len(html_name) > max_filename_length else html_name html_path = folder_directory / html_name return html_path +def format_datetime(config, timestamp): + return datetime.fromtimestamp(timestamp, config.timezone).strftime(config.time_format) + def synchronize_with_server(config, client_session): # Synchronize items from the server, generating and deleting JSON and HTML files accordingly config.update_lock.touch() @@ -144,7 +146,9 @@ def synchronize_with_server(config, client_session): "folder": folder_name, "title": item_content.title, "published": item_content.published, + "published_formatted": format_datetime(config, item_content.published), "updated": item_content.updated, + "updated_formatted": format_datetime(config, item_content.updated), "author": item_content.author, "summary": item_content.summary.content, "content": item_content.content.content, @@ -187,7 +191,6 @@ def synchronize_with_server(config, client_session): def generate_html_for_item(config, item_json): # Write HTML file for a JSON object - datetime_published = datetime.fromtimestamp(item_json["published"], config.timezone).strftime(config.time_format) html_path = config.html_root / item_json["html_path"] if html_path.exists(): print(f"WARNING: a file already exist for {html_path}. Either the feed has duplicate entries, or something has gone terribly wrong.") @@ -205,7 +208,7 @@ def generate_html_for_item(config, item_json):

- {datetime_published} + {item_json["published_formatted"]} {item_json["origin_title"]}

{item_json["title"]}