This is one of the top search results for WMC having stopped working; thanks everyone for the useful information!Yeah, the IP changes pretty often. I've attached a .bat file that I prompted AI to spit out. It will update a tvlistings.zap2it.com entry in your hosts file with results from nslookup. It needs to be run with admin privileges. I run this via Task Scheduler a couple minutes before I run zap2xml.exe.
Use at your own risk.
I searched for an updated zap2xml.exe file but could only find instructions to compile my own exe that may or may not work correctly and/or cause me to have to redo channel mapping, so I went with this route. If anyone finds a drop-in replacement .exe file please let me know.
refresh_epg.bat
exists in the same folder as the Python script, and the former calls zap2xml.exe
, etc., and updates the TV guiderefresh_epg.bat
can be written to, for storing a temporary text filehosts
file already has an existing entry to redirect from tvlistings.zap2it.com
import subprocess
hosts_path = 'C:/Windows/System32/drivers/etc/hosts'
search_text = '\t\ttvlistings.zap2it.com'
# Look up the current IP addresses, and save them to a text file
subprocess.run(['nslookup', 'tvlistings.gracenote.com', '>', 'temp.txt'], shell=True)
with open('./temp.txt', 'r') as temp_file:
lines = temp_file.readlines()
temp_file.close()
for line in lines:
if 'Addresses: ' in line:
# Note one of the addresses
ip_address = line[len('Addresses: '):-1]
break
# Load the hosts file
with open(hosts_path, 'r') as target_file:
lines = target_file.readlines()
target_file.close()
new_text = ''
for line in lines:
if search_text in line:
# Replace the old IP address with the new one
new_text += line.replace(line[:line.find(search_text)], ip_address)
else:
new_text += line
# Now open the hosts file for writing and update it
with open(hosts_path, 'w') as target_file:
target_file.write(new_text)
target_file.close()
# Finally, proceed with downloading the fresh TV Guide information
subprocess.run(['refresh_epg.bat'], shell=True)
python update_tv-guide.py
(an example name of the above script).