refactor(sponsorblock): clean up categories
This commit is contained in:
parent
0b3425a658
commit
d08744ebb2
@ -3,7 +3,7 @@ import disnake
|
||||
import audio
|
||||
import sponsorblock
|
||||
import utils
|
||||
from constants import EMBED_COLOR
|
||||
from constants import EMBED_COLOR, SPONSORBLOCK_CATEGORY_NAMES
|
||||
from state import players
|
||||
|
||||
from .utils import command_allowed
|
||||
@ -28,7 +28,7 @@ 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"])
|
||||
category_name = SPONSORBLOCK_CATEGORY_NAMES.get(segment["category"])
|
||||
|
||||
current = "**" if progress >= begin and progress < end else ""
|
||||
text.append(
|
||||
|
@ -19,6 +19,10 @@ BAR_LENGTH = 35
|
||||
EMBED_COLOR = 0xFF6600
|
||||
OWNERS = [531392146767347712]
|
||||
PREFIX = "%"
|
||||
SPONSORBLOCK_CATEGORY_NAMES = {
|
||||
"music_offtopic": "non-music",
|
||||
"sponsor": "sponsored",
|
||||
}
|
||||
RELOADABLE_MODULES = [
|
||||
"arguments",
|
||||
"audio",
|
||||
|
@ -1,13 +1,21 @@
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
import aiohttp
|
||||
|
||||
from state import sponsorblock_cache
|
||||
|
||||
CATEGORY_NAMES = {
|
||||
"music_offtopic": "non-music",
|
||||
"sponsor": "sponsored",
|
||||
}
|
||||
categories = json.dumps(
|
||||
[
|
||||
"interaction",
|
||||
"intro",
|
||||
"music_offtopic",
|
||||
"outro",
|
||||
"preview",
|
||||
"selfpromo",
|
||||
"sponsor",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
async def get_segments(video_id: str):
|
||||
@ -18,7 +26,7 @@ async def get_segments(video_id: str):
|
||||
session = aiohttp.ClientSession()
|
||||
response = await session.get(
|
||||
f"https://sponsor.ajay.app/api/skipSegments/{hashPrefix}",
|
||||
params={"categories": '["sponsor", "music_offtopic"]'},
|
||||
params={"categories": categories},
|
||||
)
|
||||
if response.status == 200 and (
|
||||
results := list(
|
||||
|
Loading…
x
Reference in New Issue
Block a user