forked from TheAMM/mpv_crop_script
/
mpv_gif_data.sh
executable file
·66 lines (59 loc) · 1.52 KB
/
mpv_gif_data.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
meta="metadata-default.yml"
level1=" "
level2=" "
level3=" "
level4=" "
level5=" "
_timestamp () {
h=$(bc <<< "${1}/3600")
m=$(bc <<< "(${1}%3600)/60")
s=$(bc <<< "${1}%60")
printf "%02d:%02d:%06.3f" "$h" "$m" "$s"
}
get_file_name () {
file_name="$1"
echo "$file_name" | xclip -selection clipboard && notify-send "copied $file_name"
printf -- "---\n" >> "$meta"
printf "video: $file_name\n" >> "$meta"
printf "clips:\n" >> "$meta"
#printf "video:\n" >> "$meta"
#printf "${level1}name: $file_name\n" >> "$meta"
#printf "${level1}scene:\n" >> "$meta"
}
copy_start_stamp () {
stamp=$(_timestamp "$1")
echo "$1" | xclip -selection clipboard && notify-send "copied $stamp"
printf -- "- s: '$stamp'\n" >> "$meta"
#printf "${level1}- clip:\n" >> "$meta"
#printf "${level3}s: '$stamp'\n" >> "$meta"
}
copy_end_stamp () {
stamp=$(_timestamp "$1")
echo "$stamp" | xclip -selection clipboard && notify-send "copied $stamp"
printf "${level1}e: '$stamp'\n" >> "$meta"
#printf "${level3}e: '$stamp'\n" >> "$meta"
}
crop_sq () {
sq="${1}"
arr=$(echo "${sq##@mpv_crop_script_asscropper_crop:crop=}" |\
tr -d '[[:alpha:]]' | tr -d '=' | sed 's/:/,/g')
echo "[$arr]" | xclip -selection clipboard && notify-send "[$arr]"
printf "${level1}crop: [$arr]\n" >> "$meta"
}
for i in "$@"; do
case $i in
s)
copy_start_stamp "$2"
shift;;
d)
copy_end_stamp "$2"
shift;;
v)
get_file_name "$2"
shift;;
n)
crop_sq "$2"
shift;;
esac
done