Spaces:
Sleeping
Sleeping
ozipoetra commited on
Commit Β·
4fe91d9
1
Parent(s): 372b807
main
Browse files- Dockerfile +1 -8
- main.py +1 -10
- start.sh +0 -66
Dockerfile
CHANGED
|
@@ -7,13 +7,6 @@ RUN apt-get update && apt-get install -y \
|
|
| 7 |
curl \
|
| 8 |
aria2 \
|
| 9 |
xz-utils \
|
| 10 |
-
gnupg2 \
|
| 11 |
-
dbus \
|
| 12 |
-
lsb-release \
|
| 13 |
-
&& curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg \
|
| 14 |
-
&& echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/cloudflare-client.list \
|
| 15 |
-
&& apt-get update \
|
| 16 |
-
&& apt-get install -y cloudflare-warp \
|
| 17 |
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
# Download and install the OFFICIAL 7-Zip standalone binary (64-bit Linux)
|
|
@@ -29,4 +22,4 @@ RUN chmod +x start.sh
|
|
| 29 |
|
| 30 |
EXPOSE 7860
|
| 31 |
|
| 32 |
-
CMD ["/app/start.sh"]
|
|
|
|
| 7 |
curl \
|
| 8 |
aria2 \
|
| 9 |
xz-utils \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
# Download and install the OFFICIAL 7-Zip standalone binary (64-bit Linux)
|
|
|
|
| 22 |
|
| 23 |
EXPOSE 7860
|
| 24 |
|
| 25 |
+
CMD ["/app/start.sh"]
|
main.py
CHANGED
|
@@ -18,9 +18,6 @@ from contextlib import asynccontextmanager
|
|
| 18 |
API_TOKEN = os.getenv("API_TOKEN", "supersecret")
|
| 19 |
PIXELDRAIN_KEY = os.getenv("PIXELDRAIN_KEY")
|
| 20 |
YTDLP_COOKIES = os.getenv("YTDLP_COOKIES", "") # Path to cookies.txt OR cookies string content
|
| 21 |
-
USE_WARP = os.getenv("USE_WARP", "false").lower() == "true"
|
| 22 |
-
WARP_PROXY_PORT = os.getenv("WARP_PROXY_PORT", "40000")
|
| 23 |
-
WARP_PROXY = f"socks5://127.0.0.1:{WARP_PROXY_PORT}" if USE_WARP else None
|
| 24 |
|
| 25 |
# Handle cookies: if it's a string (not a file path), create temp file
|
| 26 |
COOKIES_FILE = None
|
|
@@ -46,7 +43,6 @@ print("=" * 60)
|
|
| 46 |
print(f"API Token: {'β
Set' if API_TOKEN else 'β Not set'}")
|
| 47 |
print(f"Pixeldrain Key: {'β
Set' if PIXELDRAIN_KEY else 'β Not set'}")
|
| 48 |
print(f"Cookies: {'β
Loaded' if COOKIES_FILE else 'β Not loaded'}")
|
| 49 |
-
print(f"WARP Proxy: {'β
Enabled at ' + WARP_PROXY if WARP_PROXY else 'β Disabled'}")
|
| 50 |
print("=" * 60)
|
| 51 |
|
| 52 |
# Hugging Face Ephemeral Disk Paths (Fast NVMe /tmp)
|
|
@@ -452,17 +448,12 @@ async def worker(worker_id):
|
|
| 452 |
"--no-playlist",
|
| 453 |
"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best",
|
| 454 |
"--external-downloader", "aria2c",
|
| 455 |
-
"--external-downloader-args", "aria2c:-x 4 -s 4 -k 1M",
|
| 456 |
"--progress",
|
| 457 |
"--newline",
|
| 458 |
job["payload"]
|
| 459 |
]
|
| 460 |
|
| 461 |
-
# Add WARP proxy if enabled
|
| 462 |
-
if WARP_PROXY:
|
| 463 |
-
cmd.extend(["--proxy", WARP_PROXY])
|
| 464 |
-
print(f"Using WARP proxy: {WARP_PROXY}")
|
| 465 |
-
|
| 466 |
# Add cookies if provided
|
| 467 |
if COOKIES_FILE and os.path.exists(COOKIES_FILE):
|
| 468 |
cmd.extend(["--cookies", COOKIES_FILE])
|
|
|
|
| 18 |
API_TOKEN = os.getenv("API_TOKEN", "supersecret")
|
| 19 |
PIXELDRAIN_KEY = os.getenv("PIXELDRAIN_KEY")
|
| 20 |
YTDLP_COOKIES = os.getenv("YTDLP_COOKIES", "") # Path to cookies.txt OR cookies string content
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Handle cookies: if it's a string (not a file path), create temp file
|
| 23 |
COOKIES_FILE = None
|
|
|
|
| 43 |
print(f"API Token: {'β
Set' if API_TOKEN else 'β Not set'}")
|
| 44 |
print(f"Pixeldrain Key: {'β
Set' if PIXELDRAIN_KEY else 'β Not set'}")
|
| 45 |
print(f"Cookies: {'β
Loaded' if COOKIES_FILE else 'β Not loaded'}")
|
|
|
|
| 46 |
print("=" * 60)
|
| 47 |
|
| 48 |
# Hugging Face Ephemeral Disk Paths (Fast NVMe /tmp)
|
|
|
|
| 448 |
"--no-playlist",
|
| 449 |
"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best",
|
| 450 |
"--external-downloader", "aria2c",
|
| 451 |
+
"--external-downloader-args", "aria2c:-x 4 -s 4 -k 1M",
|
| 452 |
"--progress",
|
| 453 |
"--newline",
|
| 454 |
job["payload"]
|
| 455 |
]
|
| 456 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
# Add cookies if provided
|
| 458 |
if COOKIES_FILE and os.path.exists(COOKIES_FILE):
|
| 459 |
cmd.extend(["--cookies", COOKIES_FILE])
|
start.sh
CHANGED
|
@@ -1,72 +1,6 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
| 4 |
-
echo "π Starting Anime Compression API..."
|
| 5 |
-
|
| 6 |
-
# Check if WARP should be enabled
|
| 7 |
-
if [ "$USE_WARP" = "true" ]; then
|
| 8 |
-
echo "π Initializing Cloudflare WARP..."
|
| 9 |
-
|
| 10 |
-
# Start dbus for WARP (suppress output)
|
| 11 |
-
mkdir -p /run/dbus
|
| 12 |
-
dbus-daemon --system --nofork --nopidfile >/dev/null 2>&1 &
|
| 13 |
-
sleep 1
|
| 14 |
-
|
| 15 |
-
# Start WARP configuration in background (suppress verbose logs)
|
| 16 |
-
(
|
| 17 |
-
# Wait for warp-svc to be ready and register
|
| 18 |
-
if [ ! -f /var/lib/cloudflare-warp/reg.json ]; then
|
| 19 |
-
echo "π Registering WARP client..."
|
| 20 |
-
while ! warp-cli --accept-tos registration new >/dev/null 2>&1; do
|
| 21 |
-
sleep 1
|
| 22 |
-
done
|
| 23 |
-
echo "β
WARP registration complete!"
|
| 24 |
-
else
|
| 25 |
-
echo "β
WARP already registered"
|
| 26 |
-
fi
|
| 27 |
-
|
| 28 |
-
# Set license if provided
|
| 29 |
-
if [ ! -z "$WARP_LICENSE" ]; then
|
| 30 |
-
echo "π Setting WARP license..."
|
| 31 |
-
warp-cli --accept-tos set-license $WARP_LICENSE >/dev/null 2>&1
|
| 32 |
-
fi
|
| 33 |
-
|
| 34 |
-
# Configure WARP proxy mode (suppress output)
|
| 35 |
-
echo "βοΈ Configuring WARP proxy mode..."
|
| 36 |
-
warp-cli --accept-tos mode proxy >/dev/null 2>&1
|
| 37 |
-
warp-cli --accept-tos proxy port 40001 >/dev/null 2>&1
|
| 38 |
-
|
| 39 |
-
# Connect to WARP
|
| 40 |
-
echo "π Connecting to Cloudflare WARP..."
|
| 41 |
-
warp-cli --accept-tos connect >/dev/null 2>&1
|
| 42 |
-
|
| 43 |
-
# Wait for connection (silent check)
|
| 44 |
-
for i in {1..30}; do
|
| 45 |
-
if warp-cli --accept-tos status 2>/dev/null | grep -iq "connected"; then
|
| 46 |
-
echo "β
WARP connected successfully!"
|
| 47 |
-
break
|
| 48 |
-
fi
|
| 49 |
-
sleep 1
|
| 50 |
-
done
|
| 51 |
-
|
| 52 |
-
# Use socat to redirect traffic (suppress logs)
|
| 53 |
-
echo "π WARP proxy available at: socks5://127.0.0.1:${WARP_PROXY_PORT:-40000}"
|
| 54 |
-
# exec socat TCP-LISTEN:${WARP_PROXY_PORT:-40000},fork TCP:localhost:40001 >/dev/null 2>&1
|
| 55 |
-
) &
|
| 56 |
-
|
| 57 |
-
# Start warp-svc daemon (redirect verbose logs to /dev/null)
|
| 58 |
-
warp-svc --accept-tos >/dev/null 2>&1 &
|
| 59 |
-
WARP_PID=$!
|
| 60 |
-
|
| 61 |
-
# Give daemon time to initialize
|
| 62 |
-
sleep 2
|
| 63 |
-
else
|
| 64 |
-
echo "β οΈ WARP disabled (USE_WARP=$USE_WARP)"
|
| 65 |
-
fi
|
| 66 |
-
|
| 67 |
-
# Wait a moment for everything to settle
|
| 68 |
-
sleep 2
|
| 69 |
-
|
| 70 |
echo "π¬ Starting FastAPI application..."
|
| 71 |
|
| 72 |
# Start the FastAPI application
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
echo "π¬ Starting FastAPI application..."
|
| 5 |
|
| 6 |
# Start the FastAPI application
|