merge from 3.0

This commit is contained in:
EstrellaXD
2023-06-13 22:05:34 +08:00
parent de832888ac
commit aa4dd9d768
2 changed files with 22 additions and 24 deletions

View File

@@ -1,6 +1,11 @@
import logging
from .plugin import *
from .plugin import (
TelegramNotification,
ServerChanNotification,
BarkNotification,
WecomNotification,
)
from module.models import Notification
from module.conf import settings
@@ -37,14 +42,8 @@ class PostNotification:
poster_path = db.match_poster(notify.official_title)
if poster_path:
poster_link = "https://mikanani.me" + poster_path
# text = f"""
# 番剧名称:{notify.official_title}\n季度: 第{notify.season}季\n更新集数: 第{notify.episode}集\n{poster_link}\n
# """
else:
poster_link = "https://mikanani.me"
# text = f"""
# 番剧名称:{notify.official_title}\n季度: 第{notify.season}季\n更新集数: 第{notify.episode}集\n
# """
notify.poster_path = poster_link
def send_msg(self, notify: Notification) -> bool:
@@ -62,12 +61,3 @@ class PostNotification:
def __exit__(self, exc_type, exc_val, exc_tb):
self.notifier.__exit__(exc_type, exc_val, exc_tb)
if __name__ == "__main__":
info = Notification(
official_title="魔法纪录 魔法少女小圆外传",
season=2,
episode=1,
)
with PostNotification() as client:
client.send_msg(info)

View File

@@ -43,7 +43,7 @@ def get_season(seasons: list) -> int:
for season in ss:
if re.search(r"第 \d 季", season.get("season")) is not None:
date = season.get("air_date").split("-")
[year, _ , _] = date
[year, _, _] = date
now_year = time.localtime().tm_year
if int(year) <= now_year:
return int(re.findall(r"\d", season.get("season"))[0])
@@ -64,16 +64,24 @@ def tmdb_parser(title, language) -> TMDBInfo | None:
break
url_info = info_url(id, language)
info_content = req.get_json(url_info)
season = [{"season": s.get("name"), "air_date": s.get("air_date"), "poster_path": s.get("poster_path")} for s in info_content.get("seasons")]
season = [
{
"season": s.get("name"),
"air_date": s.get("air_date"),
"poster_path": s.get("poster_path")
} for s in info_content.get("seasons")
]
last_season = get_season(season)
original_title = info_content.get("original_name")
official_title = info_content.get("name")
year_number = info_content.get("first_air_date").split("-")[0]
return TMDBInfo(id, official_title, original_title, season, last_season, str(year_number))
return TMDBInfo(
id,
official_title,
original_title,
season,
last_season,
str(year_number)
)
else:
return None
if __name__ == '__main__':
title = "海盗战记"
print(tmdb_parser(title, "zh").last_season)