This commit is contained in:
2026-02-08 13:08:00 +01:00
parent 67e320287a
commit 1219f840c6
2 changed files with 182 additions and 33 deletions

View File

@@ -0,0 +1,124 @@
import pymysql
import qbittorrentapi
from datetime import datetime
# ============================================================
# CONFIG
# ============================================================
QBT_URL = "https://vladob.zen.usbx.me/qbittorrent"
QBT_USER = "vladob"
QBT_PASS = "jCni3U6d#y4bfcm"
DB_CONFIG = {
"host": "192.168.1.50",
"port": 3306,
"user": "root",
"password": "Vlado9674+",
"database": "torrents",
"charset": "utf8mb4",
"autocommit": True,
}
# ============================================================
# CONNECT
# ============================================================
def connect_qbt():
qbt = qbittorrentapi.Client(
host=QBT_URL,
username=QBT_USER,
password=QBT_PASS,
VERIFY_WEBUI_CERTIFICATE=False
)
qbt.auth_log_in()
return qbt
def connect_db():
return pymysql.connect(**DB_CONFIG)
# ============================================================
# MAIN AUDIT
# ============================================================
def main():
print("🔎 UltraCC → DB COMPLETION AUDIT")
print("READ ONLY MODE")
print("------------------------------------------------")
qbt = connect_qbt()
db = connect_db()
cursor = db.cursor()
torrents = qbt.torrents_info()
total_completed = 0
not_in_db = 0
db_no_completion = 0
db_completed = 0
for t in torrents:
# Only completed torrents
if not t.completion_on:
continue
total_completed += 1
thash = t.hash.lower()
name = t.name
completion_dt = datetime.fromtimestamp(t.completion_on)
# ---------------------------------------------
# Query DB
# ---------------------------------------------
cursor.execute("""
SELECT qb_completed_datetime
FROM torrents
WHERE torrent_hash = %s
""", (thash,))
row = cursor.fetchone()
# ---------------------------------------------
# Status classification
# ---------------------------------------------
if not row:
status = "❌ NOT_IN_DB"
not_in_db += 1
elif row[0] is None:
status = "⚠ DB_NO_COMPLETION"
db_no_completion += 1
else:
status = "✅ DB_COMPLETED"
db_completed += 1
# ---------------------------------------------
# Output
# ---------------------------------------------
print(f"{status} | {name}")
print(f" Hash: {thash}")
print(f" UltraCC completion: {completion_dt}")
if row and row[0]:
print(f" DB completion : {row[0]}")
print()
# =================================================
# SUMMARY
# =================================================
print("------------------------------------------------")
print("📊 SUMMARY")
print(f"Completed torrents in UltraCC : {total_completed}")
print(f"NOT IN DB : {not_in_db}")
print(f"DB WITHOUT COMPLETION : {db_no_completion}")
print(f"DB COMPLETED : {db_completed}")
print("------------------------------------------------")
if __name__ == "__main__":
main()