This commit is contained in:
Nyako
2026-06-06 15:07:26 +03:00
parent 2c2aa65947
commit 21e37776f9
7 changed files with 61 additions and 66 deletions
+1
View File
@@ -7,6 +7,7 @@ tmp/
config_gb.json
migration.py
change_log.txt
up/
# Byte-compiled / optimized / DLL files
__pycache__/
+1 -1
View File
@@ -95,7 +95,7 @@ if (originalImageLinkElement) {
// Получаем настроенный пользователем корневой путь
const apiRoot = GM_getValue('nyakonya_gb_api_root', 'http://127.0.2.1');
// Формируем корректный URL для запроса к dw_api
const apiUrl = apiRoot.endsWith('/') ? `${apiRoot}dw_api` : `${apiRoot}/dw_api`;
const apiUrl = apiRoot.endsWith('/') ? `${apiRoot}dw_api` : `${apiRoot}/api`;
console.log(`Отправка URL на локальный API: ${imageUrl} (Endpoint: ${apiUrl})`);
const originalOutline = newDownloadButton.style.outline;
+29
View File
@@ -0,0 +1,29 @@
### 0.2.0b
> **Fixes**
1. Added 404 error handling when the source file is not found.
> **Changes**
1. Merged `/dw_api` and `/api` into a single `/api` endpoint.
> **New**
1. Added a system module for background tasks.
2. Added an analytics page.
> **Code**
1. Deleted the legacy `db_old.py` file.
2. Sorted and refactored imports.
3. Added type hinting for input data in `system_module` functions.
4. Removed `data/analytic.json`.
5. Updated the logic for retrieving popular tags to support analytics.
- 5.1. Renamed `get_autocomplete` function to `get_top_tags`.
- 5.2. Added an optional `limit` argument to the `get_top_tags` function.
6. Removed the `get_binary_file()` function from the `gelbooru` module as it was unused.
7. Refactored the logging module.
8. Added comprehensive error logging.
9. Added the `/task` endpoint.
10. Implemented new logic for passing the database path via the configuration file.
+29
View File
@@ -0,0 +1,29 @@
### 0.2.0b
> **Иправления**
1. Добавлен вывод 404 если исходный файл не найден
> **Изменения**
1. /dw_api и /api объединены в /api
> **Новое**
1. Системный модуль с задачами
2. Страница с аналитикой
> **Код**
1. Удалён старый файл db_old.py
2. Отсортированы и изменены импорты
3. Добавлена типизация входных данных в функции расположенные в system_module
4. Удалён data/analytic.json
5. Изменена логика получения списка популярных тегов для адаптации к аналитике
- 5.1. Функция get_autocomplete переименована в get_top_tag
- 5.1. Для функции get_top_tag добален необязательный аргумент для лимита выдачи
6. Функция get_binary_file() из модуля gelbooru удалена из-за отсусвия факта использования
7. Переписан модуль логов
8. Добавлено полное логирование ошибок
9. Добавлен эндпойнт /task
10. Новая логика передачи пути к базе данных через конфиг
+1 -1
View File
@@ -11,7 +11,7 @@ def find_file(filename: str, file_folders: list[str], is_folder: bool = True):
return str(folder_path) if is_folder else str(file_path)
return None
def get_size_format(b, factor=1024, suffix="B"):
def get_size_format(b: int, factor=1024, suffix="B"):
for unit in ["", "K", "M", "G", "T"]:
if b < factor:
return f"{b:.2f} {unit}{suffix}"
-5
View File
@@ -1,5 +0,0 @@
{
"host":"https://git.nekono.su",
"user":"Nyako",
"repo":"Local-Booru"
}
-59
View File
@@ -1,59 +0,0 @@
import os
import json
import shutil
import tempfile
import zipfile
import urllib.request
CONFIG_PATH = os.path.join(os.path.dirname(__file__), "config.json")
EXCLUDE_PATHS = {
"data",
"config.json",
"logs.log",
"updater"
}
def load_config():
with open(CONFIG_PATH, "r", encoding="utf-8") as f:
return json.load(f)
def get_latest_release(cfg):
url = f"{cfg['host']}/api/v1/repos/{cfg['user']}/{cfg['repo']}/releases/latest"
with urllib.request.urlopen(url) as r:
return json.loads(r.read().decode("utf-8"))
def download(url, path):
urllib.request.urlretrieve(url, path)
def should_exclude(relative_path: str) -> bool:
parts = set(relative_path.split(os.sep))
return any(ex in parts for ex in EXCLUDE_PATHS)
def apply_update(src_root, target_root):
for root, dirs, files in os.walk(src_root):
rel_dir = os.path.relpath(root, src_root)
if rel_dir == ".":
rel_dir = ""
for file in files:
rel_path = os.path.normpath(os.path.join(rel_dir, file))
if should_exclude(rel_path):
continue
src_file = os.path.join(root, file)
dst_file = os.path.join(target_root, rel_path)
os.makedirs(os.path.dirname(dst_file), exist_ok=True)
shutil.copy2(src_file, dst_file)
cfg = load_config()
release = get_latest_release(cfg)
zip_url = release["zipball_url"]
tmp = tempfile.mkdtemp()
zip_path = os.path.join(tmp, "release.zip")
print("Downloading:", release["tag_name"])
download(zip_url, zip_path)
with zipfile.ZipFile(zip_path, "r") as z:
z.extractall(tmp)
extracted_root = os.path.join(tmp, os.listdir(tmp)[0])
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
apply_update(extracted_root, project_root)
print("Update success!")