This commit is contained in:
Hell13Cat
2026-05-26 23:06:02 +03:00
parent 270be38d1e
commit 612332e4ee
4 changed files with 35 additions and 32 deletions
+22 -1
View File
@@ -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):
+11 -11
View File
@@ -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"
pass