fix: handle missing sponsorblock category names

This commit is contained in:
2025-02-26 16:21:29 -05:00
parent 5430f7c632
commit 062676df26
2 changed files with 4 additions and 2 deletions

View File

@@ -28,11 +28,12 @@ async def sponsorblock_command(message):
text = []
for segment in video["segments"]:
begin, end = map(int, segment["segment"])
category_name = SPONSORBLOCK_CATEGORY_NAMES.get(segment["category"])
if (category := segment["category"]) in SPONSORBLOCK_CATEGORY_NAMES:
category = SPONSORBLOCK_CATEGORY_NAMES[category]
current = "**" if progress >= begin and progress < end else ""
text.append(
f"{current}`{audio.utils.format_duration(begin)}` - `{audio.utils.format_duration(end)}`: {category_name if category_name else 'Unknown'}{current}"
f"{current}`{audio.utils.format_duration(begin)}` - `{audio.utils.format_duration(end)}`: {category}{current}"
)
await utils.reply(