Repos / pytaku / faef51c459
commit faef51c459c0938c5686f458be54ac04722fc63e
Author: Bùi Thành Nhân <hi@imnhan.com>
Date: Sun May 23 00:36:45 2021 +0700
show mangasee titles first
Stopgap measure until I actually implement the new mangadex API.
diff --git a/src/pytaku/persistence.py b/src/pytaku/persistence.py
index 3747a16..0144cbf 100644
--- a/src/pytaku/persistence.py
+++ b/src/pytaku/persistence.py
@@ -272,7 +272,16 @@ def get_followed_titles(user_id):
t["chapters"] = chapters
- return sorted(titles, key=lambda t: len(t["chapters"]), reverse=True)
+ def sort_key_func(title):
+ """
+ Prioritize titles that:
+ - Have unread chapters
+ - Are from mangasee (because mangadex is currently broken)
+ """
+ has_chapters = 1 if len(title["chapters"]) > 0 else 0
+ return (has_chapters, title["site"])
+
+ return sorted(titles, key=sort_key_func, reverse=True)
def read(user_id, site, title_id, chapter_id):