Files
Server-scripts/youtube2mp3.sh
T

40 lines
848 B
Bash
Raw Normal View History

2026-08-19 11:24:29 +02:00
#!/usr/bin/env bash
set -Eeuo pipefail
# Usage:
# ./download_mp3s.sh links.txt [output_dir]
#
# links.txt: text file containing one URL per line
# output_dir: optional destination directory (default: ./downloads)
LINKS_FILE="${1:-links.txt}"
OUTDIR="${2:-downloads}"
if ! command -v yt-dlp >/dev/null 2>&1; then
echo "Error: yt-dlp not found."
exit 1
fi
if ! command -v ffmpeg >/dev/null 2>&1; then
echo "Error: ffmpeg not found."
exit 1
fi
mkdir -p "$OUTDIR"
yt-dlp \
--newline \
--ignore-errors \
--extract-audio \
--audio-format mp3 \
--audio-quality 0 \
--embed-metadata \
--embed-thumbnail \
--add-metadata \
--parse-metadata "%(artist|)s:%(meta_artist)s" \
--convert-thumbnails jpg \
--output "$OUTDIR/%(uploader)s - %(title)s.%(ext)s" \
-a "$LINKS_FILE"
echo "Done."