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