-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathxmltv.sh
34 lines (27 loc) · 1.16 KB
/
xmltv.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
#!/bin/bash
# Eingabedatei (M3U)
input_file="Freetv.m3u"
# Ausgabedatei (XMLTV)
output_file="epg.xmltv"
# XMLTV Header
echo '<?xml version="1.0" encoding="UTF-8"?>' > "$output_file"
echo '<tv>' >> "$output_file"
# EPG aus M3U auslesen
while IFS= read -r line; do
if [[ $line == *"#EXTINF:"* ]]; then
# Extrahiere den Sendernamen und die EPG-Daten
channel_name=$(echo "$line" | sed 's/#EXTINF:-1,//;s/,.*//')
epg_data=$(echo "$line" | sed 's/#EXTINF:-1,[^,]*,//')
# Füge den Channel zur XMLTV-Datei hinzu
echo " <channel id=\"$channel_name\">" >> "$output_file"
echo " <display-name>$channel_name</display-name>" >> "$output_file"
echo " </channel>" >> "$output_file"
# Füge die EPG-Daten hinzu
echo " <programme start=\"$(date +%Y%m%d%H%M%S) +0000\" stop=\"$(date +%Y%m%d%H%M%S -d '+1 hour') +0000\" channel=\"$channel_name\">" >> "$output_file"
echo " <title>$epg_data</title>" >> "$output_file"
echo " </programme>" >> "$output_file"
fi
done < "$input_file"
# XMLTV Footer
echo '</tv>' >> "$output_file"
echo "EPG-Daten wurden erfolgreich in $output_file gespeichert."