A lot of fixes (see description)

- fix indentation (I used a broken vim config)
- add a -d (dry run) option
- add guarding double quotes at a few places
- use `python3` if no `python` executable exists
- explicitly use bash (instead of posix sh) where it is required
This commit is contained in:
r4
2022-06-11 12:39:16 +02:00
parent 2655890dd4
commit 6ede9a651f
2 changed files with 185 additions and 164 deletions

31
init.sh
View File

@@ -1,15 +1,30 @@
#!/usr/bin/env sh
CUSTOM_PYTHON=
if ! which python > /dev/null; then
if which python3 > /dev/null; then
echo ">>> python not found, using python3 instead"
CUSTOM_PYTHON=python3
else
echo ">>> No python executable found, please install python or python3"
exit 1
fi
fi
if [ -e yt-dlc/ ]; then
echo ">>> youtube-dlc already downloaded, delete and redownload? [y/N]"
read RES
[ "$RES" = "y" ] || [ "$RES" = "Y" ] && rm -rf yt-dlc/
printf ">>> youtube-dlc already downloaded, delete and redownload? [y/N]: "
read RES
[ "$RES" = "y" ] || [ "$RES" = "Y" ] && rm -rf yt-dlc/
fi
if [ ! -e yt-dlc/ ]; then
echo ">>> Cloning youtube-dlc repo" &&
git clone --depth 1 --branch "2020.11.11-3" "https://github.com/blackjack4494/yt-dlc.git"
echo ">>> Applying patches"
# Allows for downloading English content from the German website
patch -p0 < fix-southpark-de-en.diff
echo ">>> Cloning youtube-dlc repo" &&
git clone --depth 1 --branch "2020.11.11-3" "https://github.com/blackjack4494/yt-dlc.git"
echo ">>> Applying patches"
# Allows for downloading English content from the German website
patch -p0 < fix-southpark-de-en.diff
fi
echo ">>> Building youtube-dlc"
make -C yt-dlc/ youtube-dlc
[ -n "$CUSTOM_PYTHON" ] &&
sed -i "1c\\#!/usr/bin/env $CUSTOM_PYTHON" yt-dlc/youtube-dlc