handbrake_for_plex.sh
-ajout d’une notification quand la conversion est finie -ajout d’un fichier /tmp/HandBrake.log pour limiter le verbiage
This commit is contained in:
@@ -25,7 +25,7 @@ showHelp() {
|
|||||||
echo "USAGE: handbrake_for_plex.sh"
|
echo "USAGE: handbrake_for_plex.sh"
|
||||||
echo
|
echo
|
||||||
echo "Configure:"
|
echo "Configure:"
|
||||||
echo " -\$SRC : source folder (récursive)"
|
echo " -\$SRC : source folder (recursive)"
|
||||||
echo " -\$DEST : destination folder"
|
echo " -\$DEST : destination folder"
|
||||||
echo " -\$DEST_EXT : destination extension"
|
echo " -\$DEST_EXT : destination extension"
|
||||||
echo " -\$PRESET : preset HandBrake"
|
echo " -\$PRESET : preset HandBrake"
|
||||||
@@ -33,7 +33,7 @@ showHelp() {
|
|||||||
echo
|
echo
|
||||||
echo "OPTION:"
|
echo "OPTION:"
|
||||||
echo " -h display this help"
|
echo " -h display this help"
|
||||||
echo " -i source folder (récursive)"
|
echo " -i source folder (recursive)"
|
||||||
echo " -o destination folder"
|
echo " -o destination folder"
|
||||||
echo " -p preset HandBrake"
|
echo " -p preset HandBrake"
|
||||||
echo
|
echo
|
||||||
@@ -44,6 +44,32 @@ showHelp() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notification() {
|
||||||
|
#path_img=`dirname "$0"`
|
||||||
|
path_img=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
if [ $3 -eq 0 ];
|
||||||
|
then
|
||||||
|
sound="Glass"
|
||||||
|
#message="Envoi terminé sur $2 !"
|
||||||
|
image="$path_img/success.png"
|
||||||
|
#image="$path_img/HandBrake.icns"
|
||||||
|
else
|
||||||
|
sound="Basso"
|
||||||
|
#message="Echec lors de l'envoi sur $2"
|
||||||
|
image="$path_img/error.png"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v zenity)" ]; then
|
||||||
|
zenity --title="$1" --notification --text="$2"
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
|
||||||
|
# -appIcon ne marche avec BigSur
|
||||||
|
#terminal-notifier -title "$1" -message "$2" -sound "$sound" -contentImage "$image" -activate "com.colliderli.iina"
|
||||||
|
terminal-notifier -title "$1" -message "$2" -sound "$sound" -appIcon "https://sur-le-sentier.fr/HandBrake.png" -activate "com.colliderli.iina"
|
||||||
|
# org.galad.Subler.plist com.colliderli.iina.plist -appIcon http://vjeantet.fr/images/logo.png
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
while getopts "h?i:o:p:" opt; do
|
while getopts "h?i:o:p:" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
h|\?)
|
h|\?)
|
||||||
@@ -85,10 +111,14 @@ DEST_EXT=mp4
|
|||||||
|
|
||||||
# Only files larger than $MAXSIZE will be processed
|
# Only files larger than $MAXSIZE will be processed
|
||||||
MAXSIZE=30000000
|
MAXSIZE=30000000
|
||||||
|
#MAXSIZE=300
|
||||||
|
|
||||||
# Open converted video file in an application
|
# Open converted video file in an application
|
||||||
APP="Subler"
|
APP="Subler"
|
||||||
|
|
||||||
|
# log
|
||||||
|
logfile=/tmp/HandBrake.log
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
echo "_ _ ____ _ _ ___ ___ ____ ____ _ _ ____ ____ ____ ____ ___ _ ____ _ _ ";
|
echo "_ _ ____ _ _ ___ ___ ____ ____ _ _ ____ ____ ____ ____ ___ _ ____ _ _ ";
|
||||||
@@ -101,15 +131,17 @@ echo "
|
|||||||
version=$(ls /opt/homebrew/Cellar/handbrake 2>/dev/null)
|
version=$(ls /opt/homebrew/Cellar/handbrake 2>/dev/null)
|
||||||
if [ "$version" != "" ]; then
|
if [ "$version" != "" ]; then
|
||||||
HANDBRAKE_CLI="/opt/homebrew/Cellar/handbrake/$version/bin/HandBrakeCLI"
|
HANDBRAKE_CLI="/opt/homebrew/Cellar/handbrake/$version/bin/HandBrakeCLI"
|
||||||
echo -e "${bold}Handbrake $version${reset}\n"
|
echo -e "${bold}HandBrake $version${reset}"
|
||||||
|
echo -e "$HANDBRAKE_CLI\n"
|
||||||
else {
|
else {
|
||||||
cli=$(which HandBrakeCLI)
|
cli=$(which HandBrakeCLI)
|
||||||
if [ "$cli" != "" ]; then
|
if [ "$cli" != "" ]; then
|
||||||
HANDBRAKE_CLI="$cli"
|
HANDBRAKE_CLI="$cli"
|
||||||
version=$("$HANDBRAKE_CLI" --version 2>/dev/null | sed -n '1p')
|
version=$("$HANDBRAKE_CLI" --version 2>/dev/null | sed -n '1p')
|
||||||
echo "${bold}$version${reset}"
|
echo -e "${bold}HandBrake $version${reset}"
|
||||||
|
echo -e "$HANDBRAKE_CLI\n"
|
||||||
else
|
else
|
||||||
echo -e "${red}handbrake not installed!${reset}\n"
|
echo -e "${red}HandBrake not installed!${reset}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -142,7 +174,7 @@ do
|
|||||||
FILESIZE=$(stat -c%s "$FILE")
|
FILESIZE=$(stat -c%s "$FILE")
|
||||||
|
|
||||||
if (( FILESIZE > MAXSIZE )); then
|
if (( FILESIZE > MAXSIZE )); then
|
||||||
|
|
||||||
: <<'END_COMMENT'
|
: <<'END_COMMENT'
|
||||||
https://stackoverflow.com/questions/41231998/mediainfo-cli-command-line-interface-syntax-teaching-me-once-for-all
|
https://stackoverflow.com/questions/41231998/mediainfo-cli-command-line-interface-syntax-teaching-me-once-for-all
|
||||||
media=$(mediainfo --Output=file:///$SCRIPT_DIR/template.txt "$FILE")
|
media=$(mediainfo --Output=file:///$SCRIPT_DIR/template.txt "$FILE")
|
||||||
@@ -223,15 +255,15 @@ END_COMMENT
|
|||||||
done <<< "$menu"
|
done <<< "$menu"
|
||||||
|
|
||||||
|
|
||||||
echo -e "\n\n🎬 ${bold}$filename${reset}"
|
echo -e "\n\n ${bold}$filename${reset}"
|
||||||
|
|
||||||
echo -e "\n${bold}Général:${reset}"
|
echo -e "\n${bold}General:${reset}"
|
||||||
printf " %-20s %-35s \n" "Format de fichier:" "${format_fichier}"
|
printf " %-20s %-35s \n" "Format de fichier:" "${format_fichier}"
|
||||||
printf " %-20s %-35s \n" "Taille de fichier:" "${filesize}"
|
printf " %-20s %-35s \n" "Taille de fichier:" "${filesize}"
|
||||||
printf " %-21s %-35s \n" "Durée:" "${duree}"
|
printf " %-21s %-35s \n" "Duree:" "${duree}"
|
||||||
|
|
||||||
echo -e "\n${bold}Vidéo:${reset}"
|
echo -e "\n${bold}Video:${reset}"
|
||||||
printf " %-21s %-35s \n" "Format vidéo:" "${format_video}"
|
printf " %-21s %-35s \n" "Format video:" "${format_video}"
|
||||||
printf " %-20s %-35s \n" "Profile:" "${format_profile}"
|
printf " %-20s %-35s \n" "Profile:" "${format_profile}"
|
||||||
printf " %-20s %-35s \n" "Level:" "${format_level}"
|
printf " %-20s %-35s \n" "Level:" "${format_level}"
|
||||||
printf " %-20s %-35s \n" "Codec:" "${codec_video}"
|
printf " %-20s %-35s \n" "Codec:" "${codec_video}"
|
||||||
@@ -265,7 +297,14 @@ END_COMMENT
|
|||||||
|
|
||||||
if [ ! -f "$file_export" ]; then
|
if [ ! -f "$file_export" ]; then
|
||||||
echo -e "\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}\n"
|
echo -e "\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}\n"
|
||||||
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET"
|
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" 2> $logfile
|
||||||
|
|
||||||
|
result=$?
|
||||||
|
if [ "$result" = 0 ]; then
|
||||||
|
notification "HandBrake for Plex" "$new_name available in $DEST" $result
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
((count++))
|
((count++))
|
||||||
|
|
||||||
@@ -287,7 +326,7 @@ END_COMMENT
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
FILESIZE=
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user