Archived
增加更多主题选择并修复了bug
This commit is contained in:
353 files changed
+1359
-1185
No files matched your search
+11
-11
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/3
|
||||
# @File Name: __init__.py.py
|
||||
|
||||
import sys
|
||||
|
||||
sys.stdout.write('\033[1;31m请不要调用此目录下的任何文件! 此目录文件仅作测试用!\033[0m')
|
||||
sys.exit(-1)
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/3
|
||||
# @File Name: __init__.py.py
|
||||
|
||||
import sys
|
||||
|
||||
sys.stdout.write('\033[1;31m请不要调用此目录下的任何文件! 此目录文件仅作测试用!\033[0m')
|
||||
sys.exit(-1)
|
||||
+41
-41
@@ -1,42 +1,42 @@
|
||||
#!/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)
|
||||
|
||||
|
||||
#!/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()
|
||||
@@ -0,0 +1,7 @@
|
||||
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)
|
||||
@@ -1,6 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/8
|
||||
# @File Name: download_img.py
|
||||
#!/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
-29
@@ -1,29 +1,29 @@
|
||||
#!/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()
|
||||
#!/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
-6
@@ -1,6 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/8
|
||||
# @File Name: img_size.py
|
||||
#!/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)
|
||||
|
||||
|
||||
+26
-26
@@ -1,26 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/5
|
||||
# @File Name: init_db.py
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
while True:
|
||||
yes_or_no = input('该操作会将数据库初始化输入y继续:')
|
||||
if yes_or_no == 'y':
|
||||
os.remove('../../db/data.db')
|
||||
conn = sqlite3.connect('../../db/data.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('create table ReqCount (name text primary key, times integer )')
|
||||
sys.exit(0)
|
||||
elif yes_or_no == 'n':
|
||||
print('已取消')
|
||||
sys.exit(0)
|
||||
else:
|
||||
print('请输入y继续或n退出')
|
||||
continue
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/5
|
||||
# @File Name: init_db.py
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
while True:
|
||||
yes_or_no = input('该操作会将数据库初始化输入y继续:')
|
||||
if yes_or_no == 'y':
|
||||
os.remove('../../db/data.db')
|
||||
conn = sqlite3.connect('../../db/data.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('create table ReqCount (name text primary key, times integer )')
|
||||
sys.exit(0)
|
||||
elif yes_or_no == 'n':
|
||||
print('已取消')
|
||||
sys.exit(0)
|
||||
else:
|
||||
print('请输入y继续或n退出')
|
||||
continue
|
||||
+15
-15
@@ -1,16 +1,16 @@
|
||||
#!/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:
|
||||
#!/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')
|
||||
+32
-32
@@ -1,33 +1,33 @@
|
||||
#!/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)
|
||||
|
||||
|
||||
#!/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()
|
||||
+12
-12
@@ -1,13 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/7
|
||||
# @File Name: stress_test.py
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
for i in range(100):
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/7
|
||||
# @File Name: stress_test.py
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
for i in range(100):
|
||||
print(requests.get('http://127.0.0.1:5000/API?name=89999&length=10&theme=t2').elapsed.microseconds)
|
||||
+10
-10
@@ -1,11 +1,11 @@
|
||||
#!/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
|
||||
|
||||
|
||||
#!/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())
|
||||
Reference in New Issue
Block a user