fix: handle missing sponsorblock category names
This commit is contained in:
parent
5430f7c632
commit
062676df26
@ -28,11 +28,12 @@ async def sponsorblock_command(message):
|
|||||||
text = []
|
text = []
|
||||||
for segment in video["segments"]:
|
for segment in video["segments"]:
|
||||||
begin, end = map(int, segment["segment"])
|
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 ""
|
current = "**" if progress >= begin and progress < end else ""
|
||||||
text.append(
|
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(
|
await utils.reply(
|
||||||
|
@ -21,6 +21,7 @@ OWNERS = [531392146767347712]
|
|||||||
PREFIX = "%"
|
PREFIX = "%"
|
||||||
SPONSORBLOCK_CATEGORY_NAMES = {
|
SPONSORBLOCK_CATEGORY_NAMES = {
|
||||||
"music_offtopic": "non-music",
|
"music_offtopic": "non-music",
|
||||||
|
"selfpromo": "self promotion",
|
||||||
"sponsor": "sponsored",
|
"sponsor": "sponsored",
|
||||||
}
|
}
|
||||||
RELOADABLE_MODULES = [
|
RELOADABLE_MODULES = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user