77 lines
2.2 KiB
Bash
Executable file
77 lines
2.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
error() {
|
|
>&2 printf "\e[31mE\e[0m %s\n" "$1"
|
|
}
|
|
|
|
die() {
|
|
error "$*"
|
|
exit 1
|
|
}
|
|
|
|
process_args() {
|
|
while :; do
|
|
case $1 in
|
|
-l|--label)
|
|
key_label="$2"
|
|
shift
|
|
;;
|
|
*)
|
|
break
|
|
esac
|
|
shift
|
|
done
|
|
}
|
|
test=""
|
|
base_dir="${HOME}/medias/videos/sambab"
|
|
|
|
conf="$*"
|
|
key_label=${key_label:-SAMBAB}
|
|
|
|
|
|
printf "Creation de la conférence de %s\n" "$conf"
|
|
cd ~/medias/videos/sambab || exit 1
|
|
|
|
#Get las friday date for creating folder
|
|
friday=$(date --date='last Friday' +"%Y.%m.%d")
|
|
|
|
#Add basedir, then I have my directory
|
|
folder="${base_dir}/${friday}-${conf// /_}"
|
|
|
|
#create it
|
|
mkdir "${folder}"/{rushes,audio,titles} -p || die "folder creation failed"
|
|
|
|
|
|
cp "${base_dir}/logo_amis.svg" "${folder}/titles" || die "SVG copy failed!"
|
|
cp "${base_dir}/template.kdenlive" "${folder}/montage.kdenlive" || dir "Template copy failed!" }
|
|
|
|
inkscape_date=$(LC_ALL=fr_FR.UTF-8 date --date='last Friday' +"%A %d %B %Y")
|
|
|
|
printf "Put Name on title\n"
|
|
sed -i "s/\[\[conf\]\]/${conf//_/ }/g" ${folder}/titles/logo_amis.svg || die "Change text on credits screen failed!"
|
|
|
|
printf "Put date on title\n"
|
|
sed -i "s/\[\[date\]\]/${inkscape_date}/g" ${folder}/titles/logo_amis.svg || die "Change date failed!"
|
|
|
|
printf "Importing PNG File in %s/montage.kdenlive \n" "$folder"
|
|
sed -i "s#\[\[logo\]\]#${folder}/titles/logo_amis.png#g" "${folder}"/montage.kdenlive || die "Import failed!"
|
|
|
|
printf "Export SVG title \n"
|
|
inkscape --export-type="png" "${folder}/titles/logo_amis.svg" || die "Export failed"
|
|
|
|
echo "Mount USBkey with Label $key_label"
|
|
usb_key="/dev/$(lsblk -o KNAME,LABEL | grep ${key_label} | awk '{print $1}')"
|
|
[[ ! $usb_key = "/dev/" ]] || die "Can't getting device name, is USB key plugged? $usb_key"
|
|
|
|
|
|
disk="$(udisksctl mount -b ${usb_key} | awk '{print $4}')"
|
|
sleep 1
|
|
[[ -n $disk ]] || die " -> Error mounting device $usb_key"
|
|
|
|
echo "Copy files from USB key"
|
|
mv ${disk}/$(date --date='last Friday' +'%Y-%m-%d')\ *.mkv "${folder}/rushes/" || error "Moving video file failed!"
|
|
|
|
mv ${disk}/RECORD/EXREC/*.MP3 "${folder}/audio/" || error "Moving audio file failed!"
|
|
|
|
udisksctl unmount -b ${usb_key}
|
|
exit 0
|