handbrake_for_plex.sh
-mise-à-jour de handbrakeCli depuis Github
This commit is contained in:
@@ -116,6 +116,60 @@ showHelp() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_handbrake() {
|
||||||
|
|
||||||
|
if [ "$(printf '%s\n' "$HB_VERSION" "$last_hbc_release" | sort -V | head -n1)" = "$HB_VERSION" ]; then
|
||||||
|
|
||||||
|
if [ "$HB_VERSION" != "$last_hbc_release" ]; then
|
||||||
|
|
||||||
|
echo -e "${green}Current version: $HB_VERSION - Version $last_hbc_release available !${reset}"
|
||||||
|
read -p "Do you want to install HandBrakeCLI v$last_hbc_release (y/n)" hbc
|
||||||
|
if [[ "$hbc" == "y" || "$hbc" == "Y" ]]; then
|
||||||
|
last_hbc_dl_url=$(curl --silent "https://api.github.com/repos/${gh_hbc_repo}/releases/latest" | grep 'HandBrakeCLI' | grep -v '.sig' | grep 'browser_download_url' | awk -F": " '{print $2}' | sed 's/"//g')
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
url=$(echo "$last_hbc_dl_url" | grep '.dmg')
|
||||||
|
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
|
url=$(echo "$last_hbc_dl_url" | grep '.flatpak')
|
||||||
|
fi
|
||||||
|
echo "Downloading $url"
|
||||||
|
dest=$HOME/Downloads
|
||||||
|
filename=$(basename $url)
|
||||||
|
curl -L -O --output-dir $dest "$url"
|
||||||
|
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
|
||||||
|
vol=$(hdiutil mount $dest/$filename | tail -1 | awk '{print $3}')
|
||||||
|
|
||||||
|
app=$vol/HandBrakeCLI
|
||||||
|
install_folder=$HOME/.local/bin/
|
||||||
|
|
||||||
|
if [ -f "$app" ]; then
|
||||||
|
echo "Copying $filename to $install_folder"
|
||||||
|
cp "$app" $install_folder
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$last_hbc_release"
|
||||||
|
|
||||||
|
x="$install_folder""HandBrakeCLI"
|
||||||
|
if [ -f "$x" ]; then
|
||||||
|
v=$("$x" --version 2>/dev/null | awk '{print $2}')
|
||||||
|
if [ "$v" == "$last_hbc_release" ]; then
|
||||||
|
echo -e "${green}HandBrakeCLI v$v successfully installed !${reset}"
|
||||||
|
else
|
||||||
|
echo -e "${red}HandBrakeCLI v$v installed !${reset}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $HOME
|
||||||
|
hdiutil unmount $vol
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
installation() {
|
installation() {
|
||||||
#long_path=`pwd`"/"`basename "$0"`
|
#long_path=`pwd`"/"`basename "$0"`
|
||||||
long_path=$(realpath "$0")
|
long_path=$(realpath "$0")
|
||||||
@@ -200,6 +254,18 @@ shift $((OPTIND-1))
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Github="https://github.com/HandBrake/HandBrake"
|
||||||
|
# Public Repo:
|
||||||
|
#RawUrl="https://raw.githubusercontent.com/Bruno21/bashbirds/main/bashbirds.sh"
|
||||||
|
# Private Repo:
|
||||||
|
RawUrl="https://x-access-token:$GITHUB_TOKEN@raw.githubusercontent.com/HandBrake/HandBrake/main/bashbirds.sh"
|
||||||
|
|
||||||
|
### Check if there's a new release of the script:
|
||||||
|
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
|
||||||
|
#LatestChanges="$(curl -s -r 0-2000 $RawUrl | sed -n "/ChangeNotes/s/# ChangeNotes: //p")"
|
||||||
|
LatestChanges="$(curl -s -r 0-2000 $RawUrl | grep "^### ChangeNotes:" | sed 's/### ChangeNotes://g')"
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
echo "_ _ ____ _ _ ___ ___ ____ ____ _ _ ____ ____ ____ ____ ___ _ ____ _ _ ";
|
echo "_ _ ____ _ _ ___ ___ ____ ____ _ _ ____ ____ ____ ____ ___ _ ____ _ _ ";
|
||||||
@@ -209,25 +275,44 @@ echo "
|
|||||||
echo " ";
|
echo " ";
|
||||||
echo " ";
|
echo " ";
|
||||||
|
|
||||||
version=$(ls /opt/homebrew/Cellar/handbrake 2>/dev/null)
|
gh_hbc_repo="HandBrake/HandBrake"
|
||||||
if [ "$version" != "" ]; then
|
last_hbc_release=$(curl --silent "https://api.github.com/repos/${gh_hbc_repo}/releases/latest" | grep -Po "(?<=\"tag_name\": \").*(?=\")")
|
||||||
HANDBRAKE_CLI="/opt/homebrew/Cellar/handbrake/$version/bin/HandBrakeCLI"
|
|
||||||
echo -e "${bold}HandBrake $version${reset}"
|
version_brew=$(ls /opt/homebrew/Cellar/handbrake 2>/dev/null)
|
||||||
echo -e "$HANDBRAKE_CLI\n"
|
cli=$(which HandBrakeCLI) # /Users/bruno/.local/bin/HandBrakeCLI
|
||||||
else {
|
version_cli=$("$cli" --version 2>/dev/null | awk '{print $2}') # HandBrake 1.9.2
|
||||||
cli=$(which HandBrakeCLI)
|
|
||||||
if [ "$cli" != "" ]; then
|
if [ "$version_brew" != "" ]; then
|
||||||
HANDBRAKE_CLI="$cli"
|
if [ "$version_cli" != "" ]; then
|
||||||
version=$("$HANDBRAKE_CLI" --version 2>/dev/null | sed -n '1p')
|
if [ "$(printf '%s\n' "$version_cli" "$version_brew" | sort -V | head -n1)" = "$version_cli" ]; then
|
||||||
echo -e "${bold}HandBrake $version${reset}"
|
HANDBRAKE_CLI="/opt/homebrew/Cellar/handbrake/$version/bin/HandBrakeCLI"
|
||||||
echo -e "$HANDBRAKE_CLI\n"
|
HB_VERSION="$version_brew"
|
||||||
|
else
|
||||||
|
HANDBRAKE_CLI="$cli"
|
||||||
|
HB_VERSION="$version_cli"
|
||||||
|
|
||||||
|
update_handbrake
|
||||||
|
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${red}HandBrake not installed!${reset}\n"
|
HANDBRAKE_CLI="/opt/homebrew/Cellar/handbrake/$version/bin/HandBrakeCLI"
|
||||||
|
HB_VERSION="$version_brew"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$version_cli" != "" ]; then
|
||||||
|
HANDBRAKE_CLI="$cli"
|
||||||
|
HB_VERSION="$version_cli"
|
||||||
|
|
||||||
|
update_handbrake
|
||||||
|
else
|
||||||
|
echo -e "\n${red}HandBrake not installed!${reset}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -e "\n${bold}HandBrake $HB_VERSION${reset}"
|
||||||
|
echo -e "$HANDBRAKE_CLI\n"
|
||||||
|
|
||||||
echo -e "Source folder: ${italic}$SRC${reset}"
|
echo -e "Source folder: ${italic}$SRC${reset}"
|
||||||
echo -e "Destination folder: ${italic}$DEST${reset}"
|
echo -e "Destination folder: ${italic}$DEST${reset}"
|
||||||
echo -e "HandBrake Profile: ${italic}$PRESET${reset}"
|
echo -e "HandBrake Profile: ${italic}$PRESET${reset}"
|
||||||
|
|||||||
Reference in New Issue
Block a user