-
Notifications
You must be signed in to change notification settings - Fork 8
188 lines (169 loc) · 7.09 KB
/
icon.yml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Update Icons
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
update-icons:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Clone fanmingming/live
run: |
git clone --depth 1 --branch main https://github.com/fanmingming/live.git
mkdir -p icon
mkdir -p icon_new
for file in live/tv/*.png; do
filename=$(basename "$file" .png | tr '[:lower:]' '[:upper:]' | sed -E 's/[ _-]//g; s/频道$|頻道$|电视台$|電視台$|電視臺$|台$|臺$//g')
cp "$file" "icon_new/${filename}.png"
done
- name: Clone taksssss/TVlogo
run: |
git clone --depth 1 --branch main https://github.com/taksssss/TVlogo.git
- name: Extract channel icons from markdown files
run: |
md_files="TVlogo/md/*.md"
for md_file in $md_files; do
while IFS= read -r line; do
echo "$line" | awk -F'|' '
{
for (i = 2; i <= NF; i += 2) {
channel_name = $i
match($(i + 1), /<img src="([^"]+)"/, arr)
image_url = arr[1]
if (channel_name && image_url) {
gsub(/https:\/\/raw.githubusercontent.com\/taksssss\/TVlogo\/.*\/img\//, "TVlogo/img/", image_url)
gsub(/[ _-]/, "", channel_name)
channel_name = toupper(channel_name)
sub(/频道$|頻道$|电视台$|電視台$|電視臺$|台$|臺$/, "", channel_name)
printf "%s:%s\n", channel_name, image_url
}
}
}
' | while IFS=: read -r channel_name image_url; do
target_path="TVlogo/img/$channel_name.png"
[[ "$image_url" != "$target_path" ]] && mv "$image_url" "$target_path" || echo "Skipped moving $image_url"
done
done < "$md_file"
done
- name: Filter and Copy Icons
run: |
ignore_keywords=("CCTV")
for file in TVlogo/img/*.png; do
filename=$(basename "$file")
for keyword in "${ignore_keywords[@]}"; do
if [[ $filename == *"$keyword"* ]]; then
continue 2
fi
done
cp "$file" "icon_new/$filename"
done
- name: Fetch and Parse 51zmt Icons
run: |
if curl --fail -o assets/51zmt.m3u.tmp http://epg.51zmt.top:8000/test.m3u; then
mv assets/51zmt.m3u.tmp assets/51zmt.m3u
else
rm assets/51zmt.m3u.tmp 2>/dev/null
echo "下载失败,保持原文件不变"
fi
awk -F'tvg-logo=|tvg-name="' '/#EXTINF/ {
match($2, /"([^"]+)"/, logo);
match($3, /([^"]+)"/, name);
if (logo[1] && name[1]) {
gsub(/[ _-]/, "", name[1]);
name[1] = toupper(name[1]);
sub(/频道$|頻道$|电视台$|電視台$|電視臺$|台$|臺$/, "", name[1]);
printf "%s %s\n", name[1], logo[1];
}
}' assets/51zmt.m3u | while read -r tvg_name tvg_logo; do
output_file="icon_new/${tvg_name}.png"
if [ ! -f "$output_file" ]; then
echo "$tvg_logo $output_file"
fi
done | xargs -P 8 -n 2 bash -c 'curl -s "$0" -o "$1"'
- name: Fetch and Parse livednow Icons
env:
PROXY_URL: ${{ secrets.PROXY_URL }}
run: |
sudo apt-get update
sudo apt-get install -y opencc
curl -x "$PROXY_URL" -o guide.html https://assets.livednow.com/guide.html
awk -F'\\| *' '/\| *频道 ID *\| *频道名称 *\| *Logo URL *\| *EPG 状态 */ {
getline;
}
NF > 3 {
gsub(/`|\\/, "", $4);
gsub(/\*\*/, "", $3);
channel_name = toupper($3);
gsub(/[ _-]/, "", channel_name);
sub(/频道$|頻道$|电视台$|電視台$|電視臺$|台$|臺$/, "", channel_name);
if ($4 != "" && !index(channel_name, "CCTV") && $4 ~ /^(http|https):\/\/[^\s]+/) {
printf "%s %s\n", channel_name, $4;
}
}' guide.html | while read -r channel_name logo_url; do
simp_channel_name=$(echo "$channel_name" | opencc -c t2s)
output_file="icon_new/${simp_channel_name}.png"
if [ ! -f "$output_file" ]; then
if [ ! -f "assets/livednow/${simp_channel_name}.png" ]; then
echo "Downloading $logo_url as $output_file"
curl -x "$PROXY_URL" -s "$logo_url" -o "$output_file"
else
echo "Copying existing file to $output_file"
cp "assets/livednow/${simp_channel_name}.png" "$output_file"
fi
else
echo "$output_file already exists, skipping"
fi
done
- name: Copy GDCMCCIPTV, MyUKJ and Others Icons
run: |
for folder in assets/gdcmcciptv assets/myukj assets/others; do
for file in $folder/*.png; do
filename=$(basename "$file" .png | tr '[:lower:]' '[:upper:]' | sed 's/[ _-]//g')
if [ ! -f "icon_new/${filename}.png" ]; then
echo "Copying $filename to icon_new"
cp "$file" "icon_new/${filename}.png"
fi
done
done
- name: Crop Icons
run: |
for file in icon_new/*.png; do
if [ -f "$file" ]; then
echo "Processing $file"
convert "$file" -trim -resize 600x\> "$file" || echo "Failed to process $file"
else
echo "File $file does not exist"
fi
done
- name: Compare and Replace
run: |
for new_file in icon_new/*.png; do
filename=$(basename "$new_file")
if [ ! -f "icon/$filename" ] || ! compare -metric AE "$new_file" "icon/$filename" null: 2> /dev/null; then
cp "$new_file" "icon/$filename"
fi
done
# for old_file in icon/*.png; do
# filename=$(basename "$old_file")
# if [ ! -f "icon_new/$filename" ]; then
# rm "$old_file"
# fi
# done
- name: Generate iconList_default.json
run: |
echo '{' > iconList_default.json
for file in icon/*.png; do
filename=$(basename "$file" .png)
echo "\"$filename\": \"https://gcore.jsdelivr.net/gh/taksssss/tv/icon/$filename.png\"," >> iconList_default.json
done
sed -i '$ s/,$//' iconList_default.json
echo '}' >> iconList_default.json
- name: Commit Changes
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add icon iconList_default.json assets/51zmt.m3u
git commit -m "Update icons and icon list" || echo "No changes to commit"
git push