From 80a9b4d565bece23db27fdcdd5a50153da09661c Mon Sep 17 00:00:00 2001 From: Asankilp Date: Sat, 24 Aug 2024 17:44:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9=EF=BC=8C=E6=8B=86=E5=88=86css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_acgnshow/acgnapis.py | 41 +++-- nonebot_plugin_acgnshow/config.py | 2 +- nonebot_plugin_acgnshow/res/css/style.css | 142 ++++++++++++++++ nonebot_plugin_acgnshow/res/template.html | 188 +--------------------- nonebot_plugin_acgnshow/util.py | 9 +- pyproject.toml | 2 +- 6 files changed, 171 insertions(+), 213 deletions(-) create mode 100644 nonebot_plugin_acgnshow/res/css/style.css diff --git a/nonebot_plugin_acgnshow/acgnapis.py b/nonebot_plugin_acgnshow/acgnapis.py index e93c4d8..098eb0e 100644 --- a/nonebot_plugin_acgnshow/acgnapis.py +++ b/nonebot_plugin_acgnshow/acgnapis.py @@ -1,4 +1,3 @@ -import json from typing import Dict from aiohttp import ClientSession @@ -59,26 +58,26 @@ async def get_shows_data(region_id: int, page=1, pagesize=20): return shows_data -def process_shows_data_to_text(shows_data: dict): - showlist = [] - 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"] - sale_flag = i["sale_flag"] - # start_time = i["start_time"] - start_unix = i["start_unix"] - start_time = convert_timestamp(start_unix) - end_time = i["end_time"] - price_low = i["price_low"] / 100 - price_high = i["price_high"] / 100 - district_name = i["district_name"] - text = f"名称:{name}\n举办地:{venue_name}\nid:{project_id}\nflag:{sale_flag}\n开始时间:{start_time}\n结束时间:{end_time}\n最低票价:{price_low}\n最高票价:{price_high}\n区名:{district_name}\n\n" - showlist.append(text) - return showlist +# def process_shows_data_to_text(shows_data: dict): +# showlist = [] +# 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"] +# sale_flag = i["sale_flag"] +# # start_time = i["start_time"] +# start_unix = i["start_unix"] +# start_time = convert_timestamp(start_unix) +# end_time = i["end_time"] +# price_low = i["price_low"] / 100 +# price_high = i["price_high"] / 100 +# district_name = i["district_name"] +# text = f"名称:{name}\n举办地:{venue_name}\nid:{project_id}\nflag:{sale_flag}\n开始时间:{start_time}\n结束时间:{end_time}\n最低票价:{price_low}\n最高票价:{price_high}\n区名:{district_name}\n\n" +# showlist.append(text) +# return showlist def process_shows_data_to_template(shows_data: dict): diff --git a/nonebot_plugin_acgnshow/config.py b/nonebot_plugin_acgnshow/config.py index 4f5f1e6..88327af 100644 --- a/nonebot_plugin_acgnshow/config.py +++ b/nonebot_plugin_acgnshow/config.py @@ -9,6 +9,6 @@ BGIMAGE_PATH = RES_PATH / "bgimage" class ConfigModel(BaseModel): acgnshow_pagesize: int = 8 - + acgnshow_bgimage_path: str = BGIMAGE_PATH config: ConfigModel = get_plugin_config(ConfigModel) diff --git a/nonebot_plugin_acgnshow/res/css/style.css b/nonebot_plugin_acgnshow/res/css/style.css new file mode 100644 index 0000000..5478aee --- /dev/null +++ b/nonebot_plugin_acgnshow/res/css/style.css @@ -0,0 +1,142 @@ +@font-face { + font-family: "Source Han Sans"; + src: url("SourceHanSans.otf") format("opentype"); +} + +body { + font-family: "Source Han Sans", sans-serif; +} + +.container, .header, .content, .footer, .details, .image { + border: 1px solid black; + box-sizing: border-box; +} + +.container { + width: 98%; + margin: 1%; + padding: 10px; + background-color: rgba(255, 255, 255, 0.8); +} + +.header, .designer { + text-align: center; + font-size: 10px; + font-weight: bold; + padding: 5px; + margin: 10px 0; +} + +.content { + display: flex; + margin-bottom: 10px; + padding: 5px; + position: relative; +} + +.image { + width: 149px; + height: 201px; + border: 1px solid rgba(128, 64, 128, 0.5); + text-align: center; +} + +.details { + flex: 1; + padding-left: 10px; + display: flex; + flex-direction: column; + font-size: 10px; + position: relative; +} + +.details .title { + font-weight: bold; + margin-bottom: 5px; +} + +.details .venue_name, +.details .guests, +.details .placeholder, +.details .price, +.details .wish, +.details .start-time, +.details .end-time { + margin-bottom: 5px; +} + +.details .sale_flag, +.details .id { + position: absolute; + font-size: 10px; +} + +.details .sale_flag { + color: red; + top: 5px; + right: 5px; +} + +.details .id { + top: 20px; + right: 5px; +} + +.details .price { + color: #fb7299; + font-weight: bold; + bottom: 5px; + left: 5px; +} + +.details .wish { + color: gray; + bottom: 5px; + left: 60px; +} + +.details .start-time { + bottom: 20px; + right: 5px; +} + +.details .end-time { + bottom: 5px; + right: 5px; +} + +.footer { + display: flex; + flex-direction: column; + justify-content: space-between; + font-size: 10px; + position: relative; +} + +.footer .pages, +.footer .total_results { + position: absolute; + font-size: 10px; +} + +.footer .pages { + bottom: 5px; + right: 5px; +} + +.footer .total_results { + bottom: 5px; + left: 5px; +} + +.footer .project_name { + font-size: 10px; + text-align: center; + color: rgb(50, 227, 227); +} + +.footer .notice_text { + font-size: 8px; + text-align: center; + color: slateblue; +} diff --git a/nonebot_plugin_acgnshow/res/template.html b/nonebot_plugin_acgnshow/res/template.html index 7e5fa9a..ed9cac2 100644 --- a/nonebot_plugin_acgnshow/res/template.html +++ b/nonebot_plugin_acgnshow/res/template.html @@ -4,195 +4,11 @@ Show Information + @@ -229,7 +45,7 @@ {{ global_data.page }} / {{ global_data.total_pages }} 页
nonebot-plugin-acgnshow
-
本页信息仅供参考,具体内容请访问展览官方详情页,并自行检索实际信息
+
本页信息仅供参考,具体内容请访问哔哩哔哩会员购,并自行检索实际信息
diff --git a/nonebot_plugin_acgnshow/util.py b/nonebot_plugin_acgnshow/util.py index f48b85c..6b779ca 100644 --- a/nonebot_plugin_acgnshow/util.py +++ b/nonebot_plugin_acgnshow/util.py @@ -1,16 +1,17 @@ import os import random import datetime - -from .config import BGIMAGE_PATH +from pathlib import Path +from .config import config def choose_random_bgimage() -> str: """ 从背景图片文件夹中随机选择一张图片,返回图片的uri地址 """ - randomfile = random.choice(os.listdir(BGIMAGE_PATH)) - randomurl = (BGIMAGE_PATH / randomfile).as_uri() + bgpath = Path(config.acgnshow_bgimage_path) + randomfile = random.choice(os.listdir(bgpath)) + randomurl = (bgpath / randomfile).as_uri() return randomurl diff --git a/pyproject.toml b/pyproject.toml index 5d6b808..0a35721 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nonebot-plugin-acgnshow" -version = "0.1.5" +version = "0.1.5.1" description = "Nonebot2插件,从哔哩哔哩会员购获取简易展览数据" readme = "README.md" requires-python = "<4.0,>=3.9"