#!/bin/bash set -eo pipefail read -rsp "Set password for admin (HTTP Basic Auth): " pass1; echo read -rsp "Confirm password: " pass2; echo if [ -z "${pass1:-}" ] || [ -z "${pass2:-}" ]; then echo "Password not set. Aborting." exit 1 fi [ "$pass1" != "$pass2" ] && echo "Passwords do not match." && exit 1 read -rp "Enter downloads directory [/app/data/downloads]: " downloads_dir downloads_dir=${downloads_dir:-/app/data/downloads} set -euo pipefail mkdir -p /app/data/public/bin "$downloads_dir" /bin/rm -f /app/data/public/bin/yt-dlp curl -sSL https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /app/data/public/bin/yt-dlp chmod +x /app/data/public/bin/yt-dlp if command -v htpasswd >/dev/null 2>&1; then htpasswd -cb /app/data/.htpasswd admin "$pass1" else echo "admin:$(openssl passwd -apr1 "$pass1")" > /app/data/.htpasswd fi cat > /app/data/public/.htaccess <<'EOF' AuthType Basic AuthName "Restricted Area" AuthUserFile /app/data/.htpasswd Require valid-user EOF { echo "[settings]" echo "downloads_dir=$downloads_dir" } > /app/data/config.ini cat > /app/data/public/index.php <<'EOF' Cookies cleared. Go back

"; exit; } if (isset($_FILES["cookies"])) { if ($_FILES["cookies"]["error"] === UPLOAD_ERR_OK && is_uploaded_file($_FILES["cookies"]["tmp_name"])) { move_uploaded_file($_FILES["cookies"]["tmp_name"], $cookies_path); echo "

Cookies uploaded successfully. Go back

"; exit; } else { echo "

Cookie upload failed. Go back

"; exit; } } if (!empty($_POST["urls"])) { $urls = array_filter(array_map("trim", explode("\n", $_POST["urls"]))); foreach ($urls as $url) { $escaped_url = escapeshellarg($url); $command = "/app/data/public/bin/yt-dlp -o " . escapeshellarg("$downloads_dir/%(title)s.%(ext)s") . " $cookies_option $escaped_url >> /tmp/yt-dlp.log 2>&1 &"; shell_exec($command); } echo "

Downloads started. Go back or View Log.

"; exit; } } ?> yt-dlp Downloader

yt-dlp Downloader

View Live Log

Video Download

Cookies Management

Need help? How to export cookies.txt

Latest Downloads

EOF cat > /app/data/public/log.php <<'EOF' 5 * 1024 * 1024) { @unlink("/tmp/yt-dlp.log"); } header("Refresh: 3"); echo "
";
system("tail -n 100 /tmp/yt-dlp.log 2>&1");
echo "
"; ?> EOF chown -R www-data:www-data /app/data/public echo "Done. Access via your LAMP app URL (protected)."