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"