z230
This commit is contained in:
71
22 stat test posledniho clanku.py
Normal file
71
22 stat test posledniho clanku.py
Normal file
@@ -0,0 +1,71 @@
|
||||
import nntplib
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from db import get_conn
|
||||
|
||||
# ================== CONFIG ==================
|
||||
GROUP = "alt.binaries.e-book.magazines"
|
||||
SUBJECT_KEY = "PC Pro 2011-07.pdf"
|
||||
# ============================================
|
||||
|
||||
load_dotenv()
|
||||
|
||||
EWEKA_USER = os.getenv("EWEKA_USER")
|
||||
EWEKA_PASS = os.getenv("EWEKA_PASS")
|
||||
|
||||
print("🔌 Connecting to PostgreSQL...")
|
||||
conn = get_conn()
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute("""
|
||||
SELECT article_number
|
||||
FROM articles
|
||||
WHERE newsgroup = %s
|
||||
AND metadata->>'subject' LIKE %s
|
||||
ORDER BY article_number
|
||||
""", (GROUP, f"%{SUBJECT_KEY}%"))
|
||||
|
||||
article_numbers = [row[0] for row in cur.fetchall()]
|
||||
total = len(article_numbers)
|
||||
|
||||
print(f"📦 Found {total} parts in DB")
|
||||
|
||||
if total == 0:
|
||||
print("❌ No articles found, aborting.")
|
||||
exit(1)
|
||||
|
||||
print("🔌 Connecting to Eweka NNTP...")
|
||||
with nntplib.NNTP_SSL(
|
||||
"news.eweka.nl",
|
||||
563,
|
||||
EWEKA_USER,
|
||||
EWEKA_PASS,
|
||||
readermode=True,
|
||||
) as nntp:
|
||||
|
||||
nntp.group(GROUP)
|
||||
|
||||
existing = []
|
||||
missing = []
|
||||
|
||||
for idx, art in enumerate(article_numbers, start=1):
|
||||
try:
|
||||
nntp.stat(art)
|
||||
existing.append(art)
|
||||
print(f"✅ [{idx}/{total}] EXISTS article {art}")
|
||||
except Exception:
|
||||
missing.append(art)
|
||||
print(f"❌ [{idx}/{total}] MISSING article {art}")
|
||||
|
||||
print("\n================ RESULT ================")
|
||||
print(f"Total parts : {total}")
|
||||
print(f"Existing : {len(existing)}")
|
||||
print(f"Missing : {len(missing)}")
|
||||
|
||||
if existing:
|
||||
print("\nExisting article_numbers:")
|
||||
print(existing)
|
||||
|
||||
if missing:
|
||||
print("\nMissing article_numbers (first 20):")
|
||||
print(missing[:20])
|
||||
Reference in New Issue
Block a user