Spaces:
Paused
Paused
Upload 29 files
Browse files- .gitattributes +2 -0
- Dockerfile +4 -3
- app.py +204 -93
- aria2.py +426 -0
- downloads/10Mb.dat +3 -0
- downloads/10Mb.dat.aria2 +0 -0
- downloads/1Mb.dat +3 -0
- qbittorrent/config/qBittorrent.conf +36 -36
- qbittorrent/config/qBittorrent/config/qBittorrent-data.conf +1 -1
- qbittorrent/config/qBittorrent/config/qBittorrent.conf +36 -36
- static/app.js +142 -38
- templates/index.html +45 -24
.gitattributes
CHANGED
|
@@ -35,3 +35,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
qbittorrent/config/qBittorrent/data/GeoDB/dbip-country-lite.mmdb filter=lfs diff=lfs merge=lfs -text
|
| 37 |
*.sh text eol=lf
|
|
|
|
|
|
|
|
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
qbittorrent/config/qBittorrent/data/GeoDB/dbip-country-lite.mmdb filter=lfs diff=lfs merge=lfs -text
|
| 37 |
*.sh text eol=lf
|
| 38 |
+
downloads/10Mb.dat filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
downloads/1Mb.dat filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
CHANGED
|
@@ -7,9 +7,9 @@ ENV PYTHONUNBUFFERED=1 \
|
|
| 7 |
QBITTORRENT_SAVE_PATH=/downloads \
|
| 8 |
PORT=5000
|
| 9 |
|
| 10 |
-
RUN apt-get update \
|
| 11 |
-
&& apt-get install -y --no-install-recommends qbittorrent-nox ca-certificates bash tini curl p7zip-full \
|
| 12 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
RUN useradd -m -u 1000 qbittorrent
|
| 15 |
|
|
@@ -19,6 +19,7 @@ COPY requirements.txt .
|
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
| 21 |
COPY app.py .
|
|
|
|
| 22 |
COPY static ./static
|
| 23 |
COPY templates ./templates
|
| 24 |
COPY qbittorrent/config/qBittorrent.conf /defaults/qBittorrent.conf
|
|
|
|
| 7 |
QBITTORRENT_SAVE_PATH=/downloads \
|
| 8 |
PORT=5000
|
| 9 |
|
| 10 |
+
RUN apt-get update \
|
| 11 |
+
&& apt-get install -y --no-install-recommends qbittorrent-nox aria2 ca-certificates bash tini curl p7zip-full \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
RUN useradd -m -u 1000 qbittorrent
|
| 15 |
|
|
|
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
| 21 |
COPY app.py .
|
| 22 |
+
COPY aria2.py .
|
| 23 |
COPY static ./static
|
| 24 |
COPY templates ./templates
|
| 25 |
COPY qbittorrent/config/qBittorrent.conf /defaults/qBittorrent.conf
|
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
-
import json
|
| 2 |
-
import os
|
| 3 |
-
import platform
|
| 4 |
-
import re
|
| 5 |
import signal
|
| 6 |
import shutil
|
| 7 |
import socket
|
|
@@ -13,9 +13,11 @@ from urllib.parse import parse_qs, quote, urlparse
|
|
| 13 |
|
| 14 |
from flask import Flask, flash, jsonify, redirect, render_template, request, url_for
|
| 15 |
import psutil
|
| 16 |
-
import qbittorrentapi
|
| 17 |
-
import requests
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
BASE_DIR = Path(__file__).resolve().parent
|
| 21 |
UPLOAD_DIR = BASE_DIR / "uploads"
|
|
@@ -308,21 +310,22 @@ def human_eta(seconds: float | int | None) -> str:
|
|
| 308 |
return f"{days} {day_label} {remaining_hours} {hour_label} left"
|
| 309 |
|
| 310 |
|
| 311 |
-
def load_monitor_state() -> dict:
|
| 312 |
-
with STATE_LOCK:
|
| 313 |
-
if not STATE_FILE.exists():
|
| 314 |
-
return {"torrents": {}, "events": [], "system": {}, "speedtest": {"running": False}}
|
| 315 |
-
|
| 316 |
-
try:
|
| 317 |
-
data = json.loads(STATE_FILE.read_text(encoding="utf-8"))
|
| 318 |
-
except (json.JSONDecodeError, OSError):
|
| 319 |
-
return {"torrents": {}, "events": [], "system": {}, "speedtest": {"running": False}}
|
| 320 |
-
|
| 321 |
-
data.setdefault("torrents", {})
|
| 322 |
-
data.setdefault("
|
| 323 |
-
data.setdefault("
|
| 324 |
-
data.setdefault("
|
| 325 |
-
|
|
|
|
| 326 |
|
| 327 |
|
| 328 |
def save_monitor_state(state: dict) -> None:
|
|
@@ -529,17 +532,28 @@ def serialize_torrent(torrent, state_entry: dict | None = None) -> dict:
|
|
| 529 |
"can_cancel_gofile_upload": gofile_uploading,
|
| 530 |
"can_pixeldrain_upload": can_gofile_upload and bool(PIXELDRAIN_API_KEY),
|
| 531 |
"is_folder": is_folder,
|
| 532 |
-
"can_raw_gofile_upload": is_folder and bool(GOFILE_API_TOKEN),
|
| 533 |
-
"can_raw_pixeldrain_upload": is_folder and bool(PIXELDRAIN_API_KEY),
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 543 |
|
| 544 |
|
| 545 |
def prepare_upload_source(source_path: Path, torrent_hash: str, provider_name: str) -> tuple[Path, bool]:
|
|
@@ -551,7 +565,7 @@ def prepare_upload_source(source_path: Path, torrent_hash: str, provider_name: s
|
|
| 551 |
if archive_path.exists():
|
| 552 |
archive_path = UPLOAD_DIR / f"{source_path.name}-{torrent_hash[:8]}.zip"
|
| 553 |
|
| 554 |
-
|
| 555 |
torrent_hash,
|
| 556 |
gofile_provider="Archiving",
|
| 557 |
gofile_status=f"Archiving folder for {provider_name}...",
|
|
@@ -578,11 +592,11 @@ def prepare_upload_source(source_path: Path, torrent_hash: str, provider_name: s
|
|
| 578 |
)
|
| 579 |
monitor_thread.start()
|
| 580 |
|
| 581 |
-
|
| 582 |
while True:
|
| 583 |
return_code = process.poll()
|
| 584 |
current_state = load_monitor_state()
|
| 585 |
-
current_entry =
|
| 586 |
if current_entry.get("gofile_cancel_requested"):
|
| 587 |
cancel_upload_process(process.pid)
|
| 588 |
|
|
@@ -598,7 +612,7 @@ def prepare_upload_source(source_path: Path, torrent_hash: str, provider_name: s
|
|
| 598 |
archive_path.unlink(missing_ok=True)
|
| 599 |
raise ValueError(" | ".join(error_lines[-3:]).strip() or "Gagal membuat arsip ZIP.")
|
| 600 |
|
| 601 |
-
|
| 602 |
torrent_hash,
|
| 603 |
gofile_provider=provider_name,
|
| 604 |
gofile_status=f"Archive ready, memulai upload ke {provider_name}...",
|
|
@@ -629,12 +643,12 @@ def upload_folder_raw_gofile(torrent_hash: str, source_path: Path) -> tuple[str,
|
|
| 629 |
|
| 630 |
for index, (file_path, relative_path) in enumerate(file_entries, start=1):
|
| 631 |
current_state = load_monitor_state()
|
| 632 |
-
current_entry =
|
| 633 |
if current_entry.get("gofile_cancel_requested"):
|
| 634 |
raise GofileUploadCancelled("Upload GoFile dibatalkan.")
|
| 635 |
|
| 636 |
progress = int((uploaded_bytes / total_bytes) * 100) if total_bytes else 0
|
| 637 |
-
|
| 638 |
torrent_hash,
|
| 639 |
gofile_progress=progress,
|
| 640 |
gofile_speed="",
|
|
@@ -672,7 +686,7 @@ def upload_folder_raw_gofile(torrent_hash: str, source_path: Path) -> tuple[str,
|
|
| 672 |
folder_renamed = True
|
| 673 |
uploaded_bytes += file_path.stat().st_size
|
| 674 |
progress = int((uploaded_bytes / total_bytes) * 100) if total_bytes else 100
|
| 675 |
-
|
| 676 |
torrent_hash,
|
| 677 |
gofile_progress=progress,
|
| 678 |
gofile_status=f"Uploading raw folder to GoFile... {index}/{total_files}",
|
|
@@ -696,12 +710,12 @@ def upload_folder_raw_pixeldrain(torrent_hash: str, source_path: Path) -> str:
|
|
| 696 |
|
| 697 |
for index, (file_path, relative_path) in enumerate(file_entries, start=1):
|
| 698 |
current_state = load_monitor_state()
|
| 699 |
-
current_entry =
|
| 700 |
if current_entry.get("gofile_cancel_requested"):
|
| 701 |
raise GofileUploadCancelled("Upload PixelDrain dibatalkan.")
|
| 702 |
|
| 703 |
progress = int((uploaded_bytes / total_bytes) * 100) if total_bytes else 0
|
| 704 |
-
|
| 705 |
torrent_hash,
|
| 706 |
gofile_progress=progress,
|
| 707 |
gofile_speed="",
|
|
@@ -728,7 +742,7 @@ def upload_folder_raw_pixeldrain(torrent_hash: str, source_path: Path) -> str:
|
|
| 728 |
uploaded_files.append({"id": file_id, "description": relative_path.as_posix()})
|
| 729 |
uploaded_bytes += file_path.stat().st_size
|
| 730 |
progress = int((uploaded_bytes / total_bytes) * 100) if total_bytes else 100
|
| 731 |
-
|
| 732 |
torrent_hash,
|
| 733 |
gofile_progress=progress,
|
| 734 |
gofile_status=f"Uploading raw folder to PixelDrain... {index}/{total_files}",
|
|
@@ -766,8 +780,12 @@ def clear_pre_upload_restore_fields(entry: dict) -> None:
|
|
| 766 |
|
| 767 |
|
| 768 |
def restore_torrent_state_after_remote_upload(torrent_hash: str) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 769 |
state = load_monitor_state()
|
| 770 |
-
entry =
|
| 771 |
previous_state = str(entry.get("pre_upload_state", "") or "")
|
| 772 |
previous_force_start = bool(entry.get("pre_upload_force_start", False))
|
| 773 |
if not previous_state and "pre_upload_force_start" not in entry:
|
|
@@ -811,7 +829,7 @@ def restore_torrent_state_after_remote_upload(torrent_hash: str) -> None:
|
|
| 811 |
except qbittorrentapi.APIError:
|
| 812 |
pass
|
| 813 |
finally:
|
| 814 |
-
update_state(lambda current: clear_pre_upload_restore_fields(
|
| 815 |
|
| 816 |
|
| 817 |
def evaluate_torrent_health(client, torrents: list, state: dict) -> bool:
|
|
@@ -1022,10 +1040,10 @@ def run_speedtest_background() -> None:
|
|
| 1022 |
set_speedtest_state(running=False, status=f"Speedtest gagal: {exc}", result={})
|
| 1023 |
|
| 1024 |
|
| 1025 |
-
def get_dashboard_data() -> tuple[list[dict], dict]:
|
| 1026 |
-
client = get_client()
|
| 1027 |
-
state = load_monitor_state()
|
| 1028 |
-
raw_torrents = list(client.torrents_info(sort="added_on", reverse=True))
|
| 1029 |
state_changed = evaluate_torrent_health(client, raw_torrents, state)
|
| 1030 |
|
| 1031 |
if state_changed:
|
|
@@ -1033,17 +1051,21 @@ def get_dashboard_data() -> tuple[list[dict], dict]:
|
|
| 1033 |
raw_torrents = list(client.torrents_info(sort="added_on", reverse=True))
|
| 1034 |
|
| 1035 |
version = client.app.version
|
| 1036 |
-
|
|
|
|
|
|
|
| 1037 |
seeding_states = {"uploading", "stalledUP", "forcedUP", "pausedUP", "queuedUP", "checkingUP"}
|
|
|
|
|
|
|
| 1038 |
stats = {
|
| 1039 |
"connected": True,
|
| 1040 |
"download_path": DOWNLOAD_PATH,
|
| 1041 |
"version": version,
|
| 1042 |
"torrent_count": len(torrents),
|
| 1043 |
-
"downloading": sum(1 for item in raw_torrents if item.state in ACTIVE_DOWNLOAD_STATES),
|
| 1044 |
"total_seeds": sum(1 for item in raw_torrents if getattr(item, "state", "") in seeding_states),
|
| 1045 |
-
"total_leechs": sum(1 for item in raw_torrents if getattr(item, "state", "") in ACTIVE_DOWNLOAD_STATES),
|
| 1046 |
-
"all_time_download": format_size(sum(int(getattr(item, "downloaded", 0) or 0) for item in raw_torrents)),
|
| 1047 |
"all_time_upload": format_size(sum(int(getattr(item, "uploaded", 0) or 0) for item in raw_torrents)),
|
| 1048 |
}
|
| 1049 |
system_info = get_system_info()
|
|
@@ -1112,7 +1134,7 @@ def monitor_7z_progress(stdout_pipe, torrent_hash: str, provider_name: str, erro
|
|
| 1112 |
if progress is not None and progress != last_progress:
|
| 1113 |
last_progress = progress
|
| 1114 |
update_state(
|
| 1115 |
-
lambda state:
|
| 1116 |
{
|
| 1117 |
"gofile_provider": "Archiving",
|
| 1118 |
"gofile_progress": progress,
|
|
@@ -1156,7 +1178,7 @@ def monitor_curl_progress(stderr_pipe, torrent_hash: str, total_bytes: int, uplo
|
|
| 1156 |
if progress:
|
| 1157 |
speed_text = format_speed(progress["speed"])
|
| 1158 |
update_state(
|
| 1159 |
-
lambda state:
|
| 1160 |
{
|
| 1161 |
"gofile_progress": progress["progress"],
|
| 1162 |
"gofile_speed": speed_text,
|
|
@@ -1234,7 +1256,7 @@ def gofile_upload_attempt(
|
|
| 1234 |
monitor_thread.start()
|
| 1235 |
|
| 1236 |
update_state(
|
| 1237 |
-
lambda state:
|
| 1238 |
{
|
| 1239 |
"gofile_uploading": True,
|
| 1240 |
"gofile_pid": process.pid,
|
|
@@ -1249,7 +1271,7 @@ def gofile_upload_attempt(
|
|
| 1249 |
while True:
|
| 1250 |
return_code = process.poll()
|
| 1251 |
current_state = load_monitor_state()
|
| 1252 |
-
current_entry =
|
| 1253 |
if current_entry.get("gofile_cancel_requested"):
|
| 1254 |
cancel_upload_process(process.pid)
|
| 1255 |
|
|
@@ -1258,7 +1280,7 @@ def gofile_upload_attempt(
|
|
| 1258 |
|
| 1259 |
elapsed = max(int(time.time() - started_at), 1)
|
| 1260 |
update_state(
|
| 1261 |
-
lambda state:
|
| 1262 |
{
|
| 1263 |
"gofile_uploading": True,
|
| 1264 |
"gofile_pid": process.pid,
|
|
@@ -1341,7 +1363,7 @@ def pixeldrain_upload_attempt(torrent_hash: str, file_path: Path, started_at: fl
|
|
| 1341 |
monitor_thread.start()
|
| 1342 |
|
| 1343 |
update_state(
|
| 1344 |
-
lambda state:
|
| 1345 |
{
|
| 1346 |
"gofile_uploading": True,
|
| 1347 |
"gofile_pid": process.pid,
|
|
@@ -1356,7 +1378,7 @@ def pixeldrain_upload_attempt(torrent_hash: str, file_path: Path, started_at: fl
|
|
| 1356 |
while True:
|
| 1357 |
return_code = process.poll()
|
| 1358 |
current_state = load_monitor_state()
|
| 1359 |
-
current_entry =
|
| 1360 |
if current_entry.get("gofile_cancel_requested"):
|
| 1361 |
cancel_upload_process(process.pid)
|
| 1362 |
|
|
@@ -1364,7 +1386,7 @@ def pixeldrain_upload_attempt(torrent_hash: str, file_path: Path, started_at: fl
|
|
| 1364 |
break
|
| 1365 |
|
| 1366 |
update_state(
|
| 1367 |
-
lambda state:
|
| 1368 |
{
|
| 1369 |
"gofile_uploading": True,
|
| 1370 |
"gofile_pid": process.pid,
|
|
@@ -1403,7 +1425,7 @@ def start_gofile_upload_background(torrent_hash: str, torrent_name: str, file_pa
|
|
| 1403 |
folder_link, _folder_id = upload_folder_raw_gofile(torrent_hash, file_path)
|
| 1404 |
|
| 1405 |
def success_raw_mutator(state: dict):
|
| 1406 |
-
entry =
|
| 1407 |
clear_gofile_runtime_fields(entry)
|
| 1408 |
entry["gofile_link"] = folder_link
|
| 1409 |
entry["gofile_provider"] = "GoFile"
|
|
@@ -1427,7 +1449,7 @@ def start_gofile_upload_background(torrent_hash: str, torrent_name: str, file_pa
|
|
| 1427 |
except ValueError as exc:
|
| 1428 |
last_error = f"{upload_url}: {exc}"
|
| 1429 |
update_state(
|
| 1430 |
-
lambda state:
|
| 1431 |
{
|
| 1432 |
"gofile_uploading": True,
|
| 1433 |
"gofile_provider": "GoFile",
|
|
@@ -1446,7 +1468,7 @@ def start_gofile_upload_background(torrent_hash: str, torrent_name: str, file_pa
|
|
| 1446 |
raise ValueError("Respons GoFile tidak mengandung downloadPage.")
|
| 1447 |
|
| 1448 |
def success_mutator(state: dict):
|
| 1449 |
-
entry =
|
| 1450 |
clear_gofile_runtime_fields(entry)
|
| 1451 |
entry["gofile_link"] = download_page
|
| 1452 |
entry["gofile_provider"] = "GoFile"
|
|
@@ -1457,7 +1479,7 @@ def start_gofile_upload_background(torrent_hash: str, torrent_name: str, file_pa
|
|
| 1457 |
restore_torrent_state_after_remote_upload(torrent_hash)
|
| 1458 |
except GofileUploadCancelled:
|
| 1459 |
def cancel_mutator(state: dict):
|
| 1460 |
-
entry =
|
| 1461 |
clear_gofile_runtime_fields(entry)
|
| 1462 |
entry["gofile_provider"] = "GoFile"
|
| 1463 |
entry["gofile_status"] = "Upload GoFile dibatalkan."
|
|
@@ -1468,7 +1490,7 @@ def start_gofile_upload_background(torrent_hash: str, torrent_name: str, file_pa
|
|
| 1468 |
restore_torrent_state_after_remote_upload(torrent_hash)
|
| 1469 |
except (ValueError, requests.RequestException) as exc:
|
| 1470 |
def error_mutator(state: dict):
|
| 1471 |
-
entry =
|
| 1472 |
clear_gofile_runtime_fields(entry)
|
| 1473 |
entry["gofile_provider"] = "GoFile"
|
| 1474 |
entry["gofile_status"] = f"Upload GoFile gagal: {exc}"
|
|
@@ -1495,7 +1517,7 @@ def start_pixeldrain_upload_background(torrent_hash: str, torrent_name: str, fil
|
|
| 1495 |
download_page = upload_folder_raw_pixeldrain(torrent_hash, file_path)
|
| 1496 |
|
| 1497 |
def success_raw_mutator(state: dict):
|
| 1498 |
-
entry =
|
| 1499 |
clear_gofile_runtime_fields(entry)
|
| 1500 |
entry["gofile_link"] = download_page
|
| 1501 |
entry["gofile_provider"] = "PixelDrain"
|
|
@@ -1514,7 +1536,7 @@ def start_pixeldrain_upload_background(torrent_hash: str, torrent_name: str, fil
|
|
| 1514 |
download_page = f"https://pixeldrain.com/u/{file_id}"
|
| 1515 |
|
| 1516 |
def success_mutator(state: dict):
|
| 1517 |
-
entry =
|
| 1518 |
clear_gofile_runtime_fields(entry)
|
| 1519 |
entry["gofile_link"] = download_page
|
| 1520 |
entry["gofile_provider"] = "PixelDrain"
|
|
@@ -1525,7 +1547,7 @@ def start_pixeldrain_upload_background(torrent_hash: str, torrent_name: str, fil
|
|
| 1525 |
restore_torrent_state_after_remote_upload(torrent_hash)
|
| 1526 |
except GofileUploadCancelled:
|
| 1527 |
def cancel_mutator(state: dict):
|
| 1528 |
-
entry =
|
| 1529 |
clear_gofile_runtime_fields(entry)
|
| 1530 |
entry["gofile_provider"] = "PixelDrain"
|
| 1531 |
entry["gofile_status"] = "Upload PixelDrain dibatalkan."
|
|
@@ -1536,7 +1558,7 @@ def start_pixeldrain_upload_background(torrent_hash: str, torrent_name: str, fil
|
|
| 1536 |
restore_torrent_state_after_remote_upload(torrent_hash)
|
| 1537 |
except (ValueError, requests.RequestException) as exc:
|
| 1538 |
def error_mutator(state: dict):
|
| 1539 |
-
entry =
|
| 1540 |
clear_gofile_runtime_fields(entry)
|
| 1541 |
entry["gofile_provider"] = "PixelDrain"
|
| 1542 |
entry["gofile_status"] = f"Upload PixelDrain gagal: {exc}"
|
|
@@ -1623,6 +1645,9 @@ def system_speedtest():
|
|
| 1623 |
|
| 1624 |
@app.route("/api/torrents/<torrent_hash>/pause", methods=["POST"])
|
| 1625 |
def pause_torrent(torrent_hash: str):
|
|
|
|
|
|
|
|
|
|
| 1626 |
try:
|
| 1627 |
client = get_client()
|
| 1628 |
try:
|
|
@@ -1639,8 +1664,11 @@ def pause_torrent(torrent_hash: str):
|
|
| 1639 |
return action_response(f"Gagal pause torrent: {exc}", ok=False, status_code=400)
|
| 1640 |
|
| 1641 |
|
| 1642 |
-
@app.route("/api/torrents/<torrent_hash>/resume", methods=["POST"])
|
| 1643 |
def resume_torrent(torrent_hash: str):
|
|
|
|
|
|
|
|
|
|
| 1644 |
try:
|
| 1645 |
client = get_client()
|
| 1646 |
client.torrents_resume(torrent_hashes=torrent_hash)
|
|
@@ -1665,11 +1693,17 @@ def resume_torrent(torrent_hash: str):
|
|
| 1665 |
|
| 1666 |
|
| 1667 |
@app.route("/api/torrents/<torrent_hash>", methods=["DELETE"])
|
| 1668 |
-
def delete_torrent(torrent_hash: str):
|
| 1669 |
-
delete_files = request.args.get("with_files", "false").lower() == "true"
|
| 1670 |
-
|
| 1671 |
-
|
| 1672 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1673 |
state = load_monitor_state()
|
| 1674 |
state.setdefault("torrents", {}).pop(torrent_hash, None)
|
| 1675 |
if delete_files:
|
|
@@ -1681,13 +1715,65 @@ def delete_torrent(torrent_hash: str):
|
|
| 1681 |
save_monitor_state(state)
|
| 1682 |
return action_response(message)
|
| 1683 |
except qbittorrentapi.APIError as exc:
|
| 1684 |
-
return action_response(f"Gagal menghapus torrent: {exc}", ok=False, status_code=400)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1685 |
|
| 1686 |
|
| 1687 |
@app.route("/api/torrents/<torrent_hash>/upload-gofile", methods=["POST"])
|
| 1688 |
-
def upload_torrent_to_gofile(torrent_hash: str):
|
| 1689 |
-
|
| 1690 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1691 |
torrents = client.torrents_info(torrent_hashes=torrent_hash)
|
| 1692 |
if not torrents:
|
| 1693 |
return action_response("Torrent tidak ditemukan.", ok=False, status_code=404)
|
|
@@ -1707,7 +1793,7 @@ def upload_torrent_to_gofile(torrent_hash: str):
|
|
| 1707 |
return action_response("Raw folder upload GoFile memerlukan GOFILE_API_TOKEN.", ok=False, status_code=400)
|
| 1708 |
|
| 1709 |
state = load_monitor_state()
|
| 1710 |
-
entry =
|
| 1711 |
if entry.get("gofile_uploading"):
|
| 1712 |
return action_response("Upload GoFile masih berjalan.", ok=False, status_code=409)
|
| 1713 |
|
|
@@ -1732,11 +1818,12 @@ def upload_torrent_to_gofile(torrent_hash: str):
|
|
| 1732 |
|
| 1733 |
|
| 1734 |
@app.route("/api/torrents/<torrent_hash>/cancel-gofile", methods=["POST"])
|
| 1735 |
-
def cancel_gofile_upload(torrent_hash: str):
|
| 1736 |
-
state = load_monitor_state()
|
| 1737 |
-
|
| 1738 |
-
|
| 1739 |
-
|
|
|
|
| 1740 |
|
| 1741 |
provider = entry.get("gofile_provider", "upload")
|
| 1742 |
entry["gofile_cancel_requested"] = True
|
|
@@ -1749,12 +1836,36 @@ def cancel_gofile_upload(torrent_hash: str):
|
|
| 1749 |
|
| 1750 |
|
| 1751 |
@app.route("/api/torrents/<torrent_hash>/upload-pixeldrain", methods=["POST"])
|
| 1752 |
-
def upload_torrent_to_pixeldrain(torrent_hash: str):
|
| 1753 |
-
if not PIXELDRAIN_API_KEY:
|
| 1754 |
-
return action_response("PIXELDRAIN_API_KEY belum diset.", ok=False, status_code=400)
|
| 1755 |
-
|
| 1756 |
-
|
| 1757 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1758 |
torrents = client.torrents_info(torrent_hashes=torrent_hash)
|
| 1759 |
if not torrents:
|
| 1760 |
return action_response("Torrent tidak ditemukan.", ok=False, status_code=404)
|
|
@@ -1772,7 +1883,7 @@ def upload_torrent_to_pixeldrain(torrent_hash: str):
|
|
| 1772 |
return action_response("Mode upload tidak valid.", ok=False, status_code=400)
|
| 1773 |
|
| 1774 |
state = load_monitor_state()
|
| 1775 |
-
entry =
|
| 1776 |
if entry.get("gofile_uploading"):
|
| 1777 |
return action_response("Upload file eksternal masih berjalan.", ok=False, status_code=409)
|
| 1778 |
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
import platform
|
| 4 |
+
import re
|
| 5 |
import signal
|
| 6 |
import shutil
|
| 7 |
import socket
|
|
|
|
| 13 |
|
| 14 |
from flask import Flask, flash, jsonify, redirect, render_template, request, url_for
|
| 15 |
import psutil
|
| 16 |
+
import qbittorrentapi
|
| 17 |
+
import requests
|
| 18 |
+
|
| 19 |
+
import aria2
|
| 20 |
+
|
| 21 |
|
| 22 |
BASE_DIR = Path(__file__).resolve().parent
|
| 23 |
UPLOAD_DIR = BASE_DIR / "uploads"
|
|
|
|
| 310 |
return f"{days} {day_label} {remaining_hours} {hour_label} left"
|
| 311 |
|
| 312 |
|
| 313 |
+
def load_monitor_state() -> dict:
|
| 314 |
+
with STATE_LOCK:
|
| 315 |
+
if not STATE_FILE.exists():
|
| 316 |
+
return {"torrents": {}, "aria2": {}, "events": [], "system": {}, "speedtest": {"running": False}}
|
| 317 |
+
|
| 318 |
+
try:
|
| 319 |
+
data = json.loads(STATE_FILE.read_text(encoding="utf-8"))
|
| 320 |
+
except (json.JSONDecodeError, OSError):
|
| 321 |
+
return {"torrents": {}, "aria2": {}, "events": [], "system": {}, "speedtest": {"running": False}}
|
| 322 |
+
|
| 323 |
+
data.setdefault("torrents", {})
|
| 324 |
+
data.setdefault("aria2", {})
|
| 325 |
+
data.setdefault("events", [])
|
| 326 |
+
data.setdefault("system", {})
|
| 327 |
+
data.setdefault("speedtest", {"running": False})
|
| 328 |
+
return data
|
| 329 |
|
| 330 |
|
| 331 |
def save_monitor_state(state: dict) -> None:
|
|
|
|
| 532 |
"can_cancel_gofile_upload": gofile_uploading,
|
| 533 |
"can_pixeldrain_upload": can_gofile_upload and bool(PIXELDRAIN_API_KEY),
|
| 534 |
"is_folder": is_folder,
|
| 535 |
+
"can_raw_gofile_upload": is_folder and bool(GOFILE_API_TOKEN),
|
| 536 |
+
"can_raw_pixeldrain_upload": is_folder and bool(PIXELDRAIN_API_KEY),
|
| 537 |
+
"task_kind": "torrent",
|
| 538 |
+
"added_at": int(getattr(torrent, "added_on", 0) or 0),
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
|
| 542 |
+
def is_aria2_task(task_id: str) -> bool:
|
| 543 |
+
return str(task_id).startswith("aria2_")
|
| 544 |
+
|
| 545 |
+
|
| 546 |
+
def get_task_state_entry(state: dict, task_id: str) -> dict:
|
| 547 |
+
bucket_name = "aria2" if is_aria2_task(task_id) else "torrents"
|
| 548 |
+
return state.setdefault(bucket_name, {}).setdefault(task_id, {})
|
| 549 |
+
|
| 550 |
+
|
| 551 |
+
def update_task_entry(task_id: str, **fields) -> None:
|
| 552 |
+
def mutator(state: dict):
|
| 553 |
+
entry = get_task_state_entry(state, task_id)
|
| 554 |
+
entry.update(fields)
|
| 555 |
+
|
| 556 |
+
update_state(mutator)
|
| 557 |
|
| 558 |
|
| 559 |
def prepare_upload_source(source_path: Path, torrent_hash: str, provider_name: str) -> tuple[Path, bool]:
|
|
|
|
| 565 |
if archive_path.exists():
|
| 566 |
archive_path = UPLOAD_DIR / f"{source_path.name}-{torrent_hash[:8]}.zip"
|
| 567 |
|
| 568 |
+
update_task_entry(
|
| 569 |
torrent_hash,
|
| 570 |
gofile_provider="Archiving",
|
| 571 |
gofile_status=f"Archiving folder for {provider_name}...",
|
|
|
|
| 592 |
)
|
| 593 |
monitor_thread.start()
|
| 594 |
|
| 595 |
+
update_task_entry(torrent_hash, gofile_pid=process.pid)
|
| 596 |
while True:
|
| 597 |
return_code = process.poll()
|
| 598 |
current_state = load_monitor_state()
|
| 599 |
+
current_entry = get_task_state_entry(current_state, torrent_hash)
|
| 600 |
if current_entry.get("gofile_cancel_requested"):
|
| 601 |
cancel_upload_process(process.pid)
|
| 602 |
|
|
|
|
| 612 |
archive_path.unlink(missing_ok=True)
|
| 613 |
raise ValueError(" | ".join(error_lines[-3:]).strip() or "Gagal membuat arsip ZIP.")
|
| 614 |
|
| 615 |
+
update_task_entry(
|
| 616 |
torrent_hash,
|
| 617 |
gofile_provider=provider_name,
|
| 618 |
gofile_status=f"Archive ready, memulai upload ke {provider_name}...",
|
|
|
|
| 643 |
|
| 644 |
for index, (file_path, relative_path) in enumerate(file_entries, start=1):
|
| 645 |
current_state = load_monitor_state()
|
| 646 |
+
current_entry = get_task_state_entry(current_state, torrent_hash)
|
| 647 |
if current_entry.get("gofile_cancel_requested"):
|
| 648 |
raise GofileUploadCancelled("Upload GoFile dibatalkan.")
|
| 649 |
|
| 650 |
progress = int((uploaded_bytes / total_bytes) * 100) if total_bytes else 0
|
| 651 |
+
update_task_entry(
|
| 652 |
torrent_hash,
|
| 653 |
gofile_progress=progress,
|
| 654 |
gofile_speed="",
|
|
|
|
| 686 |
folder_renamed = True
|
| 687 |
uploaded_bytes += file_path.stat().st_size
|
| 688 |
progress = int((uploaded_bytes / total_bytes) * 100) if total_bytes else 100
|
| 689 |
+
update_task_entry(
|
| 690 |
torrent_hash,
|
| 691 |
gofile_progress=progress,
|
| 692 |
gofile_status=f"Uploading raw folder to GoFile... {index}/{total_files}",
|
|
|
|
| 710 |
|
| 711 |
for index, (file_path, relative_path) in enumerate(file_entries, start=1):
|
| 712 |
current_state = load_monitor_state()
|
| 713 |
+
current_entry = get_task_state_entry(current_state, torrent_hash)
|
| 714 |
if current_entry.get("gofile_cancel_requested"):
|
| 715 |
raise GofileUploadCancelled("Upload PixelDrain dibatalkan.")
|
| 716 |
|
| 717 |
progress = int((uploaded_bytes / total_bytes) * 100) if total_bytes else 0
|
| 718 |
+
update_task_entry(
|
| 719 |
torrent_hash,
|
| 720 |
gofile_progress=progress,
|
| 721 |
gofile_speed="",
|
|
|
|
| 742 |
uploaded_files.append({"id": file_id, "description": relative_path.as_posix()})
|
| 743 |
uploaded_bytes += file_path.stat().st_size
|
| 744 |
progress = int((uploaded_bytes / total_bytes) * 100) if total_bytes else 100
|
| 745 |
+
update_task_entry(
|
| 746 |
torrent_hash,
|
| 747 |
gofile_progress=progress,
|
| 748 |
gofile_status=f"Uploading raw folder to PixelDrain... {index}/{total_files}",
|
|
|
|
| 780 |
|
| 781 |
|
| 782 |
def restore_torrent_state_after_remote_upload(torrent_hash: str) -> None:
|
| 783 |
+
if is_aria2_task(torrent_hash):
|
| 784 |
+
update_state(lambda current: clear_pre_upload_restore_fields(get_task_state_entry(current, torrent_hash)))
|
| 785 |
+
return
|
| 786 |
+
|
| 787 |
state = load_monitor_state()
|
| 788 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 789 |
previous_state = str(entry.get("pre_upload_state", "") or "")
|
| 790 |
previous_force_start = bool(entry.get("pre_upload_force_start", False))
|
| 791 |
if not previous_state and "pre_upload_force_start" not in entry:
|
|
|
|
| 829 |
except qbittorrentapi.APIError:
|
| 830 |
pass
|
| 831 |
finally:
|
| 832 |
+
update_state(lambda current: clear_pre_upload_restore_fields(get_task_state_entry(current, torrent_hash)))
|
| 833 |
|
| 834 |
|
| 835 |
def evaluate_torrent_health(client, torrents: list, state: dict) -> bool:
|
|
|
|
| 1040 |
set_speedtest_state(running=False, status=f"Speedtest gagal: {exc}", result={})
|
| 1041 |
|
| 1042 |
|
| 1043 |
+
def get_dashboard_data() -> tuple[list[dict], dict]:
|
| 1044 |
+
client = get_client()
|
| 1045 |
+
state = load_monitor_state()
|
| 1046 |
+
raw_torrents = list(client.torrents_info(sort="added_on", reverse=True))
|
| 1047 |
state_changed = evaluate_torrent_health(client, raw_torrents, state)
|
| 1048 |
|
| 1049 |
if state_changed:
|
|
|
|
| 1051 |
raw_torrents = list(client.torrents_info(sort="added_on", reverse=True))
|
| 1052 |
|
| 1053 |
version = client.app.version
|
| 1054 |
+
torrent_items = [serialize_torrent(torrent, state.get("torrents", {}).get(torrent.hash)) for torrent in raw_torrents]
|
| 1055 |
+
aria2_items = [aria2.serialize_task(task) for task in state.get("aria2", {}).values()]
|
| 1056 |
+
torrents = sorted(torrent_items + aria2_items, key=lambda item: int(item.get("added_at", 0) or 0), reverse=True)
|
| 1057 |
seeding_states = {"uploading", "stalledUP", "forcedUP", "pausedUP", "queuedUP", "checkingUP"}
|
| 1058 |
+
aria2_active_count = sum(1 for item in state.get("aria2", {}).values() if item.get("state") == "downloading")
|
| 1059 |
+
aria2_downloaded_bytes = sum(int(item.get("downloaded_bytes", 0) or 0) for item in state.get("aria2", {}).values())
|
| 1060 |
stats = {
|
| 1061 |
"connected": True,
|
| 1062 |
"download_path": DOWNLOAD_PATH,
|
| 1063 |
"version": version,
|
| 1064 |
"torrent_count": len(torrents),
|
| 1065 |
+
"downloading": sum(1 for item in raw_torrents if item.state in ACTIVE_DOWNLOAD_STATES) + aria2_active_count,
|
| 1066 |
"total_seeds": sum(1 for item in raw_torrents if getattr(item, "state", "") in seeding_states),
|
| 1067 |
+
"total_leechs": sum(1 for item in raw_torrents if getattr(item, "state", "") in ACTIVE_DOWNLOAD_STATES) + aria2_active_count,
|
| 1068 |
+
"all_time_download": format_size(sum(int(getattr(item, "downloaded", 0) or 0) for item in raw_torrents) + aria2_downloaded_bytes),
|
| 1069 |
"all_time_upload": format_size(sum(int(getattr(item, "uploaded", 0) or 0) for item in raw_torrents)),
|
| 1070 |
}
|
| 1071 |
system_info = get_system_info()
|
|
|
|
| 1134 |
if progress is not None and progress != last_progress:
|
| 1135 |
last_progress = progress
|
| 1136 |
update_state(
|
| 1137 |
+
lambda state: get_task_state_entry(state, torrent_hash).update(
|
| 1138 |
{
|
| 1139 |
"gofile_provider": "Archiving",
|
| 1140 |
"gofile_progress": progress,
|
|
|
|
| 1178 |
if progress:
|
| 1179 |
speed_text = format_speed(progress["speed"])
|
| 1180 |
update_state(
|
| 1181 |
+
lambda state: get_task_state_entry(state, torrent_hash).update(
|
| 1182 |
{
|
| 1183 |
"gofile_progress": progress["progress"],
|
| 1184 |
"gofile_speed": speed_text,
|
|
|
|
| 1256 |
monitor_thread.start()
|
| 1257 |
|
| 1258 |
update_state(
|
| 1259 |
+
lambda state: get_task_state_entry(state, torrent_hash).update(
|
| 1260 |
{
|
| 1261 |
"gofile_uploading": True,
|
| 1262 |
"gofile_pid": process.pid,
|
|
|
|
| 1271 |
while True:
|
| 1272 |
return_code = process.poll()
|
| 1273 |
current_state = load_monitor_state()
|
| 1274 |
+
current_entry = get_task_state_entry(current_state, torrent_hash)
|
| 1275 |
if current_entry.get("gofile_cancel_requested"):
|
| 1276 |
cancel_upload_process(process.pid)
|
| 1277 |
|
|
|
|
| 1280 |
|
| 1281 |
elapsed = max(int(time.time() - started_at), 1)
|
| 1282 |
update_state(
|
| 1283 |
+
lambda state: get_task_state_entry(state, torrent_hash).update(
|
| 1284 |
{
|
| 1285 |
"gofile_uploading": True,
|
| 1286 |
"gofile_pid": process.pid,
|
|
|
|
| 1363 |
monitor_thread.start()
|
| 1364 |
|
| 1365 |
update_state(
|
| 1366 |
+
lambda state: get_task_state_entry(state, torrent_hash).update(
|
| 1367 |
{
|
| 1368 |
"gofile_uploading": True,
|
| 1369 |
"gofile_pid": process.pid,
|
|
|
|
| 1378 |
while True:
|
| 1379 |
return_code = process.poll()
|
| 1380 |
current_state = load_monitor_state()
|
| 1381 |
+
current_entry = get_task_state_entry(current_state, torrent_hash)
|
| 1382 |
if current_entry.get("gofile_cancel_requested"):
|
| 1383 |
cancel_upload_process(process.pid)
|
| 1384 |
|
|
|
|
| 1386 |
break
|
| 1387 |
|
| 1388 |
update_state(
|
| 1389 |
+
lambda state: get_task_state_entry(state, torrent_hash).update(
|
| 1390 |
{
|
| 1391 |
"gofile_uploading": True,
|
| 1392 |
"gofile_pid": process.pid,
|
|
|
|
| 1425 |
folder_link, _folder_id = upload_folder_raw_gofile(torrent_hash, file_path)
|
| 1426 |
|
| 1427 |
def success_raw_mutator(state: dict):
|
| 1428 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1429 |
clear_gofile_runtime_fields(entry)
|
| 1430 |
entry["gofile_link"] = folder_link
|
| 1431 |
entry["gofile_provider"] = "GoFile"
|
|
|
|
| 1449 |
except ValueError as exc:
|
| 1450 |
last_error = f"{upload_url}: {exc}"
|
| 1451 |
update_state(
|
| 1452 |
+
lambda state: get_task_state_entry(state, torrent_hash).update(
|
| 1453 |
{
|
| 1454 |
"gofile_uploading": True,
|
| 1455 |
"gofile_provider": "GoFile",
|
|
|
|
| 1468 |
raise ValueError("Respons GoFile tidak mengandung downloadPage.")
|
| 1469 |
|
| 1470 |
def success_mutator(state: dict):
|
| 1471 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1472 |
clear_gofile_runtime_fields(entry)
|
| 1473 |
entry["gofile_link"] = download_page
|
| 1474 |
entry["gofile_provider"] = "GoFile"
|
|
|
|
| 1479 |
restore_torrent_state_after_remote_upload(torrent_hash)
|
| 1480 |
except GofileUploadCancelled:
|
| 1481 |
def cancel_mutator(state: dict):
|
| 1482 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1483 |
clear_gofile_runtime_fields(entry)
|
| 1484 |
entry["gofile_provider"] = "GoFile"
|
| 1485 |
entry["gofile_status"] = "Upload GoFile dibatalkan."
|
|
|
|
| 1490 |
restore_torrent_state_after_remote_upload(torrent_hash)
|
| 1491 |
except (ValueError, requests.RequestException) as exc:
|
| 1492 |
def error_mutator(state: dict):
|
| 1493 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1494 |
clear_gofile_runtime_fields(entry)
|
| 1495 |
entry["gofile_provider"] = "GoFile"
|
| 1496 |
entry["gofile_status"] = f"Upload GoFile gagal: {exc}"
|
|
|
|
| 1517 |
download_page = upload_folder_raw_pixeldrain(torrent_hash, file_path)
|
| 1518 |
|
| 1519 |
def success_raw_mutator(state: dict):
|
| 1520 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1521 |
clear_gofile_runtime_fields(entry)
|
| 1522 |
entry["gofile_link"] = download_page
|
| 1523 |
entry["gofile_provider"] = "PixelDrain"
|
|
|
|
| 1536 |
download_page = f"https://pixeldrain.com/u/{file_id}"
|
| 1537 |
|
| 1538 |
def success_mutator(state: dict):
|
| 1539 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1540 |
clear_gofile_runtime_fields(entry)
|
| 1541 |
entry["gofile_link"] = download_page
|
| 1542 |
entry["gofile_provider"] = "PixelDrain"
|
|
|
|
| 1547 |
restore_torrent_state_after_remote_upload(torrent_hash)
|
| 1548 |
except GofileUploadCancelled:
|
| 1549 |
def cancel_mutator(state: dict):
|
| 1550 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1551 |
clear_gofile_runtime_fields(entry)
|
| 1552 |
entry["gofile_provider"] = "PixelDrain"
|
| 1553 |
entry["gofile_status"] = "Upload PixelDrain dibatalkan."
|
|
|
|
| 1558 |
restore_torrent_state_after_remote_upload(torrent_hash)
|
| 1559 |
except (ValueError, requests.RequestException) as exc:
|
| 1560 |
def error_mutator(state: dict):
|
| 1561 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1562 |
clear_gofile_runtime_fields(entry)
|
| 1563 |
entry["gofile_provider"] = "PixelDrain"
|
| 1564 |
entry["gofile_status"] = f"Upload PixelDrain gagal: {exc}"
|
|
|
|
| 1645 |
|
| 1646 |
@app.route("/api/torrents/<torrent_hash>/pause", methods=["POST"])
|
| 1647 |
def pause_torrent(torrent_hash: str):
|
| 1648 |
+
if is_aria2_task(torrent_hash):
|
| 1649 |
+
ok, message = aria2.pause_task(torrent_hash, STATE_FILE, STATE_LOCK)
|
| 1650 |
+
return action_response(message, ok=ok, status_code=200 if ok else 400)
|
| 1651 |
try:
|
| 1652 |
client = get_client()
|
| 1653 |
try:
|
|
|
|
| 1664 |
return action_response(f"Gagal pause torrent: {exc}", ok=False, status_code=400)
|
| 1665 |
|
| 1666 |
|
| 1667 |
+
@app.route("/api/torrents/<torrent_hash>/resume", methods=["POST"])
|
| 1668 |
def resume_torrent(torrent_hash: str):
|
| 1669 |
+
if is_aria2_task(torrent_hash):
|
| 1670 |
+
ok, message = aria2.resume_task(torrent_hash, STATE_FILE, STATE_LOCK)
|
| 1671 |
+
return action_response(message, ok=ok, status_code=200 if ok else 400)
|
| 1672 |
try:
|
| 1673 |
client = get_client()
|
| 1674 |
client.torrents_resume(torrent_hashes=torrent_hash)
|
|
|
|
| 1693 |
|
| 1694 |
|
| 1695 |
@app.route("/api/torrents/<torrent_hash>", methods=["DELETE"])
|
| 1696 |
+
def delete_torrent(torrent_hash: str):
|
| 1697 |
+
delete_files = request.args.get("with_files", "false").lower() == "true"
|
| 1698 |
+
if torrent_hash.startswith("aria2_"):
|
| 1699 |
+
ok, message = aria2.delete_task(torrent_hash, STATE_FILE, STATE_LOCK, delete_files)
|
| 1700 |
+
if ok:
|
| 1701 |
+
update_state(lambda state: add_event(state, "warning", f"Tugas Aria2 {torrent_hash[:10]} dihapus{' beserta file' if delete_files else ''}."))
|
| 1702 |
+
return action_response(message)
|
| 1703 |
+
return action_response(message, ok=False, status_code=404)
|
| 1704 |
+
try:
|
| 1705 |
+
client = get_client()
|
| 1706 |
+
client.torrents_delete(delete_files=delete_files, torrent_hashes=torrent_hash)
|
| 1707 |
state = load_monitor_state()
|
| 1708 |
state.setdefault("torrents", {}).pop(torrent_hash, None)
|
| 1709 |
if delete_files:
|
|
|
|
| 1715 |
save_monitor_state(state)
|
| 1716 |
return action_response(message)
|
| 1717 |
except qbittorrentapi.APIError as exc:
|
| 1718 |
+
return action_response(f"Gagal menghapus torrent: {exc}", ok=False, status_code=400)
|
| 1719 |
+
|
| 1720 |
+
|
| 1721 |
+
@app.route("/add-aria2", methods=["POST"])
|
| 1722 |
+
def add_aria2():
|
| 1723 |
+
is_valid_url, url_or_error = aria2.validate_download_url(request.form.get("aria2_link", ""))
|
| 1724 |
+
if not is_valid_url:
|
| 1725 |
+
if wants_json_response():
|
| 1726 |
+
return action_response(url_or_error, ok=False, status_code=400)
|
| 1727 |
+
flash(url_or_error, "error")
|
| 1728 |
+
return redirect(url_for("index"))
|
| 1729 |
+
|
| 1730 |
+
if shutil.which("aria2c") is None:
|
| 1731 |
+
message = "aria2c belum tersedia di environment aplikasi."
|
| 1732 |
+
if wants_json_response():
|
| 1733 |
+
return action_response(message, ok=False, status_code=503)
|
| 1734 |
+
flash(message, "error")
|
| 1735 |
+
return redirect(url_for("index"))
|
| 1736 |
+
|
| 1737 |
+
try:
|
| 1738 |
+
_task_id, filename = aria2.start_download(url_or_error, DOWNLOAD_PATH, STATE_FILE, STATE_LOCK)
|
| 1739 |
+
update_state(lambda state: add_event(state, "info", f"Aria2 download dimulai: {filename}"))
|
| 1740 |
+
if wants_json_response():
|
| 1741 |
+
return action_response("Aria2 link berhasil ditambahkan.")
|
| 1742 |
+
flash("Aria2 link berhasil ditambahkan.", "success")
|
| 1743 |
+
except (OSError, requests.RequestException) as exc:
|
| 1744 |
+
if wants_json_response():
|
| 1745 |
+
return action_response(f"Gagal memulai Aria2 download: {exc}", ok=False, status_code=502)
|
| 1746 |
+
flash(f"Gagal memulai Aria2 download: {exc}", "error")
|
| 1747 |
+
return redirect(url_for("index"))
|
| 1748 |
|
| 1749 |
|
| 1750 |
@app.route("/api/torrents/<torrent_hash>/upload-gofile", methods=["POST"])
|
| 1751 |
+
def upload_torrent_to_gofile(torrent_hash: str):
|
| 1752 |
+
if is_aria2_task(torrent_hash):
|
| 1753 |
+
state = load_monitor_state()
|
| 1754 |
+
entry = state.get("aria2", {}).get(torrent_hash)
|
| 1755 |
+
if not entry:
|
| 1756 |
+
return action_response("Tugas Aria2 tidak ditemukan.", ok=False, status_code=404)
|
| 1757 |
+
if entry.get("gofile_uploading"):
|
| 1758 |
+
return action_response("Upload GoFile masih berjalan.", ok=False, status_code=409)
|
| 1759 |
+
file_path = Path(entry.get("file_path", "") or "")
|
| 1760 |
+
if not file_path.exists():
|
| 1761 |
+
return action_response("File Aria2 tidak ditemukan di storage.", ok=False, status_code=404)
|
| 1762 |
+
entry["gofile_uploading"] = True
|
| 1763 |
+
entry["gofile_progress"] = 0
|
| 1764 |
+
entry["gofile_speed"] = ""
|
| 1765 |
+
entry["gofile_eta_seconds"] = 0
|
| 1766 |
+
entry["gofile_cancel_requested"] = False
|
| 1767 |
+
entry["gofile_pid"] = 0
|
| 1768 |
+
entry["gofile_endpoint"] = ""
|
| 1769 |
+
entry["gofile_provider"] = "GoFile"
|
| 1770 |
+
entry["gofile_status"] = "Sedang upload ke GoFile..."
|
| 1771 |
+
entry["status_message"] = ""
|
| 1772 |
+
save_monitor_state(state)
|
| 1773 |
+
start_gofile_upload_background(torrent_hash, entry.get("name", file_path.name), file_path, mode="zip")
|
| 1774 |
+
return action_response("Upload Aria2 ke GoFile dimulai.")
|
| 1775 |
+
try:
|
| 1776 |
+
client = get_client()
|
| 1777 |
torrents = client.torrents_info(torrent_hashes=torrent_hash)
|
| 1778 |
if not torrents:
|
| 1779 |
return action_response("Torrent tidak ditemukan.", ok=False, status_code=404)
|
|
|
|
| 1793 |
return action_response("Raw folder upload GoFile memerlukan GOFILE_API_TOKEN.", ok=False, status_code=400)
|
| 1794 |
|
| 1795 |
state = load_monitor_state()
|
| 1796 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1797 |
if entry.get("gofile_uploading"):
|
| 1798 |
return action_response("Upload GoFile masih berjalan.", ok=False, status_code=409)
|
| 1799 |
|
|
|
|
| 1818 |
|
| 1819 |
|
| 1820 |
@app.route("/api/torrents/<torrent_hash>/cancel-gofile", methods=["POST"])
|
| 1821 |
+
def cancel_gofile_upload(torrent_hash: str):
|
| 1822 |
+
state = load_monitor_state()
|
| 1823 |
+
bucket_name = "aria2" if is_aria2_task(torrent_hash) else "torrents"
|
| 1824 |
+
entry = state.setdefault(bucket_name, {}).get(torrent_hash)
|
| 1825 |
+
if not entry or not entry.get("gofile_uploading"):
|
| 1826 |
+
return action_response("Upload GoFile tidak sedang berjalan.", ok=False, status_code=409)
|
| 1827 |
|
| 1828 |
provider = entry.get("gofile_provider", "upload")
|
| 1829 |
entry["gofile_cancel_requested"] = True
|
|
|
|
| 1836 |
|
| 1837 |
|
| 1838 |
@app.route("/api/torrents/<torrent_hash>/upload-pixeldrain", methods=["POST"])
|
| 1839 |
+
def upload_torrent_to_pixeldrain(torrent_hash: str):
|
| 1840 |
+
if not PIXELDRAIN_API_KEY:
|
| 1841 |
+
return action_response("PIXELDRAIN_API_KEY belum diset.", ok=False, status_code=400)
|
| 1842 |
+
|
| 1843 |
+
if is_aria2_task(torrent_hash):
|
| 1844 |
+
state = load_monitor_state()
|
| 1845 |
+
entry = state.get("aria2", {}).get(torrent_hash)
|
| 1846 |
+
if not entry:
|
| 1847 |
+
return action_response("Tugas Aria2 tidak ditemukan.", ok=False, status_code=404)
|
| 1848 |
+
if entry.get("gofile_uploading"):
|
| 1849 |
+
return action_response("Upload file eksternal masih berjalan.", ok=False, status_code=409)
|
| 1850 |
+
file_path = Path(entry.get("file_path", "") or "")
|
| 1851 |
+
if not file_path.exists():
|
| 1852 |
+
return action_response("File Aria2 tidak ditemukan di storage.", ok=False, status_code=404)
|
| 1853 |
+
entry["gofile_uploading"] = True
|
| 1854 |
+
entry["gofile_progress"] = 0
|
| 1855 |
+
entry["gofile_speed"] = ""
|
| 1856 |
+
entry["gofile_eta_seconds"] = 0
|
| 1857 |
+
entry["gofile_cancel_requested"] = False
|
| 1858 |
+
entry["gofile_pid"] = 0
|
| 1859 |
+
entry["gofile_endpoint"] = "pixeldrain"
|
| 1860 |
+
entry["gofile_provider"] = "PixelDrain"
|
| 1861 |
+
entry["gofile_status"] = "Sedang upload ke PixelDrain..."
|
| 1862 |
+
entry["status_message"] = ""
|
| 1863 |
+
save_monitor_state(state)
|
| 1864 |
+
start_pixeldrain_upload_background(torrent_hash, entry.get("name", file_path.name), file_path, mode="zip")
|
| 1865 |
+
return action_response("Upload Aria2 ke PixelDrain dimulai.")
|
| 1866 |
+
|
| 1867 |
+
try:
|
| 1868 |
+
client = get_client()
|
| 1869 |
torrents = client.torrents_info(torrent_hashes=torrent_hash)
|
| 1870 |
if not torrents:
|
| 1871 |
return action_response("Torrent tidak ditemukan.", ok=False, status_code=404)
|
|
|
|
| 1883 |
return action_response("Mode upload tidak valid.", ok=False, status_code=400)
|
| 1884 |
|
| 1885 |
state = load_monitor_state()
|
| 1886 |
+
entry = get_task_state_entry(state, torrent_hash)
|
| 1887 |
if entry.get("gofile_uploading"):
|
| 1888 |
return action_response("Upload file eksternal masih berjalan.", ok=False, status_code=409)
|
| 1889 |
|
aria2.py
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
import re
|
| 4 |
+
import signal
|
| 5 |
+
import subprocess
|
| 6 |
+
import threading
|
| 7 |
+
import time
|
| 8 |
+
import uuid
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
from urllib.parse import unquote, urlparse
|
| 11 |
+
|
| 12 |
+
import requests
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
ARIA2_STATE_KEY = "aria2"
|
| 16 |
+
CONTENT_DISPOSITION_FILENAME_PATTERN = re.compile(r'filename\*?=(?:UTF-8\'\')?"?([^\";]+)"?')
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def format_size(value: int | None) -> str:
|
| 20 |
+
if value in (None, 0):
|
| 21 |
+
return "0 B"
|
| 22 |
+
|
| 23 |
+
size = float(value)
|
| 24 |
+
units = ["B", "KB", "MB", "GB", "TB"]
|
| 25 |
+
for unit in units:
|
| 26 |
+
if size < 1024 or unit == units[-1]:
|
| 27 |
+
return f"{size:.1f} {unit}"
|
| 28 |
+
size /= 1024
|
| 29 |
+
return f"{size:.1f} TB"
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def format_speed(value: int | None) -> str:
|
| 33 |
+
return f"{format_size(value)}/s"
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def human_eta(seconds: float | int | None) -> str:
|
| 37 |
+
if seconds is None:
|
| 38 |
+
return "-"
|
| 39 |
+
|
| 40 |
+
total_seconds = int(seconds)
|
| 41 |
+
if total_seconds <= 0:
|
| 42 |
+
return "-"
|
| 43 |
+
|
| 44 |
+
if total_seconds < 60:
|
| 45 |
+
return f"{total_seconds} seconds left"
|
| 46 |
+
|
| 47 |
+
minutes = total_seconds // 60
|
| 48 |
+
if total_seconds < 3600:
|
| 49 |
+
return f"{minutes} minute left" if minutes == 1 else f"{minutes} minutes left"
|
| 50 |
+
|
| 51 |
+
if total_seconds < 86400:
|
| 52 |
+
hours = total_seconds // 3600
|
| 53 |
+
remaining_minutes = (total_seconds % 3600) // 60
|
| 54 |
+
if remaining_minutes == 0:
|
| 55 |
+
return f"{hours} hour left" if hours == 1 else f"{hours} hours left"
|
| 56 |
+
hour_label = "hour" if hours == 1 else "hours"
|
| 57 |
+
minute_label = "minute" if remaining_minutes == 1 else "minutes"
|
| 58 |
+
return f"{hours} {hour_label} {remaining_minutes} {minute_label} left"
|
| 59 |
+
|
| 60 |
+
days = total_seconds // 86400
|
| 61 |
+
remaining_hours = (total_seconds % 86400) // 3600
|
| 62 |
+
if remaining_hours == 0:
|
| 63 |
+
return f"{days} day left" if days == 1 else f"{days} days left"
|
| 64 |
+
day_label = "day" if days == 1 else "days"
|
| 65 |
+
hour_label = "hour" if remaining_hours == 1 else "hours"
|
| 66 |
+
return f"{days} {day_label} {remaining_hours} {hour_label} left"
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def validate_download_url(raw_value: str) -> tuple[bool, str]:
|
| 70 |
+
url = (raw_value or "").strip()
|
| 71 |
+
if not url:
|
| 72 |
+
return False, "Aria2 link wajib diisi."
|
| 73 |
+
|
| 74 |
+
parsed = urlparse(url)
|
| 75 |
+
if parsed.scheme.lower() not in {"http", "https"} or not parsed.netloc:
|
| 76 |
+
return False, "Aria2 hanya menerima URL http atau https yang valid."
|
| 77 |
+
|
| 78 |
+
return True, url
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def ensure_state_defaults(state: dict) -> dict:
|
| 82 |
+
return state.setdefault(ARIA2_STATE_KEY, {})
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def load_state(state_file: Path, state_lock: threading.Lock) -> dict:
|
| 86 |
+
with state_lock:
|
| 87 |
+
if not state_file.exists():
|
| 88 |
+
return {"torrents": {}, "events": [], "system": {}, "speedtest": {"running": False}, ARIA2_STATE_KEY: {}}
|
| 89 |
+
try:
|
| 90 |
+
data = json.loads(state_file.read_text(encoding="utf-8"))
|
| 91 |
+
except (json.JSONDecodeError, OSError):
|
| 92 |
+
return {"torrents": {}, "events": [], "system": {}, "speedtest": {"running": False}, ARIA2_STATE_KEY: {}}
|
| 93 |
+
|
| 94 |
+
data.setdefault("torrents", {})
|
| 95 |
+
data.setdefault("events", [])
|
| 96 |
+
data.setdefault("system", {})
|
| 97 |
+
data.setdefault("speedtest", {"running": False})
|
| 98 |
+
data.setdefault(ARIA2_STATE_KEY, {})
|
| 99 |
+
return data
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def save_state(state_file: Path, state_lock: threading.Lock, state: dict) -> None:
|
| 103 |
+
with state_lock:
|
| 104 |
+
temp_file = state_file.with_suffix(".tmp")
|
| 105 |
+
temp_file.write_text(json.dumps(state, ensure_ascii=True, indent=2), encoding="utf-8")
|
| 106 |
+
temp_file.replace(state_file)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def update_state(state_file: Path, state_lock: threading.Lock, mutator) -> None:
|
| 110 |
+
state = load_state(state_file, state_lock)
|
| 111 |
+
mutator(state)
|
| 112 |
+
save_state(state_file, state_lock, state)
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def add_event(state_file: Path, state_lock: threading.Lock, level: str, message: str) -> None:
|
| 116 |
+
def mutator(state: dict):
|
| 117 |
+
state.setdefault("events", []).insert(
|
| 118 |
+
0,
|
| 119 |
+
{
|
| 120 |
+
"level": level,
|
| 121 |
+
"message": message,
|
| 122 |
+
"created_at": int(time.time()),
|
| 123 |
+
},
|
| 124 |
+
)
|
| 125 |
+
state["events"] = state["events"][:12]
|
| 126 |
+
|
| 127 |
+
update_state(state_file, state_lock, mutator)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def derive_filename(url: str, headers: dict[str, str]) -> str:
|
| 131 |
+
content_disposition = headers.get("content-disposition", "")
|
| 132 |
+
match = CONTENT_DISPOSITION_FILENAME_PATTERN.search(content_disposition)
|
| 133 |
+
if match:
|
| 134 |
+
return Path(unquote(match.group(1).strip())).name or "download.bin"
|
| 135 |
+
|
| 136 |
+
parsed = urlparse(url)
|
| 137 |
+
name = Path(unquote(parsed.path)).name
|
| 138 |
+
return name or "download.bin"
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
def inspect_remote_file(url: str) -> tuple[str, int]:
|
| 142 |
+
try:
|
| 143 |
+
response = requests.head(url, allow_redirects=True, timeout=20)
|
| 144 |
+
response.raise_for_status()
|
| 145 |
+
final_url = response.url
|
| 146 |
+
headers = {key.lower(): value for key, value in response.headers.items()}
|
| 147 |
+
total_bytes = int(headers.get("content-length", "0") or "0")
|
| 148 |
+
return derive_filename(final_url, headers), total_bytes
|
| 149 |
+
except requests.RequestException:
|
| 150 |
+
return derive_filename(url, {}), 0
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def serialize_task(task: dict) -> dict:
|
| 154 |
+
state_value = task.get("state", "downloading")
|
| 155 |
+
progress = int(task.get("progress", 0) or 0)
|
| 156 |
+
total_bytes = int(task.get("total_bytes", 0) or 0)
|
| 157 |
+
downloaded_bytes = int(task.get("downloaded_bytes", 0) or 0)
|
| 158 |
+
status_map = {
|
| 159 |
+
"downloading": "Aria2 Download",
|
| 160 |
+
"complete": "Completed",
|
| 161 |
+
"error": "Failed",
|
| 162 |
+
"cancelled": "Cancelled",
|
| 163 |
+
"paused": "Paused",
|
| 164 |
+
}
|
| 165 |
+
badge_map = {
|
| 166 |
+
"downloading": "border-cyan-500/30 bg-cyan-500/10 text-cyan-100",
|
| 167 |
+
"complete": "border-emerald-500/30 bg-emerald-500/10 text-emerald-100",
|
| 168 |
+
"error": "border-rose-500/30 bg-rose-500/10 text-rose-100",
|
| 169 |
+
"cancelled": "border-stone-500/30 bg-stone-500/10 text-stone-200",
|
| 170 |
+
"paused": "border-stone-500/30 bg-stone-500/10 text-stone-200",
|
| 171 |
+
}
|
| 172 |
+
file_path = Path(task.get("file_path", "") or "")
|
| 173 |
+
gofile_uploading = bool(task.get("gofile_uploading"))
|
| 174 |
+
can_remote_upload = state_value == "complete" and file_path.exists() and not gofile_uploading
|
| 175 |
+
|
| 176 |
+
return {
|
| 177 |
+
"hash": task.get("id", ""),
|
| 178 |
+
"name": task.get("name", "Aria2 Download"),
|
| 179 |
+
"state": "downloading" if state_value == "downloading" else state_value,
|
| 180 |
+
"state_label": status_map.get(state_value, "Aria2 Download"),
|
| 181 |
+
"state_badge": badge_map.get(state_value, badge_map["downloading"]),
|
| 182 |
+
"total_size": format_size(total_bytes),
|
| 183 |
+
"downloaded": format_size(downloaded_bytes),
|
| 184 |
+
"uploaded": "0 B",
|
| 185 |
+
"ratio": "-",
|
| 186 |
+
"dlspeed": format_speed(int(task.get("download_speed", 0) or 0)),
|
| 187 |
+
"upspeed": "0 B/s",
|
| 188 |
+
"display_speed": format_speed(int(task.get("download_speed", 0) or 0)),
|
| 189 |
+
"display_speed_label": "Down",
|
| 190 |
+
"display_speed_meta": "",
|
| 191 |
+
"progress": progress,
|
| 192 |
+
"progress_label": "Progress",
|
| 193 |
+
"num_seeds": 0,
|
| 194 |
+
"num_leechs": 0,
|
| 195 |
+
"eta": human_eta(task.get("eta_seconds", 0)),
|
| 196 |
+
"status_message": task.get("status_message", ""),
|
| 197 |
+
"can_pause": state_value == "downloading" and not gofile_uploading,
|
| 198 |
+
"can_resume": state_value == "paused",
|
| 199 |
+
"can_gofile_upload": can_remote_upload,
|
| 200 |
+
"gofile_link": task.get("gofile_link", ""),
|
| 201 |
+
"gofile_status": task.get("gofile_status", ""),
|
| 202 |
+
"gofile_uploading": gofile_uploading,
|
| 203 |
+
"gofile_speed": task.get("gofile_speed", ""),
|
| 204 |
+
"gofile_eta": human_eta(task.get("gofile_eta_seconds", 0)) if gofile_uploading else "-",
|
| 205 |
+
"gofile_endpoint": task.get("gofile_endpoint", ""),
|
| 206 |
+
"upload_provider": task.get("gofile_provider", ""),
|
| 207 |
+
"can_copy_link": bool(task.get("gofile_link")),
|
| 208 |
+
"can_cancel_gofile_upload": gofile_uploading,
|
| 209 |
+
"can_pixeldrain_upload": can_remote_upload,
|
| 210 |
+
"is_folder": False,
|
| 211 |
+
"can_raw_gofile_upload": False,
|
| 212 |
+
"can_raw_pixeldrain_upload": False,
|
| 213 |
+
"task_kind": "aria2",
|
| 214 |
+
"added_at": int(task.get("created_at", 0) or 0),
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def _kill_process(pid: int | None) -> None:
|
| 219 |
+
if not pid:
|
| 220 |
+
return
|
| 221 |
+
try:
|
| 222 |
+
os.kill(pid, signal.SIGTERM)
|
| 223 |
+
except OSError:
|
| 224 |
+
pass
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
def _monitor_download(task_id: str, file_path: Path, process: subprocess.Popen, state_file: Path, state_lock: threading.Lock) -> None:
|
| 228 |
+
last_size = 0
|
| 229 |
+
last_at = time.time()
|
| 230 |
+
|
| 231 |
+
while process.poll() is None:
|
| 232 |
+
now = time.time()
|
| 233 |
+
current_size = file_path.stat().st_size if file_path.exists() else 0
|
| 234 |
+
elapsed = max(now - last_at, 0.001)
|
| 235 |
+
speed = max(0, int((current_size - last_size) / elapsed))
|
| 236 |
+
|
| 237 |
+
def mutator(state: dict):
|
| 238 |
+
entry = ensure_state_defaults(state).get(task_id)
|
| 239 |
+
if not entry:
|
| 240 |
+
return
|
| 241 |
+
if entry.get("state") == "paused":
|
| 242 |
+
entry["download_speed"] = 0
|
| 243 |
+
entry["eta_seconds"] = 0
|
| 244 |
+
return
|
| 245 |
+
total_bytes = int(entry.get("total_bytes", 0) or 0)
|
| 246 |
+
entry["downloaded_bytes"] = current_size
|
| 247 |
+
entry["download_speed"] = speed
|
| 248 |
+
entry["progress"] = int((current_size / total_bytes) * 100) if total_bytes > 0 else entry.get("progress", 0)
|
| 249 |
+
if total_bytes > current_size and speed > 0:
|
| 250 |
+
entry["eta_seconds"] = int((total_bytes - current_size) / speed)
|
| 251 |
+
else:
|
| 252 |
+
entry["eta_seconds"] = 0
|
| 253 |
+
entry["state"] = "downloading"
|
| 254 |
+
|
| 255 |
+
update_state(state_file, state_lock, mutator)
|
| 256 |
+
last_size = current_size
|
| 257 |
+
last_at = now
|
| 258 |
+
time.sleep(1)
|
| 259 |
+
|
| 260 |
+
current_size = file_path.stat().st_size if file_path.exists() else 0
|
| 261 |
+
stdout = process.stdout.read() if process.stdout else ""
|
| 262 |
+
stderr = process.stderr.read() if process.stderr else ""
|
| 263 |
+
if process.returncode == 0:
|
| 264 |
+
def success_mutator(state: dict):
|
| 265 |
+
entry = ensure_state_defaults(state).get(task_id)
|
| 266 |
+
if not entry:
|
| 267 |
+
return
|
| 268 |
+
total_bytes = max(int(entry.get("total_bytes", 0) or 0), current_size)
|
| 269 |
+
entry["downloaded_bytes"] = total_bytes
|
| 270 |
+
entry["total_bytes"] = total_bytes
|
| 271 |
+
entry["download_speed"] = 0
|
| 272 |
+
entry["eta_seconds"] = 0
|
| 273 |
+
entry["progress"] = 100
|
| 274 |
+
entry["pid"] = 0
|
| 275 |
+
entry["state"] = "complete"
|
| 276 |
+
entry["status_message"] = "Download selesai."
|
| 277 |
+
|
| 278 |
+
update_state(state_file, state_lock, success_mutator)
|
| 279 |
+
add_event(state_file, state_lock, "info", f"Aria2 download selesai: {file_path.name}")
|
| 280 |
+
return
|
| 281 |
+
|
| 282 |
+
def error_mutator(state: dict):
|
| 283 |
+
entry = ensure_state_defaults(state).get(task_id)
|
| 284 |
+
if not entry:
|
| 285 |
+
return
|
| 286 |
+
entry["downloaded_bytes"] = current_size
|
| 287 |
+
entry["download_speed"] = 0
|
| 288 |
+
entry["eta_seconds"] = 0
|
| 289 |
+
entry["pid"] = 0
|
| 290 |
+
if entry.get("state") != "cancelled":
|
| 291 |
+
entry["state"] = "error"
|
| 292 |
+
detail = (stderr or stdout).strip().splitlines()
|
| 293 |
+
entry["status_message"] = detail[-1][:300] if detail else "Download gagal."
|
| 294 |
+
|
| 295 |
+
update_state(state_file, state_lock, error_mutator)
|
| 296 |
+
add_event(state_file, state_lock, "error", f"Aria2 download gagal: {file_path.name}")
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
def start_download(url: str, download_dir: str, state_file: Path, state_lock: threading.Lock) -> tuple[str, str]:
|
| 300 |
+
filename, total_bytes = inspect_remote_file(url)
|
| 301 |
+
task_id = f"aria2_{uuid.uuid4().hex[:12]}"
|
| 302 |
+
created_at = int(time.time())
|
| 303 |
+
target_dir = Path(download_dir)
|
| 304 |
+
target_dir.mkdir(parents=True, exist_ok=True)
|
| 305 |
+
file_path = target_dir / filename
|
| 306 |
+
command = [
|
| 307 |
+
"aria2c",
|
| 308 |
+
"--dir",
|
| 309 |
+
str(target_dir),
|
| 310 |
+
"--out",
|
| 311 |
+
filename,
|
| 312 |
+
"--allow-overwrite=true",
|
| 313 |
+
"--auto-file-renaming=false",
|
| 314 |
+
"--file-allocation=none",
|
| 315 |
+
"--summary-interval=0",
|
| 316 |
+
"--console-log-level=warn",
|
| 317 |
+
url,
|
| 318 |
+
]
|
| 319 |
+
|
| 320 |
+
process = subprocess.Popen(
|
| 321 |
+
command,
|
| 322 |
+
stdout=subprocess.PIPE,
|
| 323 |
+
stderr=subprocess.PIPE,
|
| 324 |
+
text=True,
|
| 325 |
+
)
|
| 326 |
+
|
| 327 |
+
def mutator(state: dict):
|
| 328 |
+
ensure_state_defaults(state)[task_id] = {
|
| 329 |
+
"id": task_id,
|
| 330 |
+
"name": filename,
|
| 331 |
+
"url": url,
|
| 332 |
+
"file_path": str(file_path),
|
| 333 |
+
"created_at": created_at,
|
| 334 |
+
"pid": process.pid,
|
| 335 |
+
"state": "downloading",
|
| 336 |
+
"progress": 0,
|
| 337 |
+
"downloaded_bytes": 0,
|
| 338 |
+
"total_bytes": total_bytes,
|
| 339 |
+
"download_speed": 0,
|
| 340 |
+
"eta_seconds": 0,
|
| 341 |
+
"gofile_progress": 0,
|
| 342 |
+
"gofile_uploading": False,
|
| 343 |
+
"gofile_speed": "",
|
| 344 |
+
"gofile_eta_seconds": 0,
|
| 345 |
+
"gofile_cancel_requested": False,
|
| 346 |
+
"gofile_pid": 0,
|
| 347 |
+
"gofile_endpoint": "",
|
| 348 |
+
"gofile_provider": "",
|
| 349 |
+
"gofile_status": "",
|
| 350 |
+
"gofile_link": "",
|
| 351 |
+
"status_message": "",
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
update_state(state_file, state_lock, mutator)
|
| 355 |
+
threading.Thread(
|
| 356 |
+
target=_monitor_download,
|
| 357 |
+
args=(task_id, file_path, process, state_file, state_lock),
|
| 358 |
+
daemon=True,
|
| 359 |
+
).start()
|
| 360 |
+
return task_id, filename
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
def delete_task(task_id: str, state_file: Path, state_lock: threading.Lock, delete_files: bool) -> tuple[bool, str]:
|
| 364 |
+
state = load_state(state_file, state_lock)
|
| 365 |
+
entry = ensure_state_defaults(state).get(task_id)
|
| 366 |
+
if not entry:
|
| 367 |
+
return False, "Tugas Aria2 tidak ditemukan."
|
| 368 |
+
|
| 369 |
+
pid = int(entry.get("pid", 0) or 0)
|
| 370 |
+
_kill_process(pid)
|
| 371 |
+
|
| 372 |
+
file_path = Path(entry.get("file_path", "") or "")
|
| 373 |
+
if delete_files and file_path.exists():
|
| 374 |
+
file_path.unlink(missing_ok=True)
|
| 375 |
+
partial_path = Path(f"{file_path}.aria2")
|
| 376 |
+
partial_path.unlink(missing_ok=True)
|
| 377 |
+
|
| 378 |
+
del state[ARIA2_STATE_KEY][task_id]
|
| 379 |
+
save_state(state_file, state_lock, state)
|
| 380 |
+
return True, "Tugas Aria2 dihapus."
|
| 381 |
+
|
| 382 |
+
|
| 383 |
+
def pause_task(task_id: str, state_file: Path, state_lock: threading.Lock) -> tuple[bool, str]:
|
| 384 |
+
state = load_state(state_file, state_lock)
|
| 385 |
+
entry = ensure_state_defaults(state).get(task_id)
|
| 386 |
+
if not entry:
|
| 387 |
+
return False, "Tugas Aria2 tidak ditemukan."
|
| 388 |
+
if entry.get("state") != "downloading":
|
| 389 |
+
return False, "Tugas Aria2 tidak bisa dijeda."
|
| 390 |
+
|
| 391 |
+
pid = int(entry.get("pid", 0) or 0)
|
| 392 |
+
if not pid:
|
| 393 |
+
return False, "Process Aria2 tidak ditemukan."
|
| 394 |
+
try:
|
| 395 |
+
os.kill(pid, signal.SIGSTOP)
|
| 396 |
+
except OSError as exc:
|
| 397 |
+
return False, f"Gagal pause Aria2: {exc}"
|
| 398 |
+
|
| 399 |
+
entry["state"] = "paused"
|
| 400 |
+
entry["download_speed"] = 0
|
| 401 |
+
entry["eta_seconds"] = 0
|
| 402 |
+
entry["status_message"] = ""
|
| 403 |
+
save_state(state_file, state_lock, state)
|
| 404 |
+
return True, "Tugas Aria2 dijeda."
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
def resume_task(task_id: str, state_file: Path, state_lock: threading.Lock) -> tuple[bool, str]:
|
| 408 |
+
state = load_state(state_file, state_lock)
|
| 409 |
+
entry = ensure_state_defaults(state).get(task_id)
|
| 410 |
+
if not entry:
|
| 411 |
+
return False, "Tugas Aria2 tidak ditemukan."
|
| 412 |
+
if entry.get("state") != "paused":
|
| 413 |
+
return False, "Tugas Aria2 tidak bisa dilanjutkan."
|
| 414 |
+
|
| 415 |
+
pid = int(entry.get("pid", 0) or 0)
|
| 416 |
+
if not pid:
|
| 417 |
+
return False, "Process Aria2 tidak ditemukan."
|
| 418 |
+
try:
|
| 419 |
+
os.kill(pid, signal.SIGCONT)
|
| 420 |
+
except OSError as exc:
|
| 421 |
+
return False, f"Gagal melanjutkan Aria2: {exc}"
|
| 422 |
+
|
| 423 |
+
entry["state"] = "downloading"
|
| 424 |
+
entry["status_message"] = ""
|
| 425 |
+
save_state(state_file, state_lock, state)
|
| 426 |
+
return True, "Tugas Aria2 dilanjutkan."
|
downloads/10Mb.dat
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f87420f29adc93691a08e833bc145acdd59a0d0e32bd5734b855e4182ad69e71
|
| 3 |
+
size 7340032
|
downloads/10Mb.dat.aria2
ADDED
|
Binary file (60 Bytes). View file
|
|
|
downloads/1Mb.dat
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:66f77f71710117f71712eb5766f3151e8aecec390ebe0b0349c84961f1a547e6
|
| 3 |
+
size 1048576
|
qbittorrent/config/qBittorrent.conf
CHANGED
|
@@ -1,40 +1,40 @@
|
|
| 1 |
-
[BitTorrent]
|
| 2 |
Session\AddTorrentStopped=false
|
| 3 |
Session\Port=6881
|
| 4 |
-
Session\QueueingSystemEnabled=true
|
| 5 |
Session\SSL\Port=14906
|
| 6 |
Session\ShareLimitAction=Stop
|
| 7 |
-
|
| 8 |
-
[LegalNotice]
|
| 9 |
-
Accepted=true
|
| 10 |
-
|
| 11 |
-
[Meta]
|
| 12 |
-
MigrationVersion=8
|
| 13 |
-
|
| 14 |
-
[Network]
|
| 15 |
-
Cookies=@Invalid()
|
| 16 |
-
PortForwarding\Enabled=true
|
| 17 |
-
Proxy\HostnameLookupEnabled=false
|
| 18 |
-
Proxy\Profiles\BitTorrent=true
|
| 19 |
-
Proxy\Profiles\Misc=true
|
| 20 |
-
Proxy\Profiles\RSS=true
|
| 21 |
-
|
| 22 |
-
[Preferences]
|
| 23 |
-
WebUI\Address=*
|
| 24 |
-
WebUI\AlternativeUIEnabled=false
|
| 25 |
-
WebUI\AuthSubnetWhitelist=172.16.0.0/12
|
| 26 |
-
WebUI\AuthSubnetWhitelistEnabled=true
|
| 27 |
-
WebUI\CSRFProtection=false
|
| 28 |
-
WebUI\ClickjackingProtection=false
|
| 29 |
-
WebUI\HostHeaderValidation=false
|
| 30 |
-
WebUI\LocalHostAuth=false
|
| 31 |
-
WebUI\Password_PBKDF2="@ByteArray(E1RCsaqF6BN+2zLheBJUIw==:rHiHGB4E2rSO4aze8Fw0XEOsWky1Ff9Y4YMC+qqEVyHrFoS6cLEXbR7W+T/35DK1YFMJc9W3BGDAmhfX1Bu0Qg==)"
|
| 32 |
-
WebUI\Port=8080
|
| 33 |
-
WebUI\RootFolder=
|
| 34 |
-
WebUI\ServerDomains=*
|
| 35 |
-
WebUI\UseUPnP=false
|
| 36 |
-
WebUI\Username=admin
|
| 37 |
-
|
| 38 |
-
[Session]
|
| 39 |
-
DefaultSavePath=/downloads
|
| 40 |
-
TempPath=/downloads/incomplete
|
|
|
|
| 1 |
+
[BitTorrent]
|
| 2 |
Session\AddTorrentStopped=false
|
| 3 |
Session\Port=6881
|
| 4 |
+
Session\QueueingSystemEnabled=true
|
| 5 |
Session\SSL\Port=14906
|
| 6 |
Session\ShareLimitAction=Stop
|
| 7 |
+
|
| 8 |
+
[LegalNotice]
|
| 9 |
+
Accepted=true
|
| 10 |
+
|
| 11 |
+
[Meta]
|
| 12 |
+
MigrationVersion=8
|
| 13 |
+
|
| 14 |
+
[Network]
|
| 15 |
+
Cookies=@Invalid()
|
| 16 |
+
PortForwarding\Enabled=true
|
| 17 |
+
Proxy\HostnameLookupEnabled=false
|
| 18 |
+
Proxy\Profiles\BitTorrent=true
|
| 19 |
+
Proxy\Profiles\Misc=true
|
| 20 |
+
Proxy\Profiles\RSS=true
|
| 21 |
+
|
| 22 |
+
[Preferences]
|
| 23 |
+
WebUI\Address=*
|
| 24 |
+
WebUI\AlternativeUIEnabled=false
|
| 25 |
+
WebUI\AuthSubnetWhitelist=172.16.0.0/12
|
| 26 |
+
WebUI\AuthSubnetWhitelistEnabled=true
|
| 27 |
+
WebUI\CSRFProtection=false
|
| 28 |
+
WebUI\ClickjackingProtection=false
|
| 29 |
+
WebUI\HostHeaderValidation=false
|
| 30 |
+
WebUI\LocalHostAuth=false
|
| 31 |
+
WebUI\Password_PBKDF2="@ByteArray(E1RCsaqF6BN+2zLheBJUIw==:rHiHGB4E2rSO4aze8Fw0XEOsWky1Ff9Y4YMC+qqEVyHrFoS6cLEXbR7W+T/35DK1YFMJc9W3BGDAmhfX1Bu0Qg==)"
|
| 32 |
+
WebUI\Port=8080
|
| 33 |
+
WebUI\RootFolder=
|
| 34 |
+
WebUI\ServerDomains=*
|
| 35 |
+
WebUI\UseUPnP=false
|
| 36 |
+
WebUI\Username=admin
|
| 37 |
+
|
| 38 |
+
[Session]
|
| 39 |
+
DefaultSavePath=/downloads
|
| 40 |
+
TempPath=/downloads/incomplete
|
qbittorrent/config/qBittorrent/config/qBittorrent-data.conf
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
[Stats]
|
| 2 |
-
AllStats=@Variant(\0\0\0\x1c\0\0\0\x2\0\0\0\x12\0\x41\0l\0l\0t\0i\0m\0\x65\
|
|
|
|
| 1 |
[Stats]
|
| 2 |
+
AllStats=@Variant(\0\0\0\x1c\0\0\0\x2\0\0\0\x12\0\x41\0l\0l\0t\0i\0m\0\x65\0\x44\0L\0\0\0\x4\0\0\0\x1\x33\x9a\x9f\xee\0\0\0\x12\0\x41\0l\0l\0t\0i\0m\0\x65\0U\0L\0\0\0\x4\0\0\0\0G\xacI\xca)
|
qbittorrent/config/qBittorrent/config/qBittorrent.conf
CHANGED
|
@@ -1,40 +1,40 @@
|
|
| 1 |
-
[BitTorrent]
|
| 2 |
Session\AddTorrentStopped=false
|
| 3 |
Session\Port=6881
|
| 4 |
-
Session\QueueingSystemEnabled=true
|
| 5 |
Session\SSL\Port=14906
|
| 6 |
Session\ShareLimitAction=Stop
|
| 7 |
-
|
| 8 |
-
[LegalNotice]
|
| 9 |
-
Accepted=true
|
| 10 |
-
|
| 11 |
-
[Meta]
|
| 12 |
-
MigrationVersion=8
|
| 13 |
-
|
| 14 |
-
[Network]
|
| 15 |
-
Cookies=@Invalid()
|
| 16 |
-
PortForwarding\Enabled=true
|
| 17 |
-
Proxy\HostnameLookupEnabled=false
|
| 18 |
-
Proxy\Profiles\BitTorrent=true
|
| 19 |
-
Proxy\Profiles\Misc=true
|
| 20 |
-
Proxy\Profiles\RSS=true
|
| 21 |
-
|
| 22 |
-
[Preferences]
|
| 23 |
-
WebUI\Address=*
|
| 24 |
-
WebUI\AlternativeUIEnabled=false
|
| 25 |
-
WebUI\AuthSubnetWhitelist=172.16.0.0/12
|
| 26 |
-
WebUI\AuthSubnetWhitelistEnabled=true
|
| 27 |
-
WebUI\CSRFProtection=false
|
| 28 |
-
WebUI\ClickjackingProtection=false
|
| 29 |
-
WebUI\HostHeaderValidation=false
|
| 30 |
-
WebUI\LocalHostAuth=false
|
| 31 |
-
WebUI\Password_PBKDF2="@ByteArray(E1RCsaqF6BN+2zLheBJUIw==:rHiHGB4E2rSO4aze8Fw0XEOsWky1Ff9Y4YMC+qqEVyHrFoS6cLEXbR7W+T/35DK1YFMJc9W3BGDAmhfX1Bu0Qg==)"
|
| 32 |
-
WebUI\Port=8080
|
| 33 |
-
WebUI\RootFolder=
|
| 34 |
-
WebUI\ServerDomains=*
|
| 35 |
-
WebUI\UseUPnP=false
|
| 36 |
-
WebUI\Username=admin
|
| 37 |
-
|
| 38 |
-
[Session]
|
| 39 |
-
DefaultSavePath=/downloads
|
| 40 |
-
TempPath=/downloads/incomplete
|
|
|
|
| 1 |
+
[BitTorrent]
|
| 2 |
Session\AddTorrentStopped=false
|
| 3 |
Session\Port=6881
|
| 4 |
+
Session\QueueingSystemEnabled=true
|
| 5 |
Session\SSL\Port=14906
|
| 6 |
Session\ShareLimitAction=Stop
|
| 7 |
+
|
| 8 |
+
[LegalNotice]
|
| 9 |
+
Accepted=true
|
| 10 |
+
|
| 11 |
+
[Meta]
|
| 12 |
+
MigrationVersion=8
|
| 13 |
+
|
| 14 |
+
[Network]
|
| 15 |
+
Cookies=@Invalid()
|
| 16 |
+
PortForwarding\Enabled=true
|
| 17 |
+
Proxy\HostnameLookupEnabled=false
|
| 18 |
+
Proxy\Profiles\BitTorrent=true
|
| 19 |
+
Proxy\Profiles\Misc=true
|
| 20 |
+
Proxy\Profiles\RSS=true
|
| 21 |
+
|
| 22 |
+
[Preferences]
|
| 23 |
+
WebUI\Address=*
|
| 24 |
+
WebUI\AlternativeUIEnabled=false
|
| 25 |
+
WebUI\AuthSubnetWhitelist=172.16.0.0/12
|
| 26 |
+
WebUI\AuthSubnetWhitelistEnabled=true
|
| 27 |
+
WebUI\CSRFProtection=false
|
| 28 |
+
WebUI\ClickjackingProtection=false
|
| 29 |
+
WebUI\HostHeaderValidation=false
|
| 30 |
+
WebUI\LocalHostAuth=false
|
| 31 |
+
WebUI\Password_PBKDF2="@ByteArray(E1RCsaqF6BN+2zLheBJUIw==:rHiHGB4E2rSO4aze8Fw0XEOsWky1Ff9Y4YMC+qqEVyHrFoS6cLEXbR7W+T/35DK1YFMJc9W3BGDAmhfX1Bu0Qg==)"
|
| 32 |
+
WebUI\Port=8080
|
| 33 |
+
WebUI\RootFolder=
|
| 34 |
+
WebUI\ServerDomains=*
|
| 35 |
+
WebUI\UseUPnP=false
|
| 36 |
+
WebUI\Username=admin
|
| 37 |
+
|
| 38 |
+
[Session]
|
| 39 |
+
DefaultSavePath=/downloads
|
| 40 |
+
TempPath=/downloads/incomplete
|
static/app.js
CHANGED
|
@@ -34,14 +34,17 @@
|
|
| 34 |
summaryAllTimeUpload: document.getElementById("summary-all-time-upload"),
|
| 35 |
openAddModal: document.getElementById("open-add-modal"),
|
| 36 |
addModal: document.getElementById("add-modal"),
|
| 37 |
-
addModalClose: document.getElementById("add-modal-close"),
|
| 38 |
-
addTabMagnet: document.getElementById("add-tab-magnet"),
|
| 39 |
-
addTabFile: document.getElementById("add-tab-file"),
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
torrentFileName: document.getElementById("torrent-file-name"),
|
| 46 |
deleteModal: document.getElementById("delete-modal"),
|
| 47 |
deleteModalText: document.getElementById("delete-modal-text"),
|
|
@@ -106,6 +109,38 @@
|
|
| 106 |
};
|
| 107 |
}
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
const label = normalizeStateLabel(torrent.state_label);
|
| 110 |
if (label.includes("download")) {
|
| 111 |
return {
|
|
@@ -228,6 +263,26 @@
|
|
| 228 |
if (!torrent) {
|
| 229 |
return;
|
| 230 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
const progress = Number(torrent.progress || 0);
|
| 232 |
const isComplete = progress >= 100;
|
| 233 |
|
|
@@ -267,6 +322,34 @@
|
|
| 267 |
return;
|
| 268 |
}
|
| 269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
const rawState = String(torrent.state || "");
|
| 271 |
if (optimisticAction === "pause") {
|
| 272 |
const serverPaused = ["pausedDL", "pausedUP"].includes(rawState);
|
|
@@ -360,11 +443,14 @@
|
|
| 360 |
if (state.activeFilter === "completed") {
|
| 361 |
return progress >= 100 || label.includes("complete");
|
| 362 |
}
|
| 363 |
-
if (state.activeFilter === "uploading") {
|
| 364 |
-
return !!torrent.gofile_uploading;
|
| 365 |
-
}
|
| 366 |
-
|
| 367 |
-
|
|
|
|
|
|
|
|
|
|
| 368 |
|
| 369 |
function matchesSearch(torrent) {
|
| 370 |
if (!state.searchTerm) {
|
|
@@ -641,18 +727,24 @@
|
|
| 641 |
</button>
|
| 642 |
</div>`
|
| 643 |
: "";
|
| 644 |
-
const endpointMeta = torrent.
|
| 645 |
-
? `<span class="rounded-full border border-
|
| 646 |
-
:
|
|
|
|
|
|
|
| 647 |
const statusIconName = torrent.gofile_uploading
|
| 648 |
? "fa-cloud-arrow-up"
|
|
|
|
|
|
|
| 649 |
: isSeeding
|
| 650 |
-
? "fa-arrow-up"
|
| 651 |
-
: isDownloading
|
| 652 |
? "fa-arrow-down"
|
| 653 |
: "fa-circle";
|
| 654 |
const statusIconTone = torrent.gofile_uploading
|
| 655 |
? "bg-violet/10 text-violet"
|
|
|
|
|
|
|
| 656 |
: isSeeding
|
| 657 |
? "bg-lime/10 text-lime"
|
| 658 |
: isDownloading
|
|
@@ -840,19 +932,26 @@
|
|
| 840 |
hideModal(elements.addModal);
|
| 841 |
}
|
| 842 |
|
| 843 |
-
function showAddTab(tab) {
|
| 844 |
-
const isMagnet = tab === "magnet";
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
elements.addTabMagnet.
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
elements.
|
| 851 |
-
? "add-tab font-display rounded-[14px] border border-white/10 bg-neon px-3 py-2 text-sm font-semibold text-ink transition"
|
| 852 |
-
: "add-tab font-display rounded-[14px] border border-transparent bg-transparent px-3 py-2 text-sm font-semibold text-stone-400 transition hover:text-white";
|
| 853 |
-
elements.
|
| 854 |
-
|
| 855 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 856 |
|
| 857 |
function syncTorrentFileName() {
|
| 858 |
if (!elements.torrentFileName) {
|
|
@@ -1177,18 +1276,23 @@
|
|
| 1177 |
document.querySelectorAll("[data-close-add-modal]").forEach((button) => {
|
| 1178 |
button.addEventListener("click", closeAddModal);
|
| 1179 |
});
|
| 1180 |
-
elements.addTabMagnet?.addEventListener("click", () => showAddTab("magnet"));
|
| 1181 |
-
elements.addTabFile?.addEventListener("click", () => showAddTab("file"));
|
| 1182 |
-
elements.
|
|
|
|
| 1183 |
|
| 1184 |
elements.magnetForm?.addEventListener("submit", async (event) => {
|
| 1185 |
event.preventDefault();
|
| 1186 |
await submitFormWithToast(elements.magnetForm, "Magnet link berhasil ditambahkan.");
|
| 1187 |
});
|
| 1188 |
-
elements.torrentUploadForm?.addEventListener("submit", async (event) => {
|
| 1189 |
-
event.preventDefault();
|
| 1190 |
-
await submitFormWithToast(elements.torrentUploadForm, "File torrent berhasil diunggah.");
|
| 1191 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1192 |
|
| 1193 |
elements.modalClose?.addEventListener("click", closeDeleteModal);
|
| 1194 |
elements.modalCancel?.addEventListener("click", closeDeleteModal);
|
|
|
|
| 34 |
summaryAllTimeUpload: document.getElementById("summary-all-time-upload"),
|
| 35 |
openAddModal: document.getElementById("open-add-modal"),
|
| 36 |
addModal: document.getElementById("add-modal"),
|
| 37 |
+
addModalClose: document.getElementById("add-modal-close"),
|
| 38 |
+
addTabMagnet: document.getElementById("add-tab-magnet"),
|
| 39 |
+
addTabFile: document.getElementById("add-tab-file"),
|
| 40 |
+
addTabAria2: document.getElementById("add-tab-aria2"),
|
| 41 |
+
addPanelMagnet: document.getElementById("add-panel-magnet"),
|
| 42 |
+
addPanelFile: document.getElementById("add-panel-file"),
|
| 43 |
+
addPanelAria2: document.getElementById("add-panel-aria2"),
|
| 44 |
+
magnetForm: document.getElementById("magnet-form"),
|
| 45 |
+
torrentUploadForm: document.getElementById("torrent-upload-form"),
|
| 46 |
+
aria2Form: document.getElementById("aria2-form"),
|
| 47 |
+
torrentFileInput: document.getElementById("torrent-file-input"),
|
| 48 |
torrentFileName: document.getElementById("torrent-file-name"),
|
| 49 |
deleteModal: document.getElementById("delete-modal"),
|
| 50 |
deleteModalText: document.getElementById("delete-modal-text"),
|
|
|
|
| 109 |
};
|
| 110 |
}
|
| 111 |
|
| 112 |
+
if (torrent.task_kind === "aria2") {
|
| 113 |
+
const aria2Label = normalizeStateLabel(torrent.state_label);
|
| 114 |
+
if (aria2Label.includes("complete")) {
|
| 115 |
+
return {
|
| 116 |
+
dotClass: "bg-emerald-300",
|
| 117 |
+
dotStyle: "background-color: #6ee7b7;",
|
| 118 |
+
text: "text-emerald-300",
|
| 119 |
+
pillClass: "text-emerald-200",
|
| 120 |
+
pillStyle: "background-color: rgba(110, 231, 183, 0.18); box-shadow: inset 0 0 0 1px rgba(110, 231, 183, 0.22);",
|
| 121 |
+
label: torrent.state_label || "Completed",
|
| 122 |
+
};
|
| 123 |
+
}
|
| 124 |
+
if (aria2Label.includes("fail") || aria2Label.includes("cancel")) {
|
| 125 |
+
return {
|
| 126 |
+
dotClass: "bg-rose",
|
| 127 |
+
dotStyle: "background-color: #ff6b9d;",
|
| 128 |
+
text: "text-rose",
|
| 129 |
+
pillClass: "text-rose-200",
|
| 130 |
+
pillStyle: "background-color: rgba(255, 107, 157, 0.18); box-shadow: inset 0 0 0 1px rgba(255, 107, 157, 0.22);",
|
| 131 |
+
label: torrent.state_label || "Aria2",
|
| 132 |
+
};
|
| 133 |
+
}
|
| 134 |
+
return {
|
| 135 |
+
dotClass: "bg-sky-300",
|
| 136 |
+
dotStyle: "background-color: #7dd3fc;",
|
| 137 |
+
text: "text-sky-200",
|
| 138 |
+
pillClass: "text-sky-100",
|
| 139 |
+
pillStyle: "background-color: rgba(125, 211, 252, 0.16); box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.22);",
|
| 140 |
+
label: torrent.state_label || "Aria2 Download",
|
| 141 |
+
};
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
const label = normalizeStateLabel(torrent.state_label);
|
| 145 |
if (label.includes("download")) {
|
| 146 |
return {
|
|
|
|
| 263 |
if (!torrent) {
|
| 264 |
return;
|
| 265 |
}
|
| 266 |
+
if (torrent.task_kind === "aria2") {
|
| 267 |
+
if (action === "pause") {
|
| 268 |
+
torrent.state = "paused";
|
| 269 |
+
torrent.state_label = "Paused";
|
| 270 |
+
torrent.can_pause = false;
|
| 271 |
+
torrent.can_resume = true;
|
| 272 |
+
torrent.dlspeed = "0 B/s";
|
| 273 |
+
torrent.status_message = "";
|
| 274 |
+
}
|
| 275 |
+
if (action === "resume") {
|
| 276 |
+
torrent.state = "downloading";
|
| 277 |
+
torrent.state_label = "Aria2 Download";
|
| 278 |
+
torrent.can_pause = !torrent.gofile_uploading;
|
| 279 |
+
torrent.can_resume = false;
|
| 280 |
+
torrent.status_message = "";
|
| 281 |
+
}
|
| 282 |
+
updateSummary(state.stats, state.torrents);
|
| 283 |
+
renderTorrents();
|
| 284 |
+
return;
|
| 285 |
+
}
|
| 286 |
const progress = Number(torrent.progress || 0);
|
| 287 |
const isComplete = progress >= 100;
|
| 288 |
|
|
|
|
| 322 |
return;
|
| 323 |
}
|
| 324 |
|
| 325 |
+
if (torrent.task_kind === "aria2") {
|
| 326 |
+
const rawState = String(torrent.state || "");
|
| 327 |
+
if (optimisticAction === "pause") {
|
| 328 |
+
if (rawState === "paused") {
|
| 329 |
+
clearOptimisticTorrentState(torrent.hash);
|
| 330 |
+
return;
|
| 331 |
+
}
|
| 332 |
+
torrent.state = "paused";
|
| 333 |
+
torrent.state_label = "Paused";
|
| 334 |
+
torrent.can_pause = false;
|
| 335 |
+
torrent.can_resume = true;
|
| 336 |
+
torrent.dlspeed = "0 B/s";
|
| 337 |
+
torrent.status_message = "";
|
| 338 |
+
}
|
| 339 |
+
if (optimisticAction === "resume") {
|
| 340 |
+
if (rawState !== "paused") {
|
| 341 |
+
clearOptimisticTorrentState(torrent.hash);
|
| 342 |
+
return;
|
| 343 |
+
}
|
| 344 |
+
torrent.state = "downloading";
|
| 345 |
+
torrent.state_label = "Aria2 Download";
|
| 346 |
+
torrent.can_pause = !torrent.gofile_uploading;
|
| 347 |
+
torrent.can_resume = false;
|
| 348 |
+
torrent.status_message = "";
|
| 349 |
+
}
|
| 350 |
+
return;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
const rawState = String(torrent.state || "");
|
| 354 |
if (optimisticAction === "pause") {
|
| 355 |
const serverPaused = ["pausedDL", "pausedUP"].includes(rawState);
|
|
|
|
| 443 |
if (state.activeFilter === "completed") {
|
| 444 |
return progress >= 100 || label.includes("complete");
|
| 445 |
}
|
| 446 |
+
if (state.activeFilter === "uploading") {
|
| 447 |
+
return !!torrent.gofile_uploading;
|
| 448 |
+
}
|
| 449 |
+
if (state.activeFilter === "aria2") {
|
| 450 |
+
return torrent.task_kind === "aria2";
|
| 451 |
+
}
|
| 452 |
+
return true;
|
| 453 |
+
}
|
| 454 |
|
| 455 |
function matchesSearch(torrent) {
|
| 456 |
if (!state.searchTerm) {
|
|
|
|
| 727 |
</button>
|
| 728 |
</div>`
|
| 729 |
: "";
|
| 730 |
+
const endpointMeta = torrent.task_kind === "aria2"
|
| 731 |
+
? `<span class="rounded-full border border-sky-400/20 bg-sky-400/10 px-2 py-1 font-mono text-[10px] uppercase tracking-[0.2em] text-sky-100">ARIA2</span>`
|
| 732 |
+
: torrent.gofile_endpoint
|
| 733 |
+
? `<span class="rounded-full border border-white/10 bg-white/[0.04] px-2 py-1 font-mono text-[10px] uppercase tracking-[0.2em] text-stone-400">${escapeHtml(torrent.gofile_endpoint)}</span>`
|
| 734 |
+
: "";
|
| 735 |
const statusIconName = torrent.gofile_uploading
|
| 736 |
? "fa-cloud-arrow-up"
|
| 737 |
+
: torrent.task_kind === "aria2"
|
| 738 |
+
? "fa-link"
|
| 739 |
: isSeeding
|
| 740 |
+
? "fa-arrow-up"
|
| 741 |
+
: isDownloading
|
| 742 |
? "fa-arrow-down"
|
| 743 |
: "fa-circle";
|
| 744 |
const statusIconTone = torrent.gofile_uploading
|
| 745 |
? "bg-violet/10 text-violet"
|
| 746 |
+
: torrent.task_kind === "aria2"
|
| 747 |
+
? "bg-sky-400/10 text-sky-200"
|
| 748 |
: isSeeding
|
| 749 |
? "bg-lime/10 text-lime"
|
| 750 |
: isDownloading
|
|
|
|
| 932 |
hideModal(elements.addModal);
|
| 933 |
}
|
| 934 |
|
| 935 |
+
function showAddTab(tab) {
|
| 936 |
+
const isMagnet = tab === "magnet";
|
| 937 |
+
const isFile = tab === "file";
|
| 938 |
+
const isAria2 = tab === "aria2";
|
| 939 |
+
elements.addTabMagnet.dataset.active = isMagnet ? "true" : "false";
|
| 940 |
+
elements.addTabFile.dataset.active = isFile ? "true" : "false";
|
| 941 |
+
elements.addTabAria2.dataset.active = isAria2 ? "true" : "false";
|
| 942 |
+
elements.addTabMagnet.className = isMagnet
|
| 943 |
+
? "add-tab font-display rounded-[14px] border border-white/10 bg-neon px-3 py-2 text-sm font-semibold text-ink transition"
|
| 944 |
+
: "add-tab font-display rounded-[14px] border border-transparent bg-transparent px-3 py-2 text-sm font-semibold text-stone-400 transition hover:text-white";
|
| 945 |
+
elements.addTabFile.className = isFile
|
| 946 |
+
? "add-tab font-display rounded-[14px] border border-white/10 bg-neon px-3 py-2 text-sm font-semibold text-ink transition"
|
| 947 |
+
: "add-tab font-display rounded-[14px] border border-transparent bg-transparent px-3 py-2 text-sm font-semibold text-stone-400 transition hover:text-white";
|
| 948 |
+
elements.addTabAria2.className = isAria2
|
| 949 |
+
? "add-tab font-display rounded-[14px] border border-white/10 bg-neon px-3 py-2 text-sm font-semibold text-ink transition"
|
| 950 |
+
: "add-tab font-display rounded-[14px] border border-transparent bg-transparent px-3 py-2 text-sm font-semibold text-stone-400 transition hover:text-white";
|
| 951 |
+
elements.addPanelMagnet.classList.toggle("hidden", !isMagnet);
|
| 952 |
+
elements.addPanelFile.classList.toggle("hidden", !isFile);
|
| 953 |
+
elements.addPanelAria2.classList.toggle("hidden", !isAria2);
|
| 954 |
+
}
|
| 955 |
|
| 956 |
function syncTorrentFileName() {
|
| 957 |
if (!elements.torrentFileName) {
|
|
|
|
| 1276 |
document.querySelectorAll("[data-close-add-modal]").forEach((button) => {
|
| 1277 |
button.addEventListener("click", closeAddModal);
|
| 1278 |
});
|
| 1279 |
+
elements.addTabMagnet?.addEventListener("click", () => showAddTab("magnet"));
|
| 1280 |
+
elements.addTabFile?.addEventListener("click", () => showAddTab("file"));
|
| 1281 |
+
elements.addTabAria2?.addEventListener("click", () => showAddTab("aria2"));
|
| 1282 |
+
elements.torrentFileInput?.addEventListener("change", syncTorrentFileName);
|
| 1283 |
|
| 1284 |
elements.magnetForm?.addEventListener("submit", async (event) => {
|
| 1285 |
event.preventDefault();
|
| 1286 |
await submitFormWithToast(elements.magnetForm, "Magnet link berhasil ditambahkan.");
|
| 1287 |
});
|
| 1288 |
+
elements.torrentUploadForm?.addEventListener("submit", async (event) => {
|
| 1289 |
+
event.preventDefault();
|
| 1290 |
+
await submitFormWithToast(elements.torrentUploadForm, "File torrent berhasil diunggah.");
|
| 1291 |
+
});
|
| 1292 |
+
elements.aria2Form?.addEventListener("submit", async (event) => {
|
| 1293 |
+
event.preventDefault();
|
| 1294 |
+
await submitFormWithToast(elements.aria2Form, "Aria2 link berhasil ditambahkan.");
|
| 1295 |
+
});
|
| 1296 |
|
| 1297 |
elements.modalClose?.addEventListener("click", closeDeleteModal);
|
| 1298 |
elements.modalCancel?.addEventListener("click", closeDeleteModal);
|
templates/index.html
CHANGED
|
@@ -143,11 +143,12 @@
|
|
| 143 |
<button type="button" class="filter-chip font-display rounded-2xl border border-neon/30 bg-neon/12 px-4 py-2 text-sm font-semibold text-neon transition hover:bg-neon/20" data-filter="all" data-active="true">All</button>
|
| 144 |
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="downloading" data-active="false">Downloading</button>
|
| 145 |
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="seeding" data-active="false">Seeding</button>
|
| 146 |
-
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="paused" data-active="false">Paused</button>
|
| 147 |
-
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="completed" data-active="false">Completed</button>
|
| 148 |
-
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="uploading" data-active="false">Uploading</button>
|
| 149 |
-
|
| 150 |
-
|
|
|
|
| 151 |
|
| 152 |
<label class="relative block">
|
| 153 |
<i class="fa-solid fa-magnifying-glass pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-sm text-stone-500"></i>
|
|
@@ -264,25 +265,28 @@
|
|
| 264 |
<div class="flex h-12 w-12 items-center justify-center rounded-2xl bg-neon/12 text-neon">
|
| 265 |
<i class="fa-solid fa-plus text-lg"></i>
|
| 266 |
</div>
|
| 267 |
-
<div>
|
| 268 |
-
<p class="text-[11px] uppercase tracking-[0.25em] text-stone-500">Add Torrent</p>
|
| 269 |
-
<h3 class="font-display mt-2 text-xl font-semibold text-white">Push magnet link
|
| 270 |
-
</div>
|
| 271 |
-
</div>
|
| 272 |
<button id="add-modal-close" type="button" class="rounded-2xl border border-[#20293a] px-3 py-2 text-sm text-stone-400 transition hover:bg-white/5 hover:text-white">
|
| 273 |
<i class="fa-solid fa-xmark"></i>
|
| 274 |
</button>
|
| 275 |
</div>
|
| 276 |
|
| 277 |
<div class="p-5 sm:p-6">
|
| 278 |
-
<div class="grid grid-cols-
|
| 279 |
<button type="button" id="add-tab-magnet" data-add-tab="magnet" data-active="true" class="add-tab font-display rounded-[14px] border px-3 py-2 text-sm font-semibold transition">
|
| 280 |
Magnet Link
|
| 281 |
-
</button>
|
| 282 |
-
<button type="button" id="add-tab-file" data-add-tab="file" data-active="false" class="add-tab font-display rounded-[14px] border px-3 py-2 text-sm font-semibold transition">
|
| 283 |
-
Torrent File
|
| 284 |
-
</button>
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
| 286 |
|
| 287 |
<div id="add-panel-magnet" data-add-panel="magnet" class="mt-5">
|
| 288 |
<form id="magnet-form" action="{{ url_for('add_magnet') }}" method="post" class="space-y-4">
|
|
@@ -301,8 +305,8 @@
|
|
| 301 |
</form>
|
| 302 |
</div>
|
| 303 |
|
| 304 |
-
<div id="add-panel-file" data-add-panel="file" class="mt-5 hidden">
|
| 305 |
-
<form id="torrent-upload-form" action="{{ url_for('upload_torrent') }}" method="post" enctype="multipart/form-data" class="space-y-4">
|
| 306 |
<label class="block rounded-[24px] border border-dashed border-[#20293a] bg-black/30 px-5 py-8 text-center transition hover:border-neon/30 hover:bg-black/40">
|
| 307 |
<div class="mx-auto flex h-14 w-14 items-center justify-center rounded-3xl bg-white/[0.04] text-neon">
|
| 308 |
<i class="fa-solid fa-file-arrow-up text-lg"></i>
|
|
@@ -324,12 +328,29 @@
|
|
| 324 |
<button type="submit" class="font-display rounded-2xl border border-[#20293a] bg-white/[0.03] px-4 py-3 text-sm font-medium text-stone-100 transition hover:bg-white/[0.06]">
|
| 325 |
Upload Torrent
|
| 326 |
</button>
|
| 327 |
-
</div>
|
| 328 |
-
</form>
|
| 329 |
-
</div>
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
|
| 334 |
<div id="delete-modal" class="fixed inset-0 z-[70] hidden items-center justify-center bg-black/75 px-4 backdrop-blur-xl">
|
| 335 |
<div class="w-full max-w-md rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(15,18,28,0.96),rgba(9,11,18,0.95))] shadow-halo">
|
|
|
|
| 143 |
<button type="button" class="filter-chip font-display rounded-2xl border border-neon/30 bg-neon/12 px-4 py-2 text-sm font-semibold text-neon transition hover:bg-neon/20" data-filter="all" data-active="true">All</button>
|
| 144 |
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="downloading" data-active="false">Downloading</button>
|
| 145 |
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="seeding" data-active="false">Seeding</button>
|
| 146 |
+
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="paused" data-active="false">Paused</button>
|
| 147 |
+
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="completed" data-active="false">Completed</button>
|
| 148 |
+
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="uploading" data-active="false">Uploading</button>
|
| 149 |
+
<button type="button" class="filter-chip font-display rounded-2xl border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-semibold text-stone-300 transition hover:border-white/20 hover:text-white" data-filter="aria2" data-active="false">Aria2</button>
|
| 150 |
+
</div>
|
| 151 |
+
</section>
|
| 152 |
|
| 153 |
<label class="relative block">
|
| 154 |
<i class="fa-solid fa-magnifying-glass pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-sm text-stone-500"></i>
|
|
|
|
| 265 |
<div class="flex h-12 w-12 items-center justify-center rounded-2xl bg-neon/12 text-neon">
|
| 266 |
<i class="fa-solid fa-plus text-lg"></i>
|
| 267 |
</div>
|
| 268 |
+
<div>
|
| 269 |
+
<p class="text-[11px] uppercase tracking-[0.25em] text-stone-500">Add Torrent</p>
|
| 270 |
+
<h3 class="font-display mt-2 text-xl font-semibold text-white">Push magnet link, torrent file, atau Aria2 link</h3>
|
| 271 |
+
</div>
|
| 272 |
+
</div>
|
| 273 |
<button id="add-modal-close" type="button" class="rounded-2xl border border-[#20293a] px-3 py-2 text-sm text-stone-400 transition hover:bg-white/5 hover:text-white">
|
| 274 |
<i class="fa-solid fa-xmark"></i>
|
| 275 |
</button>
|
| 276 |
</div>
|
| 277 |
|
| 278 |
<div class="p-5 sm:p-6">
|
| 279 |
+
<div class="grid grid-cols-3 gap-1 rounded-[16px] border border-[#1b2332] bg-black/20 p-1">
|
| 280 |
<button type="button" id="add-tab-magnet" data-add-tab="magnet" data-active="true" class="add-tab font-display rounded-[14px] border px-3 py-2 text-sm font-semibold transition">
|
| 281 |
Magnet Link
|
| 282 |
+
</button>
|
| 283 |
+
<button type="button" id="add-tab-file" data-add-tab="file" data-active="false" class="add-tab font-display rounded-[14px] border px-3 py-2 text-sm font-semibold transition">
|
| 284 |
+
Torrent File
|
| 285 |
+
</button>
|
| 286 |
+
<button type="button" id="add-tab-aria2" data-add-tab="aria2" data-active="false" class="add-tab font-display rounded-[14px] border px-3 py-2 text-sm font-semibold transition">
|
| 287 |
+
Aria2 Link
|
| 288 |
+
</button>
|
| 289 |
+
</div>
|
| 290 |
|
| 291 |
<div id="add-panel-magnet" data-add-panel="magnet" class="mt-5">
|
| 292 |
<form id="magnet-form" action="{{ url_for('add_magnet') }}" method="post" class="space-y-4">
|
|
|
|
| 305 |
</form>
|
| 306 |
</div>
|
| 307 |
|
| 308 |
+
<div id="add-panel-file" data-add-panel="file" class="mt-5 hidden">
|
| 309 |
+
<form id="torrent-upload-form" action="{{ url_for('upload_torrent') }}" method="post" enctype="multipart/form-data" class="space-y-4">
|
| 310 |
<label class="block rounded-[24px] border border-dashed border-[#20293a] bg-black/30 px-5 py-8 text-center transition hover:border-neon/30 hover:bg-black/40">
|
| 311 |
<div class="mx-auto flex h-14 w-14 items-center justify-center rounded-3xl bg-white/[0.04] text-neon">
|
| 312 |
<i class="fa-solid fa-file-arrow-up text-lg"></i>
|
|
|
|
| 328 |
<button type="submit" class="font-display rounded-2xl border border-[#20293a] bg-white/[0.03] px-4 py-3 text-sm font-medium text-stone-100 transition hover:bg-white/[0.06]">
|
| 329 |
Upload Torrent
|
| 330 |
</button>
|
| 331 |
+
</div>
|
| 332 |
+
</form>
|
| 333 |
+
</div>
|
| 334 |
+
|
| 335 |
+
<div id="add-panel-aria2" data-add-panel="aria2" class="mt-5 hidden">
|
| 336 |
+
<form id="aria2-form" action="{{ url_for('add_aria2') }}" method="post" class="space-y-4">
|
| 337 |
+
<div>
|
| 338 |
+
<label class="mb-2 block text-sm text-stone-300">Direct download URL</label>
|
| 339 |
+
<textarea name="aria2_link" rows="6" placeholder="https://example.com/file.iso" class="w-full rounded-[24px] border border-[#20293a] bg-black/30 px-4 py-4 text-sm text-white outline-none transition placeholder:text-stone-500 focus:border-neon/40"></textarea>
|
| 340 |
+
</div>
|
| 341 |
+
<div class="grid grid-cols-2 gap-3">
|
| 342 |
+
<button type="button" data-close-add-modal class="font-display rounded-2xl border border-[#20293a] bg-white/[0.03] px-4 py-3 text-sm font-medium text-stone-200 transition hover:bg-white/[0.06]">
|
| 343 |
+
Cancel
|
| 344 |
+
</button>
|
| 345 |
+
<button type="submit" class="font-display rounded-2xl border border-[#20293a] bg-white/[0.03] px-4 py-3 text-sm font-medium text-stone-100 transition hover:bg-white/[0.06]">
|
| 346 |
+
Add Aria2 Link
|
| 347 |
+
</button>
|
| 348 |
+
</div>
|
| 349 |
+
</form>
|
| 350 |
+
</div>
|
| 351 |
+
</div>
|
| 352 |
+
</div>
|
| 353 |
+
</div>
|
| 354 |
|
| 355 |
<div id="delete-modal" class="fixed inset-0 z-[70] hidden items-center justify-center bg-black/75 px-4 backdrop-blur-xl">
|
| 356 |
<div class="w-full max-w-md rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(15,18,28,0.96),rgba(9,11,18,0.95))] shadow-halo">
|