Compare commits
No commits in common. "8ef4c85bd8f145b391231a93cb9a26c32c819e72" and "7f07e1bd71b6cdbee7f937c7495b3c3248d8dfa3" have entirely different histories.
8ef4c85bd8
...
7f07e1bd71
@ -1,7 +1,7 @@
|
||||
import re
|
||||
|
||||
import aiohttp
|
||||
import disnake
|
||||
import requests
|
||||
|
||||
import arguments
|
||||
import commands
|
||||
@ -31,9 +31,8 @@ async def lookup(message):
|
||||
return
|
||||
|
||||
if args.application:
|
||||
session = aiohttp.ClientSession()
|
||||
response = await (
|
||||
await session.get(f"https://discord.com/api/v9/applications/{args.id}/rpc")
|
||||
response = requests.get(
|
||||
f"https://discord.com/api/v9/applications/{args.id}/rpc"
|
||||
).json()
|
||||
if "code" in response.keys():
|
||||
await utils.reply(message, "application not found!")
|
||||
|
@ -2,7 +2,6 @@ import disnake_paginator
|
||||
|
||||
import arguments
|
||||
import commands
|
||||
import sponsorblock
|
||||
import utils
|
||||
from constants import EMBED_COLOR
|
||||
from state import players
|
||||
@ -90,19 +89,11 @@ async def pause(message):
|
||||
async def fast_forward(message):
|
||||
tokens = commands.tokenize(message.content)
|
||||
parser = arguments.ArgumentParser(tokens[0], "fast forward audio playback")
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument(
|
||||
"-s",
|
||||
"--seconds",
|
||||
parser.add_argument(
|
||||
"seconds",
|
||||
type=lambda v: arguments.range_type(v, min=0, max=300),
|
||||
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
|
||||
|
||||
@ -113,28 +104,8 @@ async def fast_forward(message):
|
||||
await utils.reply(message, "nothing is playing!")
|
||||
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.source.original.fast_forward(seconds)
|
||||
message.guild.voice_client.source.original.fast_forward(args.seconds)
|
||||
message.guild.voice_client.resume()
|
||||
|
||||
await utils.add_check_reaction(message)
|
||||
|
@ -22,7 +22,7 @@ async def queue_or_play(message, edited=False):
|
||||
parser = arguments.ArgumentParser(
|
||||
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(
|
||||
"-v",
|
||||
"--volume",
|
||||
@ -155,7 +155,7 @@ async def queue_or_play(message, edited=False):
|
||||
try:
|
||||
async with message.channel.typing():
|
||||
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
|
||||
except Exception as e:
|
||||
|
@ -36,13 +36,10 @@ RELOADABLE_MODULES = [
|
||||
"events",
|
||||
"extra",
|
||||
"fun",
|
||||
"sponsorblock",
|
||||
"tasks",
|
||||
"utils",
|
||||
"voice",
|
||||
"youtubedl",
|
||||
"yt_dlp",
|
||||
"yt_dlp.version",
|
||||
]
|
||||
PUBLIC_FLAGS = {
|
||||
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]
|
Loading…
x
Reference in New Issue
Block a user