0.0.2s
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
# Secure data
|
# Secure data
|
||||||
old/
|
old/
|
||||||
config_gb.json
|
config_gb.json
|
||||||
|
migration.py
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|||||||
@@ -107,22 +107,3 @@ def api():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0", port=CONFIG_PORT)
|
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)
|
|
||||||
})
|
|
||||||
+22
-1
@@ -2,6 +2,7 @@ from tinydb import TinyDB, Query
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
import gelbooru
|
||||||
|
|
||||||
class DB:
|
class DB:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -16,7 +17,27 @@ class DB:
|
|||||||
self.db.insert(data_add)
|
self.db.insert(data_add)
|
||||||
|
|
||||||
def add_raw(self, 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
|
pass
|
||||||
|
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
|
|||||||
+10
-10
@@ -1,6 +1,16 @@
|
|||||||
import requests
|
import requests
|
||||||
from datetime import datetime
|
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:
|
class GB:
|
||||||
def __init__(self, api_id, api_hash, headers):
|
def __init__(self, api_id, api_hash, headers):
|
||||||
self.api_id = api_id
|
self.api_id = api_id
|
||||||
@@ -24,13 +34,3 @@ class GB:
|
|||||||
|
|
||||||
def get_binary_file(self, id_post):
|
def get_binary_file(self, id_post):
|
||||||
pass
|
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"
|
|
||||||
Reference in New Issue
Block a user