#!/usr/bin/env python3 """ Run this from the kodi-repo directory after dropping a new addon zip in place. Example: python3 update_repo.py """ import glob import hashlib import os REPO_DIR = os.path.dirname(os.path.abspath(__file__)) def read_addon_xml(path): with open(path, encoding='utf-8') as f: content = f.read() lines = [l for l in content.splitlines() if not l.strip().startswith('\n\n' addons_xml += '\n'.join(parts) + '\n' addons_xml += '\n' return addons_xml def main(): addons_xml = build_addons_xml() with open(os.path.join(REPO_DIR, 'addons.xml'), 'w', encoding='utf-8') as f: f.write(addons_xml) md5 = hashlib.md5(addons_xml.encode('utf-8')).hexdigest() with open(os.path.join(REPO_DIR, 'addons.xml.md5'), 'w') as f: f.write(md5) print('addons.xml updated') print(f'addons.xml.md5: {md5}') print('\nNext steps:') print(' git add -A && git commit -m "Update repo" && git push') if __name__ == '__main__': main()