Added .gz option
This commit is contained in:
@@ -3,7 +3,7 @@ import gzip
|
||||
import xml.etree.ElementTree as ET
|
||||
import requests
|
||||
|
||||
save_as_gz = False # Set to True to save as .gz, False for uncompressed XML
|
||||
save_as_gz = True # Set to True to save an additional .gz version
|
||||
|
||||
tvg_ids_file = os.path.join(os.path.dirname(__file__), 'tvg-ids.txt')
|
||||
output_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'epg.xml')
|
||||
@@ -50,15 +50,14 @@ def filter_and_build_epg(urls):
|
||||
if tvg_id in valid_tvg_ids:
|
||||
root.append(programme)
|
||||
|
||||
tree = ET.ElementTree(root)
|
||||
tree.write(output_file, encoding='utf-8', xml_declaration=True)
|
||||
print(f"New EPG saved to {output_file}")
|
||||
|
||||
if save_as_gz:
|
||||
with gzip.open(output_file_gz, 'wb') as f:
|
||||
tree = ET.ElementTree(root)
|
||||
tree.write(f, encoding='utf-8', xml_declaration=True)
|
||||
print(f"New EPG saved to {output_file_gz}")
|
||||
else:
|
||||
tree = ET.ElementTree(root)
|
||||
tree.write(output_file, encoding='utf-8', xml_declaration=True)
|
||||
print(f"New EPG saved to {output_file}")
|
||||
|
||||
urls = [
|
||||
'https://epgshare01.online/epgshare01/epg_ripper_US1.xml.gz',
|
||||
|
||||
Reference in New Issue
Block a user