import os import json ROOT_DIR = r"C:\ComfyUI\Articles" PENDING_FILE = os.path.join(ROOT_DIR, "pending.json") def main(): if not os.path.exists(PENDING_FILE): print("No pending articles queue found.") return try: with open(PENDING_FILE, 'r', encoding='utf-8') as f: pending = json.load(f) except Exception as e: print(f"Failed to read pending queue: {e}") return if not pending: print("No pending articles in queue.") return # Group by category by_category = {} for item in pending: cat = item["category"] if cat not in by_category: by_category[cat] = [] by_category[cat].append(item) print(f"=== PENDING ARTICLES FOR SYNTHESIS (Total: {len(pending)}) ===") for category, items in by_category.items(): print(f"\nCategory: {category}") for idx, item in enumerate(items, 1): print(f" {idx}. Title: {item['title']}") print(f" Link: {item['link']}") print(f" Source File: {item['source_file']}") src_path = item["source_file"] content = "" if src_path and os.path.exists(src_path): try: with open(src_path, 'r', encoding='utf-8') as sf: content = sf.read().strip() except Exception as e: content = f"Error reading source file: {e}" else: content = "Source file does not exist." truncated = content if len(content) > 1500: truncated = content[:1500] + "... [truncated]" print(" Content:") # Indent content lines for cleaner logs for line in truncated.splitlines(): if line.strip(): print(f" {line}") print("\n" + "-" * 40) if __name__ == "__main__": main()