If no input URL is supplied use list from text file
6
votes
3
answers
868
views
I am trying to create a shell script for yt-dlp that takes an URL as input from the command line or if no input is given use an internal list. The script works when given input, but crashes when no input is given and thus using the internal list.
#!/usr/bin/env bash
URLfromTerminal="$1"
PathToList="--batch-file '${HOME}/bin/ytdlp/Lists/Test.txt'"
[[ -z "$URLfromTerminal" ]] && Download="$PathToList" || Download="$URLfromTerminal"
yt-dlp -ciw \
-S "res:1920" \
--ffmpeg-location "$HOME"/bin/ffmpeg/ffmpeg \
"$Download"
Error message when no input is given and using the internal list:
yt-dlp: error: no such option: --batch-file '/Users/UserName/bin/ytdlp/Lists/Test.txt'
Why is the path to the text file treated as an option by yt-dlp when expanded from a variable?
I am new to shell scripting and don't know what's best practice, so any general improvement is also welcome.
Asked by Kasam
(97 rep)
Dec 16, 2022, 12:13 PM
Last activity: Dec 16, 2022, 03:53 PM
Last activity: Dec 16, 2022, 03:53 PM