nickheyer / DiscoFlix

A simple media-requesting, Radarr/Sonarr-interfacing, movie and tv show-listing Chat Bot web-app for your media server.
45 stars 3 forks source link

Check for existence of "id" key in download response. #13

Closed nickheyer closed 1 year ago

nickheyer commented 1 year ago

This error occurs because the radarr and/or sonarr api does not return an "id" key in the returned json object. This might be because there is no content available to download yet, ie: a show that has just been announced but there aren't episodes listed yet.

https://github.com/nickheyer/DiscoFlix/blob/d63dfe3fe54dbb09c4ab720df70f375224a9140d/src/bot/request_handler.py#LL282C38-L282C38

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/discord/client.py", line 441, in _run_event
    await coro(*args, **kwargs)
  File "/app/src/bot/discord_bot.py", line 477, in on_message
    await bound_fn()  # Resolves with fn / rejects with on_reject
    ^^^^^^^^^^^^^^^^
  File "/app/src/bot/discord_bot.py", line 259, in _find_content
    return await handler.process_request()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/bot/request_handler.py", line 287, in process_request
    self.databaseId = self.download_response["id"]
                      ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'id'