fix: first channel without category
due to dynamic playlist changing, enumerate() wasn't working properly
This commit is contained in:
parent
c497d690ca
commit
121b9cce15
@ -54,10 +54,12 @@ def process(arguments):
|
|||||||
# Add category "News" to channel 5.
|
# Add category "News" to channel 5.
|
||||||
|
|
||||||
current_category = None
|
current_category = None
|
||||||
|
channels_to_remove = []
|
||||||
|
|
||||||
for index, channel in enumerate(playlist):
|
for index, channel in enumerate(playlist):
|
||||||
match = regex.match(channel.name)
|
match = regex.match(channel.name)
|
||||||
if match:
|
if match:
|
||||||
playlist.remove_channel(index)
|
channels_to_remove.append(index)
|
||||||
current_category = match.group(1)
|
current_category = match.group(1)
|
||||||
|
|
||||||
debug(f"Category matched: {current_category}")
|
debug(f"Category matched: {current_category}")
|
||||||
@ -65,6 +67,9 @@ def process(arguments):
|
|||||||
debug(f"Adding category {current_category} to channel {channel.name}")
|
debug(f"Adding category {current_category} to channel {channel.name}")
|
||||||
channel.attributes["group-title"] = current_category
|
channel.attributes["group-title"] = current_category
|
||||||
|
|
||||||
|
for index in channels_to_remove:
|
||||||
|
playlist.remove_channel(index)
|
||||||
|
|
||||||
# save playlist
|
# save playlist
|
||||||
debug("Saving playlist...")
|
debug("Saving playlist...")
|
||||||
with open(arguments.input, "w+", encoding="utf-8") as f:
|
with open(arguments.input, "w+", encoding="utf-8") as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user