proxy_finder: tach loai/chat luong dung Save-As (dat ten file), nhap nhieu file 1 lan
Browse files- proxy_finder.py +27 -18
proxy_finder.py
CHANGED
|
@@ -405,14 +405,19 @@ class App:
|
|
| 405 |
|
| 406 |
def on_import(self):
|
| 407 |
if self.running: return
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
|
| 417 |
def on_run(self):
|
| 418 |
if self.running: return
|
|
@@ -477,20 +482,22 @@ class App:
|
|
| 477 |
alive = [r for r in alive if r.get("q") == QFILTER.get(qf)]
|
| 478 |
if not alive:
|
| 479 |
messagebox.showinfo("Chưa có", "Chưa có proxy để lưu."); return
|
| 480 |
-
|
| 481 |
-
|
|
|
|
| 482 |
return
|
|
|
|
| 483 |
c = {}
|
| 484 |
for typ in ("http", "socks5", "socks4"):
|
| 485 |
rows = sorted([r for r in alive if r["type"] == typ], key=lambda x: x["ms"])
|
| 486 |
c[typ] = len(rows)
|
| 487 |
if not rows:
|
| 488 |
continue
|
| 489 |
-
with open(
|
| 490 |
for r in rows:
|
| 491 |
f.write("%s://%s\n" % (r["type"], r["raw"]))
|
| 492 |
-
self.v_status.set("💾 Đã tách: http %d · socks5 %d · socks4 %d → %s"
|
| 493 |
-
% (c["http"], c["socks5"], c["socks4"],
|
| 494 |
|
| 495 |
def on_save_split_q(self):
|
| 496 |
alive = [r for r in self.rows if r.get("ok")]
|
|
@@ -499,9 +506,11 @@ class App:
|
|
| 499 |
alive = [r for r in alive if r["type"] == tf]
|
| 500 |
if not alive:
|
| 501 |
messagebox.showinfo("Chưa có", "Chưa có proxy để lưu."); return
|
| 502 |
-
|
| 503 |
-
|
|
|
|
| 504 |
return
|
|
|
|
| 505 |
names = {"rattot": "rattot", "tot": "tot", "tb": "trungbinh", "kem": "kem"}
|
| 506 |
c = {}
|
| 507 |
for qk, fn in names.items():
|
|
@@ -509,11 +518,11 @@ class App:
|
|
| 509 |
c[qk] = len(rows)
|
| 510 |
if not rows:
|
| 511 |
continue
|
| 512 |
-
with open(
|
| 513 |
for r in rows:
|
| 514 |
f.write("%s://%s\n" % (r["type"], r["raw"]))
|
| 515 |
-
self.v_status.set("💾 Tách chất lượng: ★%d ●%d ▲%d ✗%d → %s"
|
| 516 |
-
% (c["rattot"], c["tot"], c["tb"], c["kem"],
|
| 517 |
|
| 518 |
def _clear(self):
|
| 519 |
self.tree.delete(*self.tree.get_children()); self.rows = []; self.pb["value"] = 0; self._checked = 0
|
|
|
|
| 405 |
|
| 406 |
def on_import(self):
|
| 407 |
if self.running: return
|
| 408 |
+
paths = filedialog.askopenfilenames(title="Chọn 1 hoặc nhiều file proxy",
|
| 409 |
+
filetypes=[("Text", "*.txt"), ("All", "*.*")])
|
| 410 |
+
if not paths: return
|
| 411 |
+
lines = []; nf = 0
|
| 412 |
+
for p in paths:
|
| 413 |
+
try:
|
| 414 |
+
data = open(p, encoding="utf-8", errors="ignore").read().splitlines()
|
| 415 |
+
lines += [l for l in data if l.strip() and not l.strip().startswith("#")]
|
| 416 |
+
nf += 1
|
| 417 |
+
except Exception as e:
|
| 418 |
+
messagebox.showerror("Lỗi", "%s: %s" % (p, str(e)[:60]))
|
| 419 |
+
self.input = lines
|
| 420 |
+
self.v_status.set("Đã nạp %d proxy từ %d file. Bấm ▶ Kiểm tra." % (len(lines), nf))
|
| 421 |
|
| 422 |
def on_run(self):
|
| 423 |
if self.running: return
|
|
|
|
| 482 |
alive = [r for r in alive if r.get("q") == QFILTER.get(qf)]
|
| 483 |
if not alive:
|
| 484 |
messagebox.showinfo("Chưa có", "Chưa có proxy để lưu."); return
|
| 485 |
+
path = filedialog.asksaveasfilename(defaultextension=".txt", initialfile="proxy.txt",
|
| 486 |
+
filetypes=[("Text", "*.txt")], title="Đặt tên file (tự thêm _http / _socks5 / _socks4)")
|
| 487 |
+
if not path:
|
| 488 |
return
|
| 489 |
+
base, ext = os.path.splitext(path); ext = ext or ".txt"
|
| 490 |
c = {}
|
| 491 |
for typ in ("http", "socks5", "socks4"):
|
| 492 |
rows = sorted([r for r in alive if r["type"] == typ], key=lambda x: x["ms"])
|
| 493 |
c[typ] = len(rows)
|
| 494 |
if not rows:
|
| 495 |
continue
|
| 496 |
+
with open("%s_%s%s" % (base, typ, ext), "w", encoding="utf-8") as f:
|
| 497 |
for r in rows:
|
| 498 |
f.write("%s://%s\n" % (r["type"], r["raw"]))
|
| 499 |
+
self.v_status.set("💾 Đã tách: http %d · socks5 %d · socks4 %d → %s_*%s"
|
| 500 |
+
% (c["http"], c["socks5"], c["socks4"], os.path.basename(base), ext))
|
| 501 |
|
| 502 |
def on_save_split_q(self):
|
| 503 |
alive = [r for r in self.rows if r.get("ok")]
|
|
|
|
| 506 |
alive = [r for r in alive if r["type"] == tf]
|
| 507 |
if not alive:
|
| 508 |
messagebox.showinfo("Chưa có", "Chưa có proxy để lưu."); return
|
| 509 |
+
path = filedialog.asksaveasfilename(defaultextension=".txt", initialfile="proxy.txt",
|
| 510 |
+
filetypes=[("Text", "*.txt")], title="Đặt tên file (tự thêm _rattot / _tot / _trungbinh / _kem)")
|
| 511 |
+
if not path:
|
| 512 |
return
|
| 513 |
+
base, ext = os.path.splitext(path); ext = ext or ".txt"
|
| 514 |
names = {"rattot": "rattot", "tot": "tot", "tb": "trungbinh", "kem": "kem"}
|
| 515 |
c = {}
|
| 516 |
for qk, fn in names.items():
|
|
|
|
| 518 |
c[qk] = len(rows)
|
| 519 |
if not rows:
|
| 520 |
continue
|
| 521 |
+
with open("%s_%s%s" % (base, fn, ext), "w", encoding="utf-8") as f:
|
| 522 |
for r in rows:
|
| 523 |
f.write("%s://%s\n" % (r["type"], r["raw"]))
|
| 524 |
+
self.v_status.set("💾 Tách chất lượng: ★%d ●%d ▲%d ✗%d → %s_*%s"
|
| 525 |
+
% (c["rattot"], c["tot"], c["tb"], c["kem"], os.path.basename(base), ext))
|
| 526 |
|
| 527 |
def _clear(self):
|
| 528 |
self.tree.delete(*self.tree.get_children()); self.rows = []; self.pb["value"] = 0; self._checked = 0
|