Spaces:
Paused
Paused
Download visorconf.py from AdeBagusSumantri/Sc: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/spaces/AdeBagusSumantri/Sc/resolve/main/visorconf.py
- Command line
-
hf download hf://spaces/AdeBagusSumantri/Sc/visorconf.py
-
curl -L -o visorconf.py https://huggingface.co/spaces/AdeBagusSumantri/Sc/resolve/main/visorconf.py
1.55 kB
| import server | |
| server.start() # ← HF Space langsung Running | |
| import proxy | |
| proxy.patch_all() | |
| import importlib | |
| import os | |
| import threading | |
| import time | |
| SCRAPERS_DIR = "scrapers" | |
| def load_and_run(name): | |
| try: | |
| module = importlib.import_module(f"scrapers.{name}") | |
| print(f"[visorconf] ▶ Running: {name}", flush=True) | |
| module.run() | |
| print(f"[visorconf] ✅ Done: {name}", flush=True) | |
| except Exception as e: | |
| print(f"[visorconf] ❌ Error on {name}: {e}", flush=True) | |
| def get_scrapers(): | |
| scrapers = [] | |
| for item in os.listdir(SCRAPERS_DIR): | |
| if item.endswith(".py") and not item.startswith("_"): | |
| scrapers.append(item[:-3]) | |
| elif os.path.isdir(os.path.join(SCRAPERS_DIR, item)) and \ | |
| os.path.exists(os.path.join(SCRAPERS_DIR, item, "__init__.py")) and \ | |
| not item.startswith("_"): | |
| scrapers.append(item) | |
| return scrapers | |
| def run_all(parallel=True): | |
| scrapers = get_scrapers() | |
| if not scrapers: | |
| print("[visorconf] Tidak ada scraper ditemukan.", flush=True) | |
| return | |
| print(f"[visorconf] Ditemukan {len(scrapers)} scraper: {scrapers}", flush=True) | |
| if parallel: | |
| threads = [threading.Thread(target=load_and_run, args=(s,), daemon=True) for s in scrapers] | |
| for t in threads: t.start() | |
| for t in threads: t.join() | |
| else: | |
| for s in scrapers: | |
| load_and_run(s) | |
| if __name__ == "__main__": | |
| run_all(parallel=True) | |
| # Keep alive | |
| while True: | |
| time.sleep(60) | |