Сезоны и эпизоды в графе, график десятилетий на панели
Сериалы разложены до сезонов: сериал → сезон «содержит» с числом эпизодов, сезон → эпоха. Данные из Sonarr (/api/v3/episode?seriesId), агрегация по номеру сезона. 19 сезонных карточек, граф 486/530. Команда «сезоны Foundation» и GET /seasons. На панели — график «фантастика по десятилетиям» с полосками. Ловушка: выходящие сериалы дают неполные сезоны (Foundation, сезон 4 — 1 эпизод), из-за чего счётчик сезонов завышен.
This commit is contained in:
1 parent
d58a1b1e3b
commit
ea5a211d7e
5 files changed
+176
No files matched your search
@@ -46,6 +46,26 @@ class MediaBot(Bot):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def _seasons_cmd(self, arg):
|
||||
name = (arg or "").strip()
|
||||
if not name:
|
||||
return "Укажите сериал: !сезоны Foundation"
|
||||
data, err = core_api.seasons(name)
|
||||
if err:
|
||||
return "Ядро не ответило: " + str(err)
|
||||
if not data:
|
||||
return "Сериал не нашёл."
|
||||
series = data.get("series") or {}
|
||||
seasons = data.get("seasons") or []
|
||||
lines = ["**" + str(series.get("title")) + "** — сезонов: " + str(len(seasons)), ""]
|
||||
for s in seasons:
|
||||
lines.append("• " + str(s.get("title")) + " — " + str(s.get("status")))
|
||||
if not seasons:
|
||||
lines.append("_сезонов нет_")
|
||||
return chr(10).join(lines)
|
||||
|
||||
def _together_cmd(self, arg):
|
||||
name = (arg or "").strip()
|
||||
if not name:
|
||||
@@ -451,6 +471,7 @@ class MediaBot(Bot):
|
||||
self.cmd("настроение", "подбор по настроению: !настроение мрачное")(lambda a: self._mood_cmd(a))
|
||||
self.cmd("пополнить", "добавить кандидатов в медиатеку: !пополнить 3")(lambda a: self._fill_cmd(a))
|
||||
self.cmd("вместе", "с кем снимался: !вместе Zendaya")(lambda a: self._together_cmd(a))
|
||||
self.cmd("сезоны", "сезоны сериала: !сезоны Foundation")(lambda a: self._seasons_cmd(a))
|
||||
def _stats(self, jf):
|
||||
c = jf.counts()
|
||||
info, _ = jf.info()
|
||||
|
||||
@@ -161,3 +161,7 @@ def suggest(q, limit=8):
|
||||
|
||||
def history(days=30):
|
||||
return _get("/history", {"days": days})
|
||||
|
||||
|
||||
def seasons(query):
|
||||
return _get("/seasons", {"q": query})
|
||||
Reference in new issue
Block a user