iptv-xml-cleaner/xml_cleaner.sh
Nicolas c7c1a90800 Update xml_cleaner.sh
update file to match current docker container script
2025-10-21 15:33:14 -04:00

29 lines
1.2 KiB
Bash

#!/bin/bash
wget --no-check-certificate -O CANADA.xml -P /data/temp https://download2.iptvboss.pro/ZNLS-2213-GCPB-A8O7-QDK1-GIXS-4MOI-1NFG/xmlonly/CANADA.xml
wget --no-check-certificate -O USA.xml -P /data/temp https://download2.iptvboss.pro/R5SQ-4GRG-KK00-0XQT-JZ67-7TSA-D5O7-UC1U/xmlonly/USA.xml
ids="/data/xml_tv_ids.txt"
raw_can_xml="CANADA.xml"
raw_us_xml="USA.xml"
output="/data/clean_CANADA_USA.xml"
rm /data/clean_CANADA_USA.xml
# On cree les filtres pour trouver les channels/programmes qui nous interessent
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 '<?xml version="1.0" encoding="UTF-8"?>'
echo '<tv source-info-name="IPTVBoss">'
xmlstarlet sel -t -n -c "//channel[$id_filter]" "$raw_can_xml"
xmlstarlet sel -t -n -c "//channel[$id_filter]" "$raw_us_xml"
xmlstarlet sel -t -n -c "//programme[$prog_filter]" "$raw_can_xml"
xmlstarlet sel -t -n -c "//programme[$prog_filter]" "$raw_us_xml"
echo '</tv>'
} > "$output"
# On format le xml pour un bon indent
xmlstarlet fo -t /data/clean_CANADA_USA.xml > /data/cleanest_CANADA_USA.xml