Compare commits
No commits in common. "8ef4c85bd8f145b391231a93cb9a26c32c819e72" and "7f07e1bd71b6cdbee7f937c7495b3c3248d8dfa3" have entirely different histories.
8ef4c85bd8
...
7f07e1bd71
@ -1,7 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import aiohttp
|
|
||||||
import disnake
|
import disnake
|
||||||
|
import requests
|
||||||
|
|
||||||
import arguments
|
import arguments
|
||||||
import commands
|
import commands
|
||||||
@ -31,9 +31,8 @@ async def lookup(message):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if args.application:
|
if args.application:
|
||||||
session = aiohttp.ClientSession()
|
response = requests.get(
|
||||||
response = await (
|
f"https://discord.com/api/v9/applications/{args.id}/rpc"
|
||||||
await session.get(f"https://discord.com/api/v9/applications/{args.id}/rpc")
|
|
||||||
).json()
|
).json()
|
||||||
if "code" in response.keys():
|
if "code" in response.keys():
|
||||||
await utils.reply(message, "application not found!")
|
await utils.reply(message, "application not found!")
|
||||||
|
@ -2,7 +2,6 @@ import disnake_paginator
|
|||||||
|
|
||||||
import arguments
|
import arguments
|
||||||
import commands
|
import commands
|
||||||
import sponsorblock
|
|
||||||
import utils
|
import utils
|
||||||
from constants import EMBED_COLOR
|
from constants import EMBED_COLOR
|
||||||
from state import players
|
from state import players
|
||||||
@ -90,19 +89,11 @@ async def pause(message):
|
|||||||
async def fast_forward(message):
|
async def fast_forward(message):
|
||||||
tokens = commands.tokenize(message.content)
|
tokens = commands.tokenize(message.content)
|
||||||
parser = arguments.ArgumentParser(tokens[0], "fast forward audio playback")
|
parser = arguments.ArgumentParser(tokens[0], "fast forward audio playback")
|
||||||
group = parser.add_mutually_exclusive_group(required=True)
|
parser.add_argument(
|
||||||
group.add_argument(
|
"seconds",
|
||||||
"-s",
|
|
||||||
"--seconds",
|
|
||||||
type=lambda v: arguments.range_type(v, min=0, max=300),
|
type=lambda v: arguments.range_type(v, min=0, max=300),
|
||||||
help="the amount of seconds to fast forward",
|
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)):
|
if not (args := await parser.parse_args(message, tokens)):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -113,28 +104,8 @@ async def fast_forward(message):
|
|||||||
await utils.reply(message, "nothing is playing!")
|
await utils.reply(message, "nothing is playing!")
|
||||||
return
|
return
|
||||||
|
|
||||||
seconds = args.seconds
|
|
||||||
if args.sponsorblock:
|
|
||||||
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
|
|
||||||
|
|
||||||
progress = message.guild.voice_client.source.original.progress
|
|
||||||
for segment in video["segments"]:
|
|
||||||
begin, end = map(float, segment["segment"])
|
|
||||||
if progress >= begin and progress < end:
|
|
||||||
seconds = end - message.guild.voice_client.source.original.progress
|
|
||||||
if not seconds:
|
|
||||||
await utils.reply(message, "no sponsorblock segment is currently playing!")
|
|
||||||
return
|
|
||||||
|
|
||||||
message.guild.voice_client.pause()
|
message.guild.voice_client.pause()
|
||||||
message.guild.voice_client.source.original.fast_forward(seconds)
|
message.guild.voice_client.source.original.fast_forward(args.seconds)
|
||||||
message.guild.voice_client.resume()
|
message.guild.voice_client.resume()
|
||||||
|
|
||||||
await utils.add_check_reaction(message)
|
await utils.add_check_reaction(message)
|
||||||
|
@ -22,7 +22,7 @@ async def queue_or_play(message, edited=False):
|
|||||||
parser = arguments.ArgumentParser(
|
parser = arguments.ArgumentParser(
|
||||||
tokens[0], "queue a song, list the queue, or resume playback"
|
tokens[0], "queue a song, list the queue, or resume playback"
|
||||||
)
|
)
|
||||||
parser.add_argument("query", nargs="*", help="yt-dlp URL or query to get song")
|
parser.add_argument("query", nargs="?", help="yt-dlp URL or query to get song")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-v",
|
"-v",
|
||||||
"--volume",
|
"--volume",
|
||||||
@ -155,7 +155,7 @@ async def queue_or_play(message, edited=False):
|
|||||||
try:
|
try:
|
||||||
async with message.channel.typing():
|
async with message.channel.typing():
|
||||||
player = await youtubedl.YTDLSource.from_url(
|
player = await youtubedl.YTDLSource.from_url(
|
||||||
" ".join(query), loop=client.loop, stream=True
|
query, loop=client.loop, stream=True
|
||||||
)
|
)
|
||||||
player.volume = float(args.volume) / 100.0
|
player.volume = float(args.volume) / 100.0
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -36,13 +36,10 @@ RELOADABLE_MODULES = [
|
|||||||
"events",
|
"events",
|
||||||
"extra",
|
"extra",
|
||||||
"fun",
|
"fun",
|
||||||
"sponsorblock",
|
|
||||||
"tasks",
|
"tasks",
|
||||||
"utils",
|
"utils",
|
||||||
"voice",
|
"voice",
|
||||||
"youtubedl",
|
"youtubedl",
|
||||||
"yt_dlp",
|
|
||||||
"yt_dlp.version",
|
|
||||||
]
|
]
|
||||||
PUBLIC_FLAGS = {
|
PUBLIC_FLAGS = {
|
||||||
1: "Discord Employee",
|
1: "Discord Employee",
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
import hashlib
|
|
||||||
|
|
||||||
import aiohttp
|
|
||||||
|
|
||||||
from state import sponsorblock_cache
|
|
||||||
|
|
||||||
|
|
||||||
async def get_segments(videoId: str):
|
|
||||||
if videoId in sponsorblock_cache:
|
|
||||||
return sponsorblock_cache[videoId]
|
|
||||||
|
|
||||||
hashPrefix = hashlib.sha256(videoId.encode()).hexdigest()[:4]
|
|
||||||
session = aiohttp.ClientSession()
|
|
||||||
response = await session.get(
|
|
||||||
f'https://sponsor.ajay.app/api/skipSegments/{hashPrefix}?categories=["music_offtopic"]'
|
|
||||||
)
|
|
||||||
if response.status == 200 and (
|
|
||||||
results := list(
|
|
||||||
filter(lambda v: videoId == v["videoID"], await response.json())
|
|
||||||
)
|
|
||||||
):
|
|
||||||
sponsorblock_cache[videoId] = results[0]
|
|
||||||
return results[0]
|
|
1
state.py
1
state.py
@ -15,5 +15,4 @@ idle_tracker = {"is_idle": False, "last_used": time.time()}
|
|||||||
kill = {"transcript": False}
|
kill = {"transcript": False}
|
||||||
message_responses = LimitedSizeDict()
|
message_responses = LimitedSizeDict()
|
||||||
players = {}
|
players = {}
|
||||||
sponsorblock_cache = LimitedSizeDict(size_limit=100)
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user