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 %} -