-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlist-ass-fonts
More file actions
executable file
·80 lines (68 loc) · 1.85 KB
/
list-ass-fonts
File metadata and controls
executable file
·80 lines (68 loc) · 1.85 KB
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
#!/bin/bash
# SPDX-FileCopyrightText: 2021 - 2024 sudorook <daemon@nullcodon.com>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
set -euo pipefail
ROOT="$(dirname "${0}")"
source "${ROOT}"/globals
! check_command sed && exit 3
print_ass_fonts() {
local line="${1}"
local font
local is_bold
local is_italic
local res
font="$(echo "${line}" | cut -d"," -f2)"
is_bold="$(echo "${line}" | cut -d"," -f8)"
is_italic="$(echo "${line}" | cut -d"," -f9)"
res="${font}"
if ((is_bold == -1)); then
res+=" (Bold)"
fi
if ((is_italic == -1)); then
res+=" (Italic)"
fi
echo "${res}"
}
parse_lines() {
local file="${1}"
local extension="${file##*.}"
local line
case "${extension}" in
ass | ssa)
while read -r line; do
print_ass_fonts "${line}"
done <<< "$(sed -n "s/^Style: \(.*\)/\1/p" "${file}")"
;;
esac
}
iterate_files() {
local file
local extension
local line
if [ -d "${1}" ]; then
for file in "${1}"/*; do
if [[ "$(file -ib "${file}")" =~ text/plain ]]; then
parse_lines "${file}"
fi
done
elif [ -f "${1}" ]; then
if [[ "$(file -ib "${1}")" =~ text/plain ]]; then
parse_lines "${1}"
fi
fi
}
iterate_files "${@}" | sort -u