From 94baaf929673d71bcc1c5c489d70d4e7272e3d88 Mon Sep 17 00:00:00 2001 From: lomion Date: Tue, 29 Sep 2020 09:49:16 +0200 Subject: [PATCH] Fixed handling of poster size and language if user did not set these values --- maubot.yaml | 2 +- tmdb/database.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/maubot.yaml b/maubot.yaml index e9b225a..75332d5 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: lomion.tmdb -version: 1.0.0 +version: 1.0.1 license: AGPL 3.0 modules: - tmdb diff --git a/tmdb/database.py b/tmdb/database.py index 4dfd103..9e2cf3b 100644 --- a/tmdb/database.py +++ b/tmdb/database.py @@ -45,7 +45,11 @@ class Database: def get_language(self, user_id): rows = self.db.execute(select([self.language.c.language]) .where(self.language.c.user_id == user_id)) - return rows.fetchone()['language'] + row = rows.fetchone() + if row: + return row['language'] + else: + return None def set_poster_size(self, user_id, size): with self.db.begin() as tx: @@ -55,4 +59,8 @@ class Database: def get_poster_size(self, user_id): rows = self.db.execute(select([self.tmdb_poster_size.c.size]) .where(self.tmdb_poster_size.c.user_id == user_id)) - return rows.fetchone()['size'] \ No newline at end of file + row = rows.fetchone() + if row: + return row['size'] + else: + return None \ No newline at end of file