This repository has been archived on 2026-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
RequestCounter/bin/core/b64img.py
T

76 lines
2.4 KiB
Python
Raw Normal View History

2022-02-03 20:02:38 +08:00
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/3
# @File Name: b64img.py
2022-02-07 17:24:01 +08:00
import sqlite3
def re_sort_number_image(origin_number: str, theme: str) -> list:
2022-02-03 20:02:38 +08:00
"""
2022-02-04 11:08:34 +08:00
返回一个排列好的svg base64代码列表
2022-02-07 17:24:01 +08:00
:param theme:
2022-02-04 11:08:34 +08:00
:param origin_number:
2022-02-03 20:02:38 +08:00
:return:
"""
2022-02-07 22:11:56 +08:00
print(theme)
2022-02-07 17:24:01 +08:00
if theme == 't1':
cursor.execute('select * from theme1')
elif theme == 't2':
cursor.execute('select * from theme2')
2022-02-07 22:11:56 +08:00
elif theme == 'gelbooru':
cursor.execute('select * from gelbooru')
elif theme == 'gelbooru-h':
cursor.execute('select * from gelbooruh')
elif theme == 'moebooru':
cursor.execute('select * from moebooru')
elif theme == 'moebooru-h':
cursor.execute('select * from moebooruh')
elif theme == 'rule34':
cursor.execute('select * from rule34')
2022-02-07 17:24:01 +08:00
else:
2022-02-07 22:11:56 +08:00
cursor.execute('select * from rule34')
data = cursor.fetchall()
2022-02-07 17:24:01 +08:00
temp_dict = {}
for k, v in data:
temp_dict.setdefault(k, []).append(v)
for i, c in zip(temp_dict.keys(), temp_dict.values()):
temp_dict[i] = c[0]
2022-02-03 20:02:38 +08:00
2022-02-04 11:08:34 +08:00
final_b64_img_code = []
2022-02-04 11:56:21 +08:00
if origin_number != '0000000000':
for i in origin_number:
2022-02-04 11:58:58 +08:00
if i == '0':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:58:58 +08:00
elif i == '1':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:58:58 +08:00
elif i == '2':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:58:58 +08:00
elif i == '3':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:58:58 +08:00
elif i == '4':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:58:58 +08:00
elif i == '5':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:58:58 +08:00
elif i == '6':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:58:58 +08:00
elif i == '7':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:58:58 +08:00
elif i == '8':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:58:58 +08:00
elif i == '9':
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(i)))
2022-02-04 11:08:34 +08:00
2022-02-04 11:56:21 +08:00
return final_b64_img_code
else:
for i in range(10):
2022-02-07 17:24:01 +08:00
final_b64_img_code.append(temp_dict.get(str(0)))
2022-02-04 11:56:21 +08:00
return final_b64_img_code
2022-02-07 17:24:01 +08:00
if __name__ != '__main__':
2022-02-07 22:11:56 +08:00
conn = sqlite3.connect('./bin/assets/theme.db')
cursor = conn.cursor()