From e5f35154a81240370506f5cd6a9da8598c052968 Mon Sep 17 00:00:00 2001 From: "Zev Averbach (aider)" Date: Fri, 3 Jan 2025 14:09:33 +0100 Subject: [PATCH] feat: Enhance CLI to clean URLs and display summary on console --- summarize_yt/cli.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/summarize_yt/cli.py b/summarize_yt/cli.py index 5f15f4f..027e6c5 100644 --- a/summarize_yt/cli.py +++ b/summarize_yt/cli.py @@ -33,13 +33,14 @@ def estimate_api_cost(text: str) -> float: def sanitize_filename(url: str) -> str: """Convert URL to safe filename, keeping video ID.""" - # Extract video ID if it's a YouTube URL + # Clean URL and extract video ID + clean_url = url.split("&")[0] # Remove everything after first & video_id = None - if "youtube.com" in url or "youtu.be" in url: - if "v=" in url: - video_id = url.split("v=")[1].split("&")[0] + if "youtube.com" in clean_url or "youtu.be" in clean_url: + if "v=" in clean_url: + video_id = clean_url.split("v=")[1] else: - video_id = url.split("/")[-1].split("?")[0] + video_id = clean_url.split("/")[-1].split("?")[0] timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") return f"{timestamp}_{video_id if video_id else 'video'}" @@ -277,6 +278,11 @@ def main(): with open(summary_path, "w", encoding="utf-8") as f: f.write(output) print(f"\nSummary saved to: {summary_path}") + + # Print the summary to console + print("\n=== Summary ===\n") + print(summary) + print() # Extra newline for readability # If output path specified, also save there if args.output: