Skip to content

Commit

Permalink
Support downloading two guides and merging them
Browse files Browse the repository at this point in the history
From: shuaiscott#9

Co-authored-by: Sparticuz <[email protected]>
Co-authored-by: Zach Butler <[email protected]>
  • Loading branch information
Sparticuz and kj4ezj committed Feb 27, 2024
1 parent a4a0d0e commit d089cdc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ RUN echo '@edge https://nl.alpinelinux.org/alpine/edge/main' >> /etc/apk/reposit
perl-net-http@edge \
perl-net-libidn@edge \
perl-net-ssleay@edge \
perl-uri@edge
perl-uri@edge \
xmltv@edge

VOLUME /data
ADD zap2xml.pl entry.sh /
Expand Down
18 changes: 16 additions & 2 deletions entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ download() {
while true; do
RUN_TIME="$(date '+%s')"
# shellcheck disable=SC2086
/zap2xml.pl -u "$1" -p "$2" -U -o "$3" $OPT_ARGS
/zap2xml.pl -u "$1" -p "$2" -U -o "$3" -c "$(echo "$1" | tr -d '-_@.+')" $OPT_ARGS
printf 'Run time: '
date -d "@$RUN_TIME" '+%F %T %Z'
if [ -f "$3" ]; then
Expand All @@ -28,7 +28,21 @@ download() {
}

while true; do
download "$USERNAME" "$PASSWORD" "/data/$XMLTV_FILENAME"
if [ -z "$USERNAME2" ] || [ "$USERNAME2" = 'none' ]; then
download "$USERNAME" "$PASSWORD" "/data/$XMLTV_FILENAME"
else
mkdir -p /tmp/xmltv/raws
mkdir -p /tmp/xmltv/sorted
download "$USERNAME" "$PASSWORD" "/tmp/xmltv/raws/1.xml"
download "$USERNAME2" "$PASSWORD2" "/tmp/xmltv/raws/2.xml"
echo 'Sorting both files.'
tv_sort /tmp/xmltv/raws/1.xml --by-channel --output /tmp/xmltv/sorted/1.xml
tv_sort /tmp/xmltv/raws/2.xml --by-channel --output /tmp/xmltv/sorted/2.xml
echo 'Merging both files.'
tv_merge -i /tmp/xmltv/sorted/1.xml -m /tmp/xmltv/sorted/2.xml -o "/data/$XMLTV_FILENAME"
rm -rf /tmp/xmltv
echo 'Done.'
fi
echo "Will run again in $SLEEPTIME seconds."
sleep "$SLEEPTIME"
done

0 comments on commit d089cdc

Please sign in to comment.