-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathepg.sh
executable file
·51 lines (40 loc) · 1.3 KB
/
epg.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
#!/bin/sh
# path: /home/klassiker/.local/share/repos/epg/epg.sh
# author: klassiker [mrdotx]
# github: https://github.com/mrdotx/epg
# date: 2025-01-09T07:20:07+0100
# config
logo_file="$HOME/.local/share/repos/epg/logos.csv"
# helper
sync_file() {
rsync_options="-acqPh --chmod=F644"
result=" synced"
[ "$1" = "--move" ] \
&& shift \
&& rsync_options="$rsync_options --remove-source-files" \
&& result=" moved"
eval "rsync $rsync_options $1 $2" \
&& printf "%s: %s -> %s\n" "$result" "$1" "$2"
}
update_logos() {
while IFS= read -r line; do
logo=$(printf "%s" "$line" | cut -d';' -f1 | sed 's#\/#\\/#')
url=$(printf "%s" "$line" | cut -d';' -f2)
sed -i "/<display-name.*>$logo<\/display-name>/{n;s#.*# <icon src=\"$url\" \/>#}" "$1"
done < "$logo_file" \
&& printf "updated: %s -> urls for channel logos\n" "$1"
}
# execute webgrab++
wg++ >/dev/null 2>&1
# post process
update_logos \
"$HOME/wg++/epg.xml"
# move epg file to web server
[ "$(stat -c %s "$HOME/wg++/epg.xml")" -gt 16384 ] \
&& sync_file --move \
"$HOME/wg++/epg.xml" \
"/srv/http/epg/epg.xml"
# sync channels file with web server
sync_file \
"$HOME/.local/share/repos/epg/playlists/xitylight.m3u" \
"/srv/http/epg/channels.m3u"