Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

Youtube MP3 Downloader Script using AI

Rumi, February 14, 2026
#!/bin/bash
# ==========================================================
# YouTube Audio Downloader v3.4 (Debian 12 ready)
# Installs all required dependencies automatically
# ==========================================================

set -e

# ---------- Colors ----------
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
NC='\033[0m'

# ---------- Functions ----------

info() { echo -e "${CYAN}[INFO]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
err() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }

# ---------- Root check ----------
if [[ $EUID -ne 0 ]]; then
err "Run this script as root (sudo or root shell)."
fi

# ---------- Dependency installation ----------
info "Preparing system (Debian 12)..."

apt update -y
apt install -y \
curl \
ffmpeg \
ca-certificates

# ---------- yt-dlp binary installation ----------
if ! command -v yt-dlp &>/dev/null; then
info "Installing yt-dlp official binary..."
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp \
-o /usr/local/bin/yt-dlp
chmod +x /usr/local/bin/yt-dlp
else
info "yt-dlp already installed"
fi

hash -r

info "yt-dlp version: $(yt-dlp --version)"
info "ffmpeg version: $(ffmpeg -version | head -n1)"

# ---------- Defaults ----------
AUDIO_FORMAT="mp3"
AUDIO_QUALITY="0"
DEFAULT_SAVE_PATH="$(pwd)"

echo ""
echo -e "${CYAN}==========================================${NC}"
echo -e "${CYAN} YouTube Audio Downloader (v3.4) ${NC}"
echo -e "${CYAN}==========================================${NC}"
echo ""

# ---------- URL ----------
read -p "Enter YouTube video or playlist URL: " MEDIA_URL
[[ -z "$MEDIA_URL" ]] && err "URL cannot be empty"

# ---------- Playlist detection ----------
if [[ "$MEDIA_URL" == *"list="* ]]; then
IS_PLAYLIST=true
info "Detected playlist URL"
else
IS_PLAYLIST=false
info "Detected single video URL"
fi

# ---------- Playlist options ----------
if [[ "$IS_PLAYLIST" == true ]]; then
read -p "Playlist start index (default 1): " PLAYLIST_START
read -p "Playlist end index (empty = all): " PLAYLIST_END
PLAYLIST_START=${PLAYLIST_START:-1}
fi

# ---------- Save path ----------
read -p "Save path [default: current directory]: " SAVE_PATH
SAVE_PATH=${SAVE_PATH:-$DEFAULT_SAVE_PATH}

mkdir -p "$SAVE_PATH"

# ---------- Cookies ----------
read -p "Use browser cookies for authentication? (y/n): " USE_COOKIES
if [[ "$USE_COOKIES" =~ ^[Yy]$ ]]; then
read -p "Browser (chrome/firefox/edge/brave) [default: chrome]: " BROWSER
BROWSER=${BROWSER:-chrome}
USE_COOKIES=true
else
USE_COOKIES=false
fi

# ---------- Build yt-dlp command ----------
CMD=(yt-dlp
-x
-f "bestaudio/best"
--audio-format "$AUDIO_FORMAT"
--audio-quality "$AUDIO_QUALITY"
--embed-thumbnail
--add-metadata
--extractor-args "youtube:player_client=android"
-i
)

# ---------- SABR compatibility ----------
if yt-dlp --help | grep -q -- '--no-sabr'; then
CMD+=(--no-sabr)
else
warn "--no-sabr not supported by this yt-dlp version (skipping)"
fi

# ---------- Cookies ----------
if [[ "$USE_COOKIES" == true ]]; then
info "Using cookies from browser: $BROWSER"
CMD+=(--cookies-from-browser "$BROWSER")
fi

# ---------- Output template ----------
if [[ "$IS_PLAYLIST" == true ]]; then
CMD+=(--playlist-start "$PLAYLIST_START")
[[ -n "$PLAYLIST_END" ]] && CMD+=(--playlist-end "$PLAYLIST_END")
CMD+=(-o "${SAVE_PATH}/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s")
else
CMD+=(-o "${SAVE_PATH}/%(title)s.%(ext)s")
fi

CMD+=("$MEDIA_URL")

# ---------- Execute ----------
echo ""
info "Starting download..."
"${CMD[@]}"

# ---------- Result ----------
if [[ $? -eq 0 ]]; then
echo -e "${GREEN}✅ Download completed successfully${NC}"
echo -e "${GREEN}📁 Saved to: ${SAVE_PATH}${NC}"
else
echo -e "${RED}❌ Download failed${NC}"
fi
Administrations GPT Scripts DebianDebian 12GPT-AIYoutube DownloaderYT Downloader

Post navigation

Previous post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx openvpn pfsense php Postfix Proxmox RDP Softether SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin Windows 10 XCP-NG zimbra

Topics

Recent Posts

  • Youtube MP3 Downloader Script using AI February 14, 2026
  • Install Softether VPN and create a Destination NAT (D-NAT) Rule to access the private Client VPN Node on a Debian 12 OS February 14, 2026
  • Deploying Pulse Monitoring for Proxmox Cluster Ecosystem February 13, 2026
  • Technitium DNS Web UI Configuration for Primary-Secondary Name Servers February 12, 2026
  • Technitium DNS with Primary-Slave Installation on Debian February 12, 2026
  • Install Docker and Docker Compose in Debian 12 February 5, 2026
  • Install GUI on Debian 12 using CLI February 4, 2026
  • Configuring Multiple PHP Versions on Virtualmin January 30, 2026
  • Deploy a Container TIG (Telegraf, InfluxDB and Grafana) Stack January 24, 2026
  • Resetting password of another Linux by mounting disk December 15, 2025

Archives

Top Posts & Pages

  • Youtube MP3 Downloader Script using AI
©2026 Bots! | WordPress Theme by SuperbThemes