Add graceful exit handling for Ctrl+C interrupts
This commit is contained in:
parent
cb1a201107
commit
a2e8042f27
@ -6,6 +6,7 @@ YouTube CLI - A command-line interface for browsing and downloading YouTube vide
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
@ -1004,8 +1005,16 @@ class YouTubeCLI:
|
||||
console.print(f"[red]Error during playlist download: {str(e)}[/red]")
|
||||
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
"""Handle Ctrl+C gracefully."""
|
||||
console.print("\n[yellow]Operation cancelled by user.[/yellow]")
|
||||
sys.exit(0)
|
||||
|
||||
def main():
|
||||
"""Main entry point for the YouTube CLI application."""
|
||||
# Register signal handler for Ctrl+C
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="YouTube CLI - Browse and download videos from YouTube"
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user