Update scripts/channel_processor.py
Some checks failed
Generate M3U Playlist / build (push) Has been cancelled

This commit is contained in:
stoney420 2025-06-28 00:41:11 +02:00
parent 86e900e1b2
commit 8cb336445c

View file

@ -368,6 +368,24 @@ class ChannelProcessor:
os.remove(self.config.import_file)
self.logger.info("Cleaned up import file")
# Cleanup import file - CLEAR contents instead of deleting the file
if self.config.settings.get('clear_import_after_processing', True):
try:
# Clear the file contents by writing just the M3U header
with open(self.config.import_file, 'w', encoding='utf-8') as f:
f.write('#EXTM3U\n') # Keep M3U header but remove all channels
self.logger.info(f"✅ Cleared contents of {self.config.import_file} (file preserved for future imports)")
except Exception as e:
self.logger.warning(f"Could not clear import file contents: {e}")
elif self.config.settings.get('delete_import_file', False):
try:
os.remove(self.config.import_file)
self.logger.info(f"Deleted import file: {self.config.import_file}")
except Exception as e:
self.logger.warning(f"Could not delete import file: {e}")
else:
self.logger.info(f"Import file left unchanged: {self.config.import_file}")
# CRITICAL: Save the imported channels to channels.txt
if imported_channels:
self.logger.info(f"Saving {len(imported_channels)} imported channels to file...")