mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Try to debug something, but without success
This commit is contained in:
parent
aa48c3d1e2
commit
538a850344
3 changed files with 15 additions and 6 deletions
|
@ -12,9 +12,7 @@ loop = asyncio.get_event_loop()
|
|||
|
||||
log = logging.root
|
||||
log.addHandler(logging.StreamHandler())
|
||||
logging.getLogger("royalnet.bots.telegram").setLevel(logging.DEBUG)
|
||||
logging.getLogger("royalnet.bots.discord").setLevel(logging.DEBUG)
|
||||
logging.getLogger("royalnet.network.royalnetserver").setLevel(logging.DEBUG)
|
||||
|
||||
commands = [PingCommand, ShipCommand, SmecdsCommand, ColorCommand, CiaoruoziCommand, DebugCreateCommand, SyncCommand,
|
||||
AuthorCommand, DiarioCommand, RageCommand, DateparserCommand, ReminderCommand, KvactiveCommand, KvCommand,
|
||||
|
|
|
@ -19,15 +19,19 @@ class RoyalAudioFile(YtdlFile):
|
|||
def __init__(self, info: "YtdlInfo", **ytdl_args):
|
||||
# Overwrite the new ytdl_args
|
||||
self.ytdl_args = {**self.ytdl_args, **ytdl_args}
|
||||
log.info(f"Now downloading {info.webpage_url}")
|
||||
super().__init__(info, outtmpl="./opusfiles/%(title)s-%(id)s.%(ext)s", **self.ytdl_args)
|
||||
# Find the audio_filename with a regex (should be video.opus)
|
||||
log.info(f"Starting conversion of {self.video_filename}")
|
||||
self.audio_filename = re.sub(rf"\.{self.info.ext}$", ".opus", self.video_filename)
|
||||
# Convert the video to opus
|
||||
# Actually not needed, but we do this anyways for compression reasons
|
||||
converter = ffmpeg.input(self.video_filename) \
|
||||
.output(self.audio_filename)
|
||||
converter.run()
|
||||
converter.run(quiet=True)
|
||||
log.info(f"Converted to {self.audio_filename}")
|
||||
# Delete the video file
|
||||
log.info(f"Deleting {self.video_filename}")
|
||||
self.delete_video_file()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -3,6 +3,7 @@ import asyncio
|
|||
import typing
|
||||
import logging as _logging
|
||||
import sys
|
||||
import functools
|
||||
from ..commands import NullCommand
|
||||
from ..utils import asyncify, Call, Command
|
||||
from ..error import UnregisteredError, NoneFoundError, TooManyFoundError
|
||||
|
@ -235,12 +236,18 @@ class DiscordBot:
|
|||
await self.advance_music_data(guild)
|
||||
|
||||
async def advance_music_data(self, guild: discord.Guild):
|
||||
"""Try to play the next song, while it exists. Otherwise, just return."""
|
||||
guild_music_data = self.music_data[guild]
|
||||
next_file = await guild_music_data.next()
|
||||
voice_client = self.find_voice_client(guild)
|
||||
next_file: RoyalAudioFile = await guild_music_data.next()
|
||||
if next_file is None:
|
||||
return
|
||||
voice_client = self.find_voice_client(guild)
|
||||
voice_client.play(next_file.as_audio_source(), after=lambda: loop.create_task(self.advance_music_data(guild)))
|
||||
|
||||
def advance(error=None):
|
||||
loop.create_task(self.advance_music_data(guild))
|
||||
|
||||
log.info(f"Starting to play {next_file.audio_filename}")
|
||||
voice_client.play(next_file.as_audio_source(), after=advance)
|
||||
|
||||
async def nh_play(self, message: PlayMessage):
|
||||
"""Handle a play Royalnet request. That is, add audio to a PlayMode."""
|
||||
|
|
Loading…
Reference in a new issue