mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +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 = logging.root
|
||||||
log.addHandler(logging.StreamHandler())
|
log.addHandler(logging.StreamHandler())
|
||||||
logging.getLogger("royalnet.bots.telegram").setLevel(logging.DEBUG)
|
|
||||||
logging.getLogger("royalnet.bots.discord").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,
|
commands = [PingCommand, ShipCommand, SmecdsCommand, ColorCommand, CiaoruoziCommand, DebugCreateCommand, SyncCommand,
|
||||||
AuthorCommand, DiarioCommand, RageCommand, DateparserCommand, ReminderCommand, KvactiveCommand, KvCommand,
|
AuthorCommand, DiarioCommand, RageCommand, DateparserCommand, ReminderCommand, KvactiveCommand, KvCommand,
|
||||||
|
|
|
@ -19,15 +19,19 @@ class RoyalAudioFile(YtdlFile):
|
||||||
def __init__(self, info: "YtdlInfo", **ytdl_args):
|
def __init__(self, info: "YtdlInfo", **ytdl_args):
|
||||||
# Overwrite the new ytdl_args
|
# Overwrite the new ytdl_args
|
||||||
self.ytdl_args = {**self.ytdl_args, **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)
|
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)
|
# 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)
|
self.audio_filename = re.sub(rf"\.{self.info.ext}$", ".opus", self.video_filename)
|
||||||
# Convert the video to opus
|
# Convert the video to opus
|
||||||
# Actually not needed, but we do this anyways for compression reasons
|
# Actually not needed, but we do this anyways for compression reasons
|
||||||
converter = ffmpeg.input(self.video_filename) \
|
converter = ffmpeg.input(self.video_filename) \
|
||||||
.output(self.audio_filename)
|
.output(self.audio_filename)
|
||||||
converter.run()
|
converter.run(quiet=True)
|
||||||
|
log.info(f"Converted to {self.audio_filename}")
|
||||||
# Delete the video file
|
# Delete the video file
|
||||||
|
log.info(f"Deleting {self.video_filename}")
|
||||||
self.delete_video_file()
|
self.delete_video_file()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -3,6 +3,7 @@ import asyncio
|
||||||
import typing
|
import typing
|
||||||
import logging as _logging
|
import logging as _logging
|
||||||
import sys
|
import sys
|
||||||
|
import functools
|
||||||
from ..commands import NullCommand
|
from ..commands import NullCommand
|
||||||
from ..utils import asyncify, Call, Command
|
from ..utils import asyncify, Call, Command
|
||||||
from ..error import UnregisteredError, NoneFoundError, TooManyFoundError
|
from ..error import UnregisteredError, NoneFoundError, TooManyFoundError
|
||||||
|
@ -235,12 +236,18 @@ class DiscordBot:
|
||||||
await self.advance_music_data(guild)
|
await self.advance_music_data(guild)
|
||||||
|
|
||||||
async def advance_music_data(self, guild: discord.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]
|
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:
|
if next_file is None:
|
||||||
return
|
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):
|
async def nh_play(self, message: PlayMessage):
|
||||||
"""Handle a play Royalnet request. That is, add audio to a PlayMode."""
|
"""Handle a play Royalnet request. That is, add audio to a PlayMode."""
|
||||||
|
|
Loading…
Reference in a new issue