This commit is contained in:
2026-07-10 15:11:51 +08:00
parent 8bfcf23bc2
commit da17239d7d
148 changed files with 2542 additions and 4873 deletions
+50 -36
View File
@@ -1,45 +1,59 @@
#!/usr/bin/env bash
##makedesc: Install youtube-dl (src)
# https://github.com/ytdl-org/youtube-dl#installation
set -eo pipefail
echo
echo "==============================================="
echo "Installing youtube-dl (src)..."
echo "==============================================="
echo
installed() { command -v "$1" >/dev/null 2>&1; }
# 11.04.23: release 2021.12.17 in snap/apt/github is broken (Unable to extract uploader id)
# and still no fix officially released, so we just build it from actual sources
install() {
echo
echo "==============================================="
echo "Installing youtube-dl"
echo "==============================================="
echo
# curl -L https://yt-dl.org/downloads/latest/youtube-dl -o "$HOME/.local/bin/youtube-dl" && \
# sudo chmod +rx "$HOME/.local/bin/youtube-dl"
# https://github.com/ytdl-org/youtube-dl#installation
installed() {
command -v "$1" >/dev/null 2>&1
if ! installed make; then
if [ "$(uname -s)" = "Darwin" ]; then
echo "ERROR: Install Xcode Command Line Tools first." >&2
exit 1
else
sudo apt install -y make
fi
fi
mkdir -p "$HOME/install/youtube-dl" "$HOME/.local/bin"
if installed git; then
if [ -d "$HOME/install/youtube-dl" ]; then
cd "$HOME/install/youtube-dl"
git pull
else
git clone https://github.com/ytdl-org/youtube-dl.git "$HOME/install/youtube-dl" --depth=1 --single-branch
fi
else
if ! installed wget; then
if [ "$(uname -s)" = "Darwin" ]; then
echo "ERROR: Install wget or use git." >&2
exit 1
else
sudo apt install -y wget
fi
fi
wget -q --show-progress https://github.com/ytdl-org/youtube-dl/archive/refs/heads/master.zip -O "$HOME/install/youtube-dl.zip"
unzip -oq "$HOME/install/youtube-dl.zip" -d "$HOME/install/youtube-dl"
fi
cd "$HOME/install/youtube-dl"
make youtube-dl
mv youtube-dl "$HOME/.local/bin/"
echo
echo "Finish!"
youtube-dl --version
echo
}
! installed make && sudo apt install -y make
mkdir -p "$HOME/install/youtube-dl" "$HOME/.local/bin"
if installed git; then
if [[ -d "$HOME/install/youtube-dl" ]]; then
cd "$HOME/install/youtube-dl"
git pull
else
git clone https://github.com/ytdl-org/youtube-dl.git "$HOME/install/youtube-dl" --depth=1 --single-branch
fi
else
! installed wget && sudo apt install -y wget
wget https://github.com/ytdl-org/youtube-dl/archive/refs/heads/master.zip -O "$HOME/install/youtube-dl.zip" && \
unzip -oq "$HOME/install/youtube-dl.zip" -d "$HOME/install/youtube-dl"
fi
cd "$HOME/install/youtube-dl" && \
make youtube-dl && \
mv youtube-dl "$HOME/.local/bin"
echo
echo "Finish!"
youtube-dl --version
echo
case "$1" in
*) install ;;
esac