From 9db691ee26f7004d429b2079fbccb06b61899a60 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Mon, 12 Apr 2021 23:47:25 +0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Graceful=20exit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index ece8fb7..f5413ad 100644 --- a/main.py +++ b/main.py @@ -120,5 +120,11 @@ for ch in all_channels: with youtube_dl.YoutubeDL(ydl_opts) as ydl: Path(os.path.join(output_dir, ch['title'])).mkdir( parents=True, exist_ok=True) - ydl.download( - ['https://www.youtube.com/channel/{}'.format(ch["id"])]) + try: + ydl.download( + ['https://www.youtube.com/channel/{}'.format(ch["id"])]) + except KeyboardInterrupt: + c.print('\nGoodbye!', style='orange1') + c.print( + 'Start where you left off with "python main.py -i download_list.json"') + sys.exit()