handbrake_for_plex.sh

-si une nouvelle version de handbrakeCLI est disponible, on affiche les nouveautés
This commit is contained in:
2025-02-28 20:49:45 +01:00
parent b264b99cf0
commit 0e6f7c5196

View File

@@ -31,6 +31,7 @@ shopt -s globstar
DEST_EXT=mp4 DEST_EXT=mp4
# Handbrake preset # Handbrake preset
# handbrakeCli --preset-list (or -z) to get all availables profiles
[[ "$profile" == "" ]] && PRESET="Apple 720p30 Surround" || PRESET="$profile" [[ "$profile" == "" ]] && PRESET="Apple 720p30 Surround" || PRESET="$profile"
# Only files larger than $MAXSIZE will be processed (> 30Mo) # Only files larger than $MAXSIZE will be processed (> 30Mo)
@@ -118,19 +119,35 @@ showHelp() {
update_handbrake() { update_handbrake() {
# https://www.thegeekdiary.com/how-to-install-dmg-file-on-mac-from-command-line/
if [ "$(printf '%s\n' "$HB_VERSION" "$last_hbc_release" | sort -V | head -n1)" = "$HB_VERSION" ]; then if [ "$(printf '%s\n' "$HB_VERSION" "$last_hbc_release" | sort -V | head -n1)" = "$HB_VERSION" ]; then
if [ "$HB_VERSION" != "$last_hbc_release" ]; then if [ "$HB_VERSION" != "$last_hbc_release" ]; then
# release=$(gh release list -L 1 --repo HandBrake/HandBrake | cut -f1 | xargs -I{} gh release view {} --repo HandBrake/HandBrake)
# news=$(echo "$release" | awk '/Upgrade Notice/,0')
# news=$(gh release list -L 1 --repo HandBrake/HandBrake | cut -f1 | xargs -I{} gh release view {} --repo HandBrake/HandBrake | awk '/Upgrade Notice/,0')
# asset=$(echo "$release" | awk '/Upgrade Notice/{exit} 1' | grep '^asset:' | grep -v '.sig' | grep 'HandBrakeCLI' | cut -f 2)
# url = https://github.com/HandBrake/HandBrake/releases/download/1.9.2/HandBrakeCLI-1.9.2.dmg
latest=$(curl --silent "https://api.github.com/repos/${gh_hbc_repo}/releases/latest")
last_hbc_dl_url=$(echo "$latest" | grep 'HandBrakeCLI' | grep -v '.sig' | grep 'browser_download_url' | awk -F": " '{print $2}' | sed 's/"//g')
last_hbc_news=$(echo "$latest" | jq '.body')
echo -e "${green}Current version: $HB_VERSION - Version $last_hbc_release available !${reset}" 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 echo -e "$last_hbc_news"
a=$(echo -e "${bold}Do you want to install HandBrakeCLI v$last_hbc_release (y/n)${reset}")
read -p "$a" hbc
if [[ "$hbc" == "y" || "$hbc" == "Y" ]]; then 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 if [[ "$OSTYPE" == "darwin"* ]]; then
url=$(echo "$last_hbc_dl_url" | grep '.dmg') url=$(echo "$last_hbc_dl_url" | grep '.dmg')
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
url=$(echo "$last_hbc_dl_url" | grep '.flatpak') url=$(echo "$last_hbc_dl_url" | grep '.flatpak')
fi fi
echo "Downloading $url" echo "Downloading $url"
dest=$HOME/Downloads dest=$HOME/Downloads
filename=$(basename $url) filename=$(basename $url)
@@ -148,8 +165,6 @@ update_handbrake() {
cp "$app" $install_folder cp "$app" $install_folder
fi fi
echo "$last_hbc_release"
x="$install_folder""HandBrakeCLI" x="$install_folder""HandBrakeCLI"
if [ -f "$x" ]; then if [ -f "$x" ]; then
v=$("$x" --version 2>/dev/null | awk '{print $2}') v=$("$x" --version 2>/dev/null | awk '{print $2}')
@@ -475,11 +490,6 @@ END_COMMENT
done < <(echo "$infos" | jq -c '.[]') done < <(echo "$infos" | jq -c '.[]')
echo -e "${red}nb_audio: $nb_audio${reset}"
echo -e "${red}nb_text: $nb_text${reset}"
echo -e "${red}nb_menu: $nb_menu${reset}"
# Menu # Menu
#menu=$(echo "$infos" | jq -j '.[] | .Menu' | sed '1d;$d') #menu=$(echo "$infos" | jq -j '.[] | .Menu' | sed '1d;$d')