#!/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."