2024-06-20, 08:19 PM
(This post was last modified: 2024-06-20, 08:52 PM by theguymadmax. Edited 2 times in total.)
Here's a Python script that should help you out until there's a merged fix. It inserts dummy season and episode numbers into the xml file for shows that are missing it, which will allow you to record them as a series. It's not perfect but it should do the job.
1. Install Python if you don't already have it.
2. save code as tvguidefix .py
3. go to the directory and chmod +x tvguidefix.py
4. excute code ./tvguidefix.py
5. program will prompt you for location of xml file
Once you have the new file, go into your dashboard and delete (not refresh) the old xml data. Then re-import it.
1. Install Python if you don't already have it.
2. save code as tvguidefix .py
3. go to the directory and chmod +x tvguidefix.py
4. excute code ./tvguidefix.py
5. program will prompt you for location of xml file
Once you have the new file, go into your dashboard and delete (not refresh) the old xml data. Then re-import it.
Code:
#!/usr/bin/env python3
import xml.etree.ElementTree as ET
def update_episode_numbers(xml_file):
tree = ET.parse(xml_file)
root = tree.getroot()
episode_num_common = 1
episode_num_xmltv = 1
for programme in root.findall('programme'):
common_found = False
xmltv_found = False
for episode_num in programme.findall('episode-num'):
system = episode_num.get('system')
if system == 'common':
common_found = True
elif system == 'xmltv_ns':
xmltv_found = True
if not common_found:
new_common = ET.Element('episode-num')
new_common.set('system', 'common')
new_common.text = f"S01E{episode_num_common:02}"
programme.append(new_common)
episode_num_common += 1
if not xmltv_found:
new_xmltv = ET.Element('episode-num')
new_xmltv.set('system', 'xmltv_ns')
new_xmltv.text = f"01.{episode_num_xmltv:02}."
programme.append(new_xmltv)
episode_num_xmltv += 1
tree.write(xml_file, encoding='utf-8', xml_declaration=True)
if __name__ == "__main__":
xml_file = input("Enter the path to the XML file: ").strip()
update_episode_numbers(xml_file)
print(f"Updated {xml_file} successfully.")