system-scripts/downloads/ytdl-music.sh

26 lines
654 B
Bash
Raw Normal View History

2023-11-30 15:53:53 +02:00
#!/bin/bash
PLAYLISTURL="$1"
DEFAULT_TARGET_PATH="/mnt/data/media/"
LIBRARY_NAME="${2:-Soundtracks}"
TARGETPATH="${3:-$DEFAULT_TARGET_PATH}"
# Check if $PLAYLISTURL is empty
if [ -z "$PLAYLISTURL" ]; then
echo "Need to specify a playlist URL"
exit 1
fi
if ! which ffmpeg > /dev/null 2>&1; then
echo "Error: ffmpeg is not installed. Please install ffmpeg before running this script."
exit 1
fi
ffmpeg -version | head -n 1
yt-dlp -U || exit $?
sleep 2
2023-11-30 15:53:53 +02:00
# Use double quotes for variables within the yt-dlp command
yt-dlp -f 'ba' -x --audio-format mp3 "$PLAYLISTURL" -o "$TARGETPATH/$LIBRARY_NAME/%(playlist)s/%(title)s.%(ext)s"