|
@@ -1,5 +1,6 @@
|
|
|
#!/usr/bin/env python3
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
+import logging
|
|
|
import math
|
|
|
import sys
|
|
|
from functools import cmp_to_key
|
|
@@ -78,8 +79,37 @@ class MetaBooks(ListHandler):
|
|
|
except:
|
|
|
size = 60
|
|
|
delta = min(max(size, 60), 100)
|
|
|
+ title = titles.get(meta, _(u"未知")) % vars()
|
|
|
+
|
|
|
+ from webserver import constants
|
|
|
+ if meta == "tag" and name == "豆瓣Top250" and len(constants.TOP_250) > 0:
|
|
|
+ book_names = constants.TOP_250[start:start + delta]
|
|
|
+ ids = []
|
|
|
+ for book_name in book_names:
|
|
|
+ ids_tmp = self.cache.search("title:%s" % book_name)
|
|
|
+ if len(ids_tmp) > 0:
|
|
|
+ ids.append(list(ids_tmp)[0])
|
|
|
+ else:
|
|
|
+ logging.info("%s not found in the lib", book_name)
|
|
|
+
|
|
|
+ # 按照id顺序进行排序。
|
|
|
+ books = self.get_books(ids=ids)
|
|
|
+ hbs = {}
|
|
|
+ hb_list = []
|
|
|
+ for b in books:
|
|
|
+ hbs[b["id"]] = b
|
|
|
+ for idx in ids:
|
|
|
+ if idx in hbs:
|
|
|
+ hb_list.append(hbs[idx])
|
|
|
+ books = hb_list
|
|
|
+
|
|
|
+ return {
|
|
|
+ "err": "ok",
|
|
|
+ "title": title,
|
|
|
+ "total": 250,
|
|
|
+ "books": [self.fmt(b) for b in books],
|
|
|
+ }
|
|
|
|
|
|
- title = titles.get(meta, _(u"未知")) % vars() # noqa: F841
|
|
|
category = meta + "s" if meta in ["tag", "author"] else meta
|
|
|
if meta in ["rating"]:
|
|
|
try:
|