From b5525ce66296673361f9e69a5a7ab0bd9144f51e Mon Sep 17 00:00:00 2001 From: Asankilp Date: Thu, 8 Aug 2024 20:50:18 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8v0.1.4.2,=E5=9C=A8=E5=B1=95=E8=A7=88?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=AD=E6=98=BE=E7=A4=BA=E5=87=BA=E5=9C=BA?= =?UTF-8?q?=E5=98=89=E5=AE=BE=EF=BC=88=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=85=A8?= =?UTF-8?q?=EF=BC=9F=EF=BC=89=EF=BC=8C=E5=B1=95=E8=A7=88=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E7=B2=BE=E7=A1=AE=E5=88=B0=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_acgnshow/acgnapis.py | 17 +++++++++--- nonebot_plugin_acgnshow/res/template.html | 33 ++++++++++++++--------- nonebot_plugin_acgnshow/util.py | 7 ++++- pyproject.toml | 2 +- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/nonebot_plugin_acgnshow/acgnapis.py b/nonebot_plugin_acgnshow/acgnapis.py index 6c134b7..6039ee2 100644 --- a/nonebot_plugin_acgnshow/acgnapis.py +++ b/nonebot_plugin_acgnshow/acgnapis.py @@ -1,5 +1,6 @@ import json import requests +from .util import * CITY_API_ROOT="https://show.bilibili.com/api/ticket/city/list?channel=3" SHOWS_API_ROOT="https://show.bilibili.com/api/ticket/project/listV2" HEADERS = { @@ -54,7 +55,9 @@ def process_shows_data_to_text(shows_data: dict): venue_name = i["venue_name"] project_id = i["project_id"] sale_flag = i["sale_flag"] - start_time = i["start_time"] + #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 @@ -76,7 +79,9 @@ def process_shows_data_to_template(shows_data: dict): venue_name = i["venue_name"] project_id = i["project_id"] sale_flag = i["sale_flag"] - start_time = i["start_time"] + #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 @@ -84,6 +89,11 @@ def process_shows_data_to_template(shows_data: dict): wish = i["wish"] cover = "https:" + i["cover"] if district_name == None : district_name = "" + guests_list = i["guests"] + guests = "" + if guests_list != None: + for n in guests_list: + guests += n["name"] + "," item_dict = { "name": name, "location": district_name + venue_name, @@ -94,6 +104,7 @@ def process_shows_data_to_template(shows_data: dict): "end_time": end_time, "wish": wish, "image_url": cover, + "guests": guests, "page": page, "total_pages": total_pages } @@ -103,4 +114,4 @@ def process_shows_data_to_template(shows_data: dict): "total_pages": total_pages, "total_results": total_results } - return [showlist, global_data_dict] \ No newline at end of file + return [showlist, global_data_dict] diff --git a/nonebot_plugin_acgnshow/res/template.html b/nonebot_plugin_acgnshow/res/template.html index d447ae9..57030d8 100644 --- a/nonebot_plugin_acgnshow/res/template.html +++ b/nonebot_plugin_acgnshow/res/template.html @@ -11,7 +11,6 @@ body { font-family: 'Source Han Sans', sans-serif; background-image: url('{{ bgimage }}'); - } .background { position: fixed; @@ -19,7 +18,6 @@ left: 0; width: 100%; height: 100%; - /*background-image: url('{{ bgimage }}');*/ background-size: cover; filter: blur(40%); z-index: -1; @@ -53,7 +51,6 @@ height: 200px; border: 1px solid black; text-align: center; - /*padding: 10px; */ box-sizing: border-box; } .details { @@ -61,17 +58,29 @@ padding-left: 10px; display: flex; flex-direction: column; - justify-content: space-between; + justify-content: flex-start; position: relative; font-size: 10px; } .details .title { font-size: 10px; font-weight: bold; + margin-bottom: 5px; } .details .venue_name { font-size: 10px; font-weight: normal; + margin-bottom: 5px; + } + .details .guests { + font-size: 10px; + word-wrap: break-word; + white-space: pre-wrap; /* 自动换行 */ + margin-bottom: 5px; + } + .details .placeholder { + font-size: 10px; + margin-bottom: 5px; } .details .sale_flag { color: red; @@ -99,7 +108,7 @@ color: gray; position: absolute; bottom: 5px; - left: 60px; + left: 60px; } .details .start-time, .details .end-time { @@ -161,12 +170,12 @@ Image
-
-
{{ show.name }}
-
-
举办地点:{{ show.location }}
-
-
+
{{ show.name }}
+
举办地点:{{ show.location }}
+ {% if show.guests != "" %} +
嘉宾:{{ show.guests }}
+ {% endif %} +
{{ show.sale_flag }}
ID:{{ show.id }}
¥{{ show.price }}起
@@ -184,4 +193,4 @@
- + \ No newline at end of file diff --git a/nonebot_plugin_acgnshow/util.py b/nonebot_plugin_acgnshow/util.py index 69634a6..616963d 100644 --- a/nonebot_plugin_acgnshow/util.py +++ b/nonebot_plugin_acgnshow/util.py @@ -1,6 +1,11 @@ from .config import BGIMAGE_PATH import random +import datetime def choose_random_bgimage(): randomfile = random.choice(list(BGIMAGE_PATH.iterdir())) randomurl = randomfile.as_uri() - return randomurl \ No newline at end of file + return randomurl +def convert_timestamp(timestamp): + obj = datetime.datetime.fromtimestamp(timestamp) + formatted_time = obj.strftime('%Y-%m-%d %H:%M:%S') + return formatted_time diff --git a/pyproject.toml b/pyproject.toml index 6e98f8c..3e0b1bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nonebot-plugin-acgnshow" -version = "0.1.4.1" +version = "0.1.4.2" description = "Nonebot2插件,从哔哩哔哩会员购获取简易展览数据" readme = "README.md" requires-python = "<4.0,>=3.9"