add keyboard interrupt handling

This commit is contained in:
2025-12-10 01:16:12 +01:00
parent b577359381
commit a842db2d97
2 changed files with 23 additions and 9 deletions

23
main.py
View File

@@ -13,14 +13,23 @@ jellyfinApiClient = JellyfinApiClient()
def main():
while True:
media_item = jellyfinApiClient.get_current_playback()
if not media_item:
discordRPC.clear()
time.sleep(15)
continue
try:
media_item = jellyfinApiClient.get_current_playback()
if not media_item:
discordRPC.clear()
time.sleep(15)
continue
discordRPC.update(to_rpc_payload(media_item))
time.sleep(15)
discordRPC.update(to_rpc_payload(media_item))
time.sleep(15)
except KeyboardInterrupt:
logging.info("Shutting down...")
discordRPC.clear()
break
except:
logging.exception("An error occurred in the main loop.")
jellyfinApiClient.authenticate()
time.sleep(15)
if __name__ == "__main__":
main()