#!/usr/bin/python3 import sys from xml.etree import ElementTree as ET data = open(sys.argv[1], 'rb').read() tree = ET.XML(data) download = open('download-icons.sh', 'w') icons = open('freeview-icons.sql', 'w') icons.write('create table freeview_icons (channum varchar(10), callsign varchar(20), icon varchar(255));') download.write('#!/bin/bash\n') for channel in tree.findall('.//channel'): download.write(f'wget {channel.find("icon").get("src")}\n') icons.write(f'insert into freeview_icons values(\'{channel.get("id")}\', \'{channel.find("display-name").text}\', \'{(channel.find("icon").get("src")).split("/")[-1]}\');\n') download.close() icons.close() #select channum,callsign,icon from channel where sourceid=1 order by channum+0; #update channel c set icon=(select icon from freeview_icons f where c.channum=f.channum) where sourceid=1 and (select count(*) from freeview_icons f where c.channum=f.channum)!=0; #select channum,callsign,icon from channel where sourceid=1 order by channum+0; #drop table freeview_icons;