添加了更多的主题, 修复了输入不存在主题时报错

This commit is contained in:
MarkusJoe
2022-02-09 16:20:53 +08:00
parent 494cc7fea2
commit baf99a905c
317 files changed
+111 -324

No files matched your search

-42
View File
@@ -1,42 +0,0 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/3
# @File Name: base2img.py
import base64
import os
def convert_single() -> None:
"""
:return:
"""
# image转base64
with open(f'../../static/example.png', 'rb') as f:
base64_data = base64.b64encode(f.read())
base64_code = 'data:image/jpeg;base64,' + base64_data.decode('utf-8')
print(base64_code)
def convert_multi() -> None:
"""
:return:
"""
file_list = os.listdir('../res/images')
dict_count = 0
img_dict = {}
for i in file_list:
with open(f'../res/images/theme2{i}', 'rb') as f:
base64_data = base64.b64encode(f.read())
base64_code = 'data:image/svg+xml;base64,' + base64_data.decode('utf-8')
img_dict[str(dict_count)] = base64_code
dict_count += 1
print(img_dict)
convert_multi()
-7
View File
@@ -1,7 +0,0 @@
import sqlite3
conn = sqlite3.connect('../assets/theme.db')
cursor = conn.cursor()
cursor.execute('select * from sqlite_master where type="table"')
data = cursor.fetchall()
print(data)
+25
View File
@@ -0,0 +1,25 @@
import base64
from PIL import Image
import os
import sqlite3
conn = sqlite3.connect('../assets/theme.db')
cursor = conn.cursor()
file_list = os.listdir('../assets/themes/')
for i in file_list:
img = Image.open(f'../assets/themes/{i}/0.gif')
w = img.width
h = img.height
img.close()
for n in range(0, 10):
with open(f'../assets/themes/{i}/{n}.gif', 'rb') as f:
base64_data = base64.b64encode(f.read())
base64_code = f'data:image/gif;base64,' + base64_data.decode('utf-8')
try:
cursor.execute('insert into %(name)s values(?, ?, ?, ?)' % {'name': i}, (n, base64_code, w, h))
conn.commit()
except Exception:
cursor.execute('create table %(name)s (k text, v text, w integer, h integer)' % {'name': i})
-31
View File
@@ -1,31 +0,0 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/8
# @File Name: download_img.py
import os
import requests
import threading
proxies = {
'http': '127.0.0.1:8889',
'https': '127.0.0.1:8889'
}
def thread_(i, main_url, dir):
res = requests.get(f'{main_url}/{i}.gif', proxies=proxies)
with open(f'../assets/themes/{dir}/{i}.gif', 'wb') as f:
f.write(res.content)
while True:
url = input('->')
url = url.replace('https://', '|')
url = ''.join(url.split('/')[:-2]).replace('|', 'https://') + '/counter'
dir = url.split('.')[0].split('//')[-1]
os.mkdir(f'../assets/themes/{dir}')
for i in range(0, 10):
threading.Thread(target=thread_, args=(i, url, dir)).start()
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/7
# @File Name: dump_theme_db.py
import os
import base64
import sqlite3
conn = sqlite3.connect('../assets/theme.db')
cursor = conn.cursor()
dir_name = 'gelbooru-h'
file_list = os.listdir(f'../assets/themes/moe_theme/{dir_name}')
dict_count = 0
img_dict = {}
for i in file_list:
with open(f'../assets/themes/moe_theme/{dir_name}/{i}', 'rb') as f:
base64_data = base64.b64encode(f.read())
base64_code = f'data:image/jpeg;base64,' + base64_data.decode('utf-8')
img_dict[str(dict_count)] = base64_code
dict_count += 1
for k, v in zip(img_dict.keys(), img_dict.values()):
cursor.execute("insert into gelbooruh values(?, ?)", (k, v))
conn.commit()
-30
View File
@@ -1,30 +0,0 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/8
# @File Name: img_size.py
import os
from PIL import Image
import sqlite3
def get_info(path, file):
for i in path:
img = Image.open(f'../assets/themes/{path}/{file}')
imgSize = img.size
w = img.width
h = img.height
f = img.format
print(imgSize)
print(w, h, f)
file_list = os.listdir('../assets/themes/')
for p in file_list:
lst = os.listdir(f'../assets/themes/{p}')
for i in lst:
get_info(p, i)
-16
View File
@@ -1,16 +0,0 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/3
# @File Name: numberlen.py
number = 1576451745
if len(str(number)) <= 10:
zero_count = 10 - len(str(number))
final_str = '0' * zero_count + str(number)
print(final_str[9])
else:
print('Too much to count')
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/3
# @File Name: resp_test.py
import requests
import random
def request_test() -> None:
"""
请求测试
:return:
"""
for i in range(100):
resp = requests.get(f'http://127.0.0.1:8000/API?name={i}')
print(resp)
def download_test() -> None:
"""
下载测试
:return:
"""
resp = requests.get('https://count.getloli.com/get/@Moe-counter.github')
with open('download_test.html', 'wb') as fp:
fp.write(resp.content)
request_test()
-11
View File
@@ -1,11 +0,0 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/4
# @File Name: timetest.py
import time
print(time.ctime())