From 121b9cce159730b6702d52d1ec5f6951c00ecf98 Mon Sep 17 00:00:00 2001 From: franek Date: Mon, 25 Mar 2024 20:30:20 +0100 Subject: [PATCH] fix: first channel without category due to dynamic playlist changing, enumerate() wasn't working properly --- __main__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/__main__.py b/__main__.py index c0078c9..a4a6015 100644 --- a/__main__.py +++ b/__main__.py @@ -54,10 +54,12 @@ def process(arguments): # Add category "News" to channel 5. current_category = None + channels_to_remove = [] + for index, channel in enumerate(playlist): match = regex.match(channel.name) if match: - playlist.remove_channel(index) + channels_to_remove.append(index) current_category = match.group(1) debug(f"Category matched: {current_category}") @@ -65,6 +67,9 @@ def process(arguments): debug(f"Adding category {current_category} to channel {channel.name}") channel.attributes["group-title"] = current_category + for index in channels_to_remove: + playlist.remove_channel(index) + # save playlist debug("Saving playlist...") with open(arguments.input, "w+", encoding="utf-8") as f: