diff --git a/tools/fetch.py b/tools/fetch.py index 583f543..9c5c588 100644 --- a/tools/fetch.py +++ b/tools/fetch.py @@ -249,7 +249,7 @@ def is_arctic_shift_api(url: str) -> bool: return 'arctic-shift.photon-reddit.com' in parsed.netloc and '/api/' in parsed.path def archive_arctic_shift_api(url: str) -> str: - """Archive Arctic Shift API results as minimal Markdown""" + """Archive Arctic Shift API results as HTML""" try: headers = {"User-Agent": "Mozilla/5.0 (ArchiveBot/1.0)"} response = requests.get(url, timeout=30, headers=headers) @@ -259,7 +259,7 @@ def archive_arctic_shift_api(url: str) -> str: comments = data.get('data', []) if not comments: - return "# Reddit Comments\n\nNo comments found.\n" + return "
No comments found.
" # Extract search info from URL for title parsed_url = urlparse(url) @@ -281,7 +281,7 @@ def archive_arctic_shift_api(url: str) -> str: title = "Comments by " + " • ".join(title_parts) if title_parts else "Reddit Comments" - md_content = f"# {title}\n\n" + html_content = f"Failed to archive API response: {html.escape(str(e))}
" def convert_ihsoyct_to_api_url(url: str) -> str: """Convert ihsoyct.github.io URL to Arctic Shift API URL""" @@ -373,10 +377,10 @@ def archive(url: str, out_dir: pathlib.Path, force: bool): url = convert_ihsoyct_to_api_url(url) print(f" API URL: {url}") - # Check for API URL and change extension to .md + # Check for API URL and change extension to .html is_api_url = is_arctic_shift_api(url) if is_api_url or is_reddit_search_tool(original_url): - fname = fname.with_suffix('.md') + fname = fname.with_suffix('.html') if fname.exists() and not force: print(f"✓ cached: {original_url}") @@ -389,8 +393,42 @@ def archive(url: str, out_dir: pathlib.Path, force: bool): if is_arctic_shift_api(url): content = archive_arctic_shift_api(url) - # For markdown, just add header and content - final_content = generate_markdown_archive_header(original_url, archive_date) + content + # Enhanced styling with archive header for HTML + archive_style = """ + + """ + final_content = ( + "\n" + + "
\n') + html_content += f'