-
Notifications
You must be signed in to change notification settings - Fork 0
/
media-tools
executable file
·154 lines (143 loc) · 4.76 KB
/
media-tools
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
commands=(
"Compare Audio"
"Convert to Opus"
"Mass Crop Images"
"Mass Thumbnail"
"Remove Audio"
"Rotate Video"
"Sort by Album"
"Sort by Artist"
"Sort by Genre"
"Sort by Resolution"
"View Metadata"
"View Metadata All"
"Quit"
)
selected=0
# Function to display the list and highlight the selected item
display_list() {
clear
echo -e "\033[1m Media Tools\033[0m\n -----------"
for i in "${!commands[@]}"; do
if [ $i -eq $selected ]; then
if [ "${commands[$i]}" == "Quit" ]; then
echo -e "\033[1m➤ ${commands[$i]}\033[0m\n"
else
echo -e "\033[1m➤ ${commands[$i]}\033[0m\n"
fi
else
echo -e " ${commands[$i]}\n"
fi
done
}
# Function to execute the selected command
execute_command() {
case ${commands[$selected]} in
"Compare Audio")
python3 Media-Tools/tools/compare-audio.py
read -p "Press Enter to return to the menu..."
;;
"Convert to Opus")
python3 Media-Tools/tools/convert-to-opus.py
read -p "Press Enter to return to the menu..."
;;
"Mass Crop Images")
python3 Media-Tools/tools/mass-crop-images.py
read -p "Press Enter to return to the menu..."
;;
"Mass Thumbnail")
python3 Media-Tools/tools/mass-thumbnail.py
read -p "Press Enter to return to the menu..."
;;
"Remove Audio")
python3 Media-Tools/tools/remove-audio.py
read -p "Press Enter to return to the menu..."
;;
"Rotate Video")
python3 Media-Tools/tools/rotate-video.py
read -p "Press Enter to return to the menu..."
;;
"Sort by Album")
python3 Media-Tools/tools/sort-by-album.py
read -p "Press Enter to return to the menu..."
;;
"Sort by Artist")
handle_sort_by_artist
;;
"Sort by Genre")
python3 Media-Tools/tools/sort-by-genre.py
read -p "Press Enter to return to the menu..."
;;
"Sort by Resolution")
python3 Media-Tools/tools/sort-by-resolution.py
read -p "Press Enter to return to the menu..."
;;
"View Metadata")
python3 Media-Tools/tools/view-metadata.py
read -p "Press Enter to return to the menu..."
;;
"View Metadata All")
python3 Media-Tools/tools/view-metadata-all.py
read -p "Press Enter to return to the menu..."
;;
"Quit")
echo -e "\n\033[1mExiting script\033[0m"
exit 0
;;
*)
echo -e "\nInvalid selection"
;;
esac
}
# Function to handle Sort by Artist command and its recursive option
handle_sort_by_artist() {
recursive_options=("Default" "Recursive" "Quit")
recursive_selected=0
while true; do
clear
echo -e "\033[1m Sort by Artist Options\033[0m\n "
for i in "${!recursive_options[@]}"; do
if [ $i -eq $recursive_selected ]; then
echo -e "\033[1m➤ ${recursive_options[$i]}\033[0m\n"
else
echo -e " ${recursive_options[$i]}\n"
fi
done
read -sn 1 key
case $key in
"A") ((recursive_selected--)); [ $recursive_selected -lt 0 ] && recursive_selected=$(( ${#recursive_options[@]} - 1 ));;
"B") ((recursive_selected++)); [ $recursive_selected -ge ${#recursive_options[@]} ] && recursive_selected=0 ;;
"")
case ${recursive_options[$recursive_selected]} in
"Default")
python3 Media-Tools/tools/sort-by-artist.py
read -p "Press Enter to return to the menu..."
;;
"Recursive")
python3 Media-Tools/tools/sort-by-artist-r.py
read -p "Press Enter to return to the menu..."
;;
"Quit")
return
;;
*)
echo -e "\nInvalid selection"
;;
esac
;;
*) ;;
esac
done
}
# Main loop
while true; do
display_list
read -sn 1 key
case $key in
"A") ((selected--)); [ $selected -lt 0 ] && selected=$(( ${#commands[@]} - 1 ));;
"B") ((selected++)); [ $selected -ge ${#commands[@]} ] && selected=0 ;;
"") execute_command ;;
*) ;;
esac
done