chore: rename create_conf script then lefthook analyse it when commit
This commit is contained in:
parent
f113664131
commit
5ff1e36a53
2 changed files with 31 additions and 37 deletions
|
@ -14,6 +14,6 @@ in
|
||||||
frei0r
|
frei0r
|
||||||
inkscape
|
inkscape
|
||||||
];
|
];
|
||||||
home.file.".local/bin/create_conf".source = ./files/create_conf;
|
home.file.".local/bin/create_conf".source = ./files/create_conf.sh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
error() {
|
error() {
|
||||||
printf -v message "\e[31mERROR:\e[0m %s\n" "$1"
|
printf -v message "\e[31mERROR:\e[0m %s\n" "$1"
|
||||||
message="${message} \e[1mStack trace\e[0m:\n"
|
message="${message} \e[1mStack trace\e[0m:\n"
|
||||||
for (( i=1; i<${#FUNCNAME[@]}; i++ ))
|
for ((i = 1; i < ${#FUNCNAME[@]}; i++)); do
|
||||||
do
|
|
||||||
if [[ $i = $((${#FUNCNAME[@]} - 1)) ]]; then
|
if [[ $i = $((${#FUNCNAME[@]} - 1)) ]]; then
|
||||||
message="${message} └"
|
message="${message} └"
|
||||||
else
|
else
|
||||||
|
@ -12,7 +11,7 @@ error() {
|
||||||
fi
|
fi
|
||||||
message="${message}─ source:\e[3;34m${BASH_SOURCE[$i]}\e[0m"
|
message="${message}─ source:\e[3;34m${BASH_SOURCE[$i]}\e[0m"
|
||||||
message="${message} function:\e[3;34m${FUNCNAME[$i]}\e[0m"
|
message="${message} function:\e[3;34m${FUNCNAME[$i]}\e[0m"
|
||||||
message="${message} line:\e[3;34m${BASH_LINENO[$i-1]}\e[0m\n"
|
message="${message} line:\e[3;34m${BASH_LINENO[$i - 1]}\e[0m\n"
|
||||||
done
|
done
|
||||||
>&2 printf "%b\n" "${message}"
|
>&2 printf "%b\n" "${message}"
|
||||||
}
|
}
|
||||||
|
@ -25,17 +24,18 @@ die() {
|
||||||
process_args() {
|
process_args() {
|
||||||
while :; do
|
while :; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-l|--label)
|
-l | --label)
|
||||||
key_label="$2"
|
key_label="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-r|--recorder)
|
-r | --recorder)
|
||||||
recorder_label="$2"
|
recorder_label="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
conf="$*"
|
conf="$*"
|
||||||
break
|
break
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
@ -87,19 +87,15 @@ get_file_hash() {
|
||||||
|
|
||||||
file=$1
|
file=$1
|
||||||
file_size=${2:-1}
|
file_size=${2:-1}
|
||||||
if (( file_size != -1 ))
|
if ((file_size != -1)); then
|
||||||
then
|
if [[ -f "$file" ]]; then
|
||||||
if [ -f "$file" ]
|
if ((file_size > 0)); then
|
||||||
then
|
if ((file_size > 2000000)); then
|
||||||
if (( file_size > 0 ))
|
|
||||||
then
|
|
||||||
if (( file_size > 2000000 ))
|
|
||||||
then
|
|
||||||
#calculate
|
#calculate
|
||||||
local tmp_file
|
local tmp_file
|
||||||
tmp_file=mktemp
|
tmp_file=mktemp
|
||||||
head -c 1MB "$file" > "$tmp_file"
|
head -c 1MB "$file" >"$tmp_file"
|
||||||
tail -c 1MB "$file" >> "$tmp_file"
|
tail -c 1MB "$file" >>"$tmp_file"
|
||||||
printf "%s" "$(md5sum "$tmp_file" | cut -d" " -f 1)"
|
printf "%s" "$(md5sum "$tmp_file" | cut -d" " -f 1)"
|
||||||
rm "$tmp_file"
|
rm "$tmp_file"
|
||||||
else
|
else
|
||||||
|
@ -112,7 +108,7 @@ get_file_hash() {
|
||||||
printf "%s" -1
|
printf "%s" -1
|
||||||
}
|
}
|
||||||
|
|
||||||
move_file(){
|
move_file() {
|
||||||
if [[ ! $# -eq 2 ]]; then
|
if [[ ! $# -eq 2 ]]; then
|
||||||
error "move_file need 2 arguments, $# provided : '$*'"
|
error "move_file need 2 arguments, $# provided : '$*'"
|
||||||
return 1
|
return 1
|
||||||
|
@ -140,9 +136,8 @@ get_file_size() {
|
||||||
fi
|
fi
|
||||||
local file
|
local file
|
||||||
file=$1
|
file=$1
|
||||||
if [ -f "$file" ]
|
if [[ -f "$file" ]]; then
|
||||||
then
|
wc -c <"$file"
|
||||||
wc -c < "$file"
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
printf "%s" -1
|
printf "%s" -1
|
||||||
|
@ -167,10 +162,10 @@ insert_media() {
|
||||||
filesize=$(get_file_size "$filename")
|
filesize=$(get_file_size "$filename")
|
||||||
filehash=$(get_file_hash "$filename" "$filesize")
|
filehash=$(get_file_hash "$filename" "$filesize")
|
||||||
if ! sed -i \
|
if ! sed -i \
|
||||||
-e "s#\[\[${tag}\]\]#${filename}#g" \
|
-e "s#\[\[${tag}\]\]#${filename}#g" \
|
||||||
-e "s#\[\[${tag}_filesize\]\]#${filesize}#g" \
|
-e "s#\[\[${tag}_filesize\]\]#${filesize}#g" \
|
||||||
-e "s#\[\[${tag}_filehash\]\]#${filehash}#g" \
|
-e "s#\[\[${tag}_filehash\]\]#${filehash}#g" \
|
||||||
"${folder}/montage.kdenlive"; then
|
"${folder}/montage.kdenlive"; then
|
||||||
error "sed command error on insert media!"
|
error "sed command error on insert media!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -196,7 +191,6 @@ function main() {
|
||||||
# create it
|
# create it
|
||||||
mkdir "${folder}/"{rushes,audio,titles} -p || die "folder creation failed"
|
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}/logo_amis.svg" "${folder}/titles" || die "SVG copy failed!"
|
||||||
cp "${base_dir}/template.kdenlive" "${folder}/montage.kdenlive" || die "Template copy failed!"
|
cp "${base_dir}/template.kdenlive" "${folder}/montage.kdenlive" || die "Template copy failed!"
|
||||||
|
|
||||||
|
@ -209,7 +203,7 @@ function main() {
|
||||||
sed -i "s/\[\[date\]\]/${inkscape_date}/g" "${folder}/titles/logo_amis.svg" || die "Change date failed!"
|
sed -i "s/\[\[date\]\]/${inkscape_date}/g" "${folder}/titles/logo_amis.svg" || die "Change date failed!"
|
||||||
|
|
||||||
printf "Export SVG title \n"
|
printf "Export SVG title \n"
|
||||||
inkscape --export-type="png" "${folder}/titles/logo_amis.svg" || die "Export failed"
|
inkscape --export-type="png" "${folder}/titles/logo_amis.svg" || die "SVG export failed"
|
||||||
|
|
||||||
printf "Importing PNG File in %s/montage.kdenlive \n" "$folder"
|
printf "Importing PNG File in %s/montage.kdenlive \n" "$folder"
|
||||||
insert_media "$folder/titles/logo_amis.png" "logo"
|
insert_media "$folder/titles/logo_amis.png" "logo"
|
Loading…
Add table
Add a link
Reference in a new issue