diff --git a/pytchat/cli/__init__.py b/pytchat/cli/__init__.py index 16f8a76..98c25ec 100644 --- a/pytchat/cli/__init__.py +++ b/pytchat/cli/__init__.py @@ -62,7 +62,7 @@ def main(): print("You can specify only one video ID.") return try: - SimpleEcho(Arguments().video_ids[0]).run() + Echo(Arguments().video_ids[0]).run() except InvalidVideoIdException as e: print("Invalid video id:", str(e)) except Exception as e: diff --git a/pytchat/cli/echo.py b/pytchat/cli/echo.py index 506a40f..95876ab 100644 --- a/pytchat/cli/echo.py +++ b/pytchat/cli/echo.py @@ -1,4 +1,5 @@ import pytchat +from ..exceptions import ChatDataFinished, NoContents from ..util.extract_video_id import extract_video_id @@ -12,6 +13,10 @@ class Echo: chatdata = livechat.get() for c in chatdata.sync_items(): print(f"{c.datetime} [{c.author.name}] {c.message} {c.amountString}") - - - + + try: + livechat.raise_for_status() + except (ChatDataFinished, NoContents): + print("Chat finished.") + except Exception as e: + print(type(e), str(e))