From 612332e4ee4fe95d2064af76959dc38e23c6e705 Mon Sep 17 00:00:00 2001 From: Hell13Cat <46496367+Hell13Cat@users.noreply.github.com> Date: Tue, 26 May 2026 23:06:02 +0300 Subject: [PATCH] 0.0.2s --- .gitignore | 1 + run.py | 21 +-------------------- system_module/db.py | 23 ++++++++++++++++++++++- system_module/gelbooru.py | 22 +++++++++++----------- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 20a248b..8455a9f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # Secure data old/ config_gb.json +migration.py # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/run.py b/run.py index 5b34a45..78ebd35 100644 --- a/run.py +++ b/run.py @@ -106,23 +106,4 @@ def api(): if __name__ == "__main__": - app.run(host="0.0.0.0", port=CONFIG_PORT) - -exit() - -DB.append({ - "md5": item.get("md5"), - "local_filename": local_filename, - "thumb_url": thumb_url, - "is_video": is_video, - "is_gif": is_gif, - "found": item.get("found_on_gelbooru", False), - "tags": tags, - "rating": data.get("rating", "N/A"), - "score": data.get("score", 0), - "timestamp": timestamp, - "display_date": display_date, - "source": data.get("source", ""), - "width": data.get("width", 0), - "height": data.get("height", 0) -}) \ No newline at end of file + app.run(host="0.0.0.0", port=CONFIG_PORT) \ No newline at end of file diff --git a/system_module/db.py b/system_module/db.py index bba05af..4723c2b 100644 --- a/system_module/db.py +++ b/system_module/db.py @@ -2,6 +2,7 @@ from tinydb import TinyDB, Query import os import json from collections import Counter +import gelbooru class DB: def __init__(self): @@ -16,7 +17,27 @@ class DB: self.db.insert(data_add) def add_raw(self, data_add): - # self.db.insert(data_add) + is_video = False + is_gif = False + if data_add["image"].split(".")[-1] in ["webm", "mp4", "avi"]: + is_video = True + if data_add["image"].split(".")[-1] == "gif": + is_gif = True + add_data = { + "md5": data_add["md5"], + "local_filename": data_add["image"], + "is_video": is_video, + "is_gif": is_gif, + "tags": data_add["tags"].split(" "), + "rating": data_add["rating"], + "score": data_add["score"], + "timestamp": data_add["created_at"], + "display_date": gelbooru.gelbooru_date_parse(data_add["created_at"]), + "source": data_add["source"], + "width": data_add["width"], + "height": data_add["height"] + } + self.db.insert(add_data) pass def get_all(self): diff --git a/system_module/gelbooru.py b/system_module/gelbooru.py index a158221..217c545 100644 --- a/system_module/gelbooru.py +++ b/system_module/gelbooru.py @@ -1,6 +1,16 @@ import requests from datetime import datetime +def gelbooru_date_parse(date_str): + if not self.date_str: + return 0, "Unknown" + try: + dt = datetime.strptime(date_str, "%a %b %d %H:%M:%S %z %Y") + return dt.timestamp(), dt.strftime("%Y-%m-%d") + except Exception as e: + print(f"Ошибка парсинга даты '{date_str}': {e}") + return 0, "Unknown" + class GB: def __init__(self, api_id, api_hash, headers): self.api_id = api_id @@ -23,14 +33,4 @@ class GB: pass def get_binary_file(self, id_post): - pass - - def gelbooru_date_parse(self, date_str): - if not self.date_str: - return 0, "Unknown" - try: - dt = datetime.strptime(self.date_str, "%a %b %d %H:%M:%S %z %Y") - return dt.timestamp(), dt.strftime("%Y-%m-%d") - except Exception as e: - print(f"Ошибка парсинга даты '{self.date_str}': {e}") - return 0, "Unknown" \ No newline at end of file + pass \ No newline at end of file