From 8cb336445cb82627c943175a4b0734d30dbcde07 Mon Sep 17 00:00:00 2001 From: stoney420 Date: Sat, 28 Jun 2025 00:41:11 +0200 Subject: [PATCH] Update scripts/channel_processor.py --- scripts/channel_processor.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/channel_processor.py b/scripts/channel_processor.py index c9f632e..2298893 100644 --- a/scripts/channel_processor.py +++ b/scripts/channel_processor.py @@ -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...")