From 7b972fe59f8a1981b18758f5378997d444194fd6 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Sat, 13 Jul 2024 12:38:28 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A80.1.4=EF=BC=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=A1=B5=E7=A0=81=EF=BC=8C=E6=80=BB=E6=9D=A1=E7=9B=AE=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E9=A1=B9=E7=9B=AE=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_acgnshow/acgnapis.py | 27 +++++++++++---- nonebot_plugin_acgnshow/acgnshower.py | 6 ++-- nonebot_plugin_acgnshow/res/template.html | 42 +++++++++++++++++++++-- pyproject.toml | 4 +-- 4 files changed, 66 insertions(+), 13 deletions(-) diff --git a/nonebot_plugin_acgnshow/acgnapis.py b/nonebot_plugin_acgnshow/acgnapis.py index 435e604..6c134b7 100644 --- a/nonebot_plugin_acgnshow/acgnapis.py +++ b/nonebot_plugin_acgnshow/acgnapis.py @@ -46,7 +46,10 @@ def get_shows_data(region_id: int, page=1, pagesize=20): return shows_data def process_shows_data_to_text(shows_data: dict): showlist = [] - for i in shows_data["data"]["result"]: + data = shows_data["data"] + total_pages = data["numPages"] + result = data["result"] + for i in result: name = i["project_name"] venue_name = i["venue_name"] project_id = i["project_id"] @@ -62,8 +65,13 @@ def process_shows_data_to_text(shows_data: dict): def process_shows_data_to_template(shows_data: dict): showlist = [] + data = shows_data["data"] + page = data["page"] + total_pages = data["numPages"] + total_results = data["total"] + result = data["result"] # show_template = read_template_file('/home/asankilp/LiteyukiBot/src/plugins/acgnshow/res/template.html') - for i in shows_data["data"]["result"]: + for i in result: name = i["project_name"] venue_name = i["venue_name"] project_id = i["project_id"] @@ -76,7 +84,7 @@ def process_shows_data_to_template(shows_data: dict): wish = i["wish"] cover = "https:" + i["cover"] if district_name == None : district_name = "" - dicts = { + item_dict = { "name": name, "location": district_name + venue_name, "sale_flag": sale_flag, @@ -85,7 +93,14 @@ def process_shows_data_to_template(shows_data: dict): "start_time": start_time, "end_time": end_time, "wish": wish, - "image_url": cover + "image_url": cover, + "page": page, + "total_pages": total_pages } - showlist.append(dicts) - return showlist \ No newline at end of file + showlist.append(item_dict) + global_data_dict = { + "page": page, + "total_pages": total_pages, + "total_results": total_results + } + return [showlist, global_data_dict] \ No newline at end of file diff --git a/nonebot_plugin_acgnshow/acgnshower.py b/nonebot_plugin_acgnshow/acgnshower.py index d251133..4233714 100644 --- a/nonebot_plugin_acgnshow/acgnshower.py +++ b/nonebot_plugin_acgnshow/acgnshower.py @@ -37,9 +37,11 @@ async def find_show( shows = get_shows_data(regionid,page=page,pagesize=config.acgnshow_pagesize) # print(shows) try: + showsdata = process_shows_data_to_template(shows) template = { - "shows":process_shows_data_to_template(shows), - "bgimage": choose_random_bgimage() + "shows": showsdata[0], + "bgimage": choose_random_bgimage(), + "global_data": showsdata[1] } pic = await template_to_pic(RES_PATH,TEMPLATE_NAME,template) except: diff --git a/nonebot_plugin_acgnshow/res/template.html b/nonebot_plugin_acgnshow/res/template.html index 639fc0e..d447ae9 100644 --- a/nonebot_plugin_acgnshow/res/template.html +++ b/nonebot_plugin_acgnshow/res/template.html @@ -115,6 +115,41 @@ bottom: 5px; right: 5px; } + .footer { + border: 1px solid black; + flex: 1; + padding-left: 10px; + display: flex; + flex-direction: column; + justify-content: space-between; + position: relative; + font-size: 10px; + } + .footer .designer { + text-align: center; + font-weight: bold; + padding: 5px; + margin-bottom: 10px; + margin-top: 10px; + } + .footer .pages { + position: absolute; + bottom: 5px; + right: 5px; + font-size: 10px; + } + .footer .total_results { + position: absolute; + bottom: 5px; + left: 5px; + font-size: 10px; + } + .footer .project_name { + position: relative; + font-size: 10px; + text-align: center; + color: rgb(50, 227, 227); + } @@ -141,8 +176,11 @@ {% endfor %} -
- Designed by Asankilp? +
diff --git a/pyproject.toml b/pyproject.toml index d6824a8..a763320 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nonebot-plugin-acgnshow" -version = "0.1.3.2" +version = "0.1.4" description = "Nonebot2插件,从哔哩哔哩会员购获取简易展览数据" readme = "README.md" requires-python = "<4.0,>=3.9" @@ -11,8 +11,6 @@ dependencies = [ "nonebot2>=2.2.0", "nonebot-plugin-alconna>=0.48.0", "nonebot-plugin-htmlrender>=0.3.2", - "nonebot-adapter-satori>=0.12", - "nonebot-adapter-onebot>=2.4.3", "jinja2>=3.1.4", "requests>=2.32.3" ]