Repos / pytaku / 01b57b5fa6
commit 01b57b5fa6793f97d11bf32ddeae640beade0cc4
Author: Bùi Thành Nhân <hi@imnhan.com>
Date:   Fri Jan 22 16:29:10 2021 +0700

    expose is_webtoon field to client

diff --git a/pyproject.toml b/pyproject.toml
index bcb2885..dcb5d65 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "pytaku"
-version = "0.3.34"
+version = "0.3.35"
 description = "Self-hostable web-based manga reader"
 authors = ["Bùi Thành Nhân <hi@imnhan.com>"]
 license = "AGPL-3.0-only"
diff --git a/src/pytaku/database/common.py b/src/pytaku/database/common.py
index 1bc6095..8624c5a 100644
--- a/src/pytaku/database/common.py
+++ b/src/pytaku/database/common.py
@@ -10,12 +10,19 @@ def _row_trace(cursor, row):
     Customize each result row's representation:
     - If query only asks for 1 field, return that result directly instead of tuple
     - If more than 1 field, return dict instead of tuple
+    - Because SQLite stores booleans as 0 or 1, convert them to proper python bools
     """
     desc = cursor.getdescription()
     if len(desc) == 1:
         return row[0]
     else:
-        return {k[0]: row[i] for i, k in enumerate(desc)}
+        result = {}
+        for i, (col_name, col_type) in enumerate(desc):
+            value = row[i]
+            if col_type == "boolean":
+                value = bool(value)
+            result[col_name] = value
+        return result
 
 
 def get_conn():
diff --git a/src/pytaku/main.py b/src/pytaku/main.py
index 25bec95..88e51d1 100644
--- a/src/pytaku/main.py
+++ b/src/pytaku/main.py
@@ -294,6 +294,7 @@ def api_chapter(site, title_id, chapter_id):
     chapter["prev_chapter"] = prev_chapter
     chapter["next_chapter"] = next_chapter
     chapter["site"] = site
+    chapter["is_webtoon"] = title["is_webtoon"]
     return chapter