Compare commits

..

No commits in common. "ca9f811e8f073c26b7a16cdea6a248c548ae2988" and "10f7ce991c9193e172d4180eaa60f625795803c6" have entirely different histories.

8 changed files with 18 additions and 71 deletions

View File

@ -22,7 +22,6 @@ class Command(Enum):
RELOAD = "reload"
RESUME = "resume"
SKIP = "skip"
SPONSORBLOCK = "sponsorblock"
STATUS = "status"
UPTIME = "uptime"
VOLUME = "volume"

View File

@ -1,20 +1,18 @@
from .channel import join, leave
from .playback import fast_forward, pause, playing, resume, volume
from .queue import queue_or_play, skip
from .sponsorblock import sponsorblock_command
from .utils import remove_queued
__all__ = [
"fast_forward",
"join",
"leave",
"pause",
"fast_forward",
"playing",
"queue_or_play",
"remove_queued",
"skip",
"resume",
"pause",
"skip",
"skip",
"sponsorblock_command",
"remove_queued",
"volume",
]

View File

@ -1,11 +1,11 @@
import arguments
import disnake_paginator
from constants import EMBED_COLOR
from state import players
import arguments
import commands
import sponsorblock
import utils
from constants import EMBED_COLOR
from state import players
from .utils import command_allowed
@ -89,15 +89,19 @@ async def pause(message):
async def fast_forward(message):
tokens = commands.tokenize(message.content)
parser = arguments.ArgumentParser(
tokens[0], "skip current sponsorblock segment"
)
parser.add_argument(
parser = arguments.ArgumentParser(tokens[0], "fast forward audio playback")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"-s",
"--seconds",
nargs="?",
type=lambda v: arguments.range_type(v, min=0, max=300),
help="the amount of seconds to fast forward instead",
help="the amount of seconds to fast forward",
)
group.add_argument(
"-S",
"--sponsorblock",
action="store_true",
help="go to the end of the current sponsorblock segment",
)
if not (args := await parser.parse_args(message, tokens)):
return
@ -110,7 +114,7 @@ async def fast_forward(message):
return
seconds = args.seconds
if not seconds:
if args.sponsorblock:
video = await sponsorblock.get_segments(
players[message.guild.id].current.player.id
)

View File

@ -1,45 +0,0 @@
import disnake
import sponsorblock
import utils
import youtubedl
from constants import EMBED_COLOR
from state import players
from .utils import command_allowed
async def sponsorblock_command(message):
if not command_allowed(message, immutable=True):
return
if not message.guild.voice_client.source:
await utils.reply(message, "nothing is playing!")
return
progress = message.guild.voice_client.source.original.progress
video = await sponsorblock.get_segments(players[message.guild.id].current.player.id)
if not video:
await utils.reply(
message, "no sponsorblock segments were found for this video!"
)
return
text = []
for segment in video["segments"]:
begin, end = map(int, segment["segment"])
category_name = sponsorblock.CATEGORY_NAMES.get(segment["category"])
current = "**" if progress >= begin and progress < end else ""
text.append(
f"{current}`{youtubedl.format_duration(begin)}` - `{youtubedl.format_duration(end)}`: {category_name if category_name else 'Unknown'}{current}"
)
await utils.reply(
message,
embed=disnake.Embed(
title="Sponsorblock segments",
description="\n".join(text),
color=EMBED_COLOR,
),
)

View File

@ -30,7 +30,6 @@ RELOADABLE_MODULES = [
"commands.voice.playback",
"commands.voice.playing",
"commands.voice.queue",
"commands.voice.sponsorblock",
"commands.voice.utils",
"constants",
"core",

View File

@ -146,8 +146,6 @@ async def on_message(message, edited=False):
await commands.bot.ping(message)
case C.LOOKUP:
await commands.tools.lookup(message)
case C.SPONSORBLOCK:
await commands.voice.sponsorblock_command(message)
except Exception as e:
await utils.reply(
message,

View File

@ -50,7 +50,6 @@ async def transcript(
pass
if (message.guild.voice_client.source.id != initial_id) or kill["transcript"]:
kill["transcript"] = False
break

View File

@ -4,11 +4,6 @@ import aiohttp
from state import sponsorblock_cache
CATEGORY_NAMES = {
"music_offtopic": "non-music",
"sponsor": "sponsored",
}
async def get_segments(videoId: str):
if videoId in sponsorblock_cache: