I've refactored the script and popped it into github:
GitHub - brilthor/hdhomerun-xmltv: Fetch and parse HDHomerun EPG data for XMLTV consumers
Fetch and parse HDHomerun EPG data for XMLTV consumers - brilthor/hdhomerun-xmltv
github.com
gregeeh you're likely seeing the difference between guide data and what the channel sets going out OTA. If you read the code the channels aren't getting swapped around, of course you're welcome to look at the payloads yourself to confirm