iptv-xml-cleaner/xml_cleaner.sh
2025-06-10 15:57:49 -04:00

25 lines
1.1 KiB
Bash

#!/bin/bash
wget -q --no-check-certificate https://download2.iptvboss.pro/2da279ce-ce9a-4491-8b92-f72c60e92092/xmlonly/CANADA.xml > /data/CANADA.xml
wget -q --no-check-certificate https://download2.iptvboss.pro/R5SQ-4GRG-KK00-0XQT-JZ67-7TSA-D5O7-UC1U/xmlonly/USA.xml > /data/USA.xml
ids="/data/xml_tv_ids.txt"
raw_can_xml="/data/CANADA.xml"
raw_us_xml="/data/USA.xml"
dir=$(dirname "$raw_can_xml")
output="/var/www/html/clean_CANADA_US.xml"
# On crée les filtres pour trouver les channels/programmes qui nous intéressent
id_filter=$(awk '{printf "@id='\''%s'\'' or ", $0}' "$ids" | sed 's/ or $//')
prog_filter=$(awk '{printf "@channel='\''%s'\'' or ", $0}' "$ids" | sed 's/ or $//')
# On select avec xmlstarlet les channels et progs qu'on veut et on met ca dans un clean XML
{
echo '<tv source-info-name="IPTVBoss">'
xmlstarlet sel -t -c "//channel[$id_filter]" "$raw_can_xml"
xmlstarlet sel -t -c "//channel[$id_filter]" "$raw_us_xml"
xmlstarlet sel -t -c "//programme[$prog_filter]" "$raw_can_xml"
xmlstarlet sel -t -c "//programme[$prog_filter]" "$raw_us_xml"
echo '</tv>'
} > "$output"