mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Use YouTube source plugin over the deprecated built-in source (#6373)
Co-authored-by: aikaterna <20862007+aikaterna@users.noreply.github.com>
This commit is contained in:
parent
57b76bc0d7
commit
dd61b669b0
@ -1150,6 +1150,20 @@ class AudioSetCommands(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
if is_owner:
|
if is_owner:
|
||||||
msg += _("Localtracks path: [{localpath}]\n").format(**global_data)
|
msg += _("Localtracks path: [{localpath}]\n").format(**global_data)
|
||||||
|
|
||||||
|
if (
|
||||||
|
is_owner
|
||||||
|
and not global_data["use_external_lavalink"]
|
||||||
|
and self.managed_node_controller.plugins
|
||||||
|
):
|
||||||
|
plugins = self.managed_node_controller.plugins
|
||||||
|
msg += f"\n---{_('Lavalink Plugin Versions')}---"
|
||||||
|
plugin_name_max_len = 0
|
||||||
|
for plugin_name, __ in plugins.items():
|
||||||
|
plugin_name_max_len = max(plugin_name_max_len, len(plugin_name))
|
||||||
|
for plugin_name, plugin_version in plugins.items():
|
||||||
|
key = f"{plugin_name}:".ljust(plugin_name_max_len + 5)
|
||||||
|
msg += f"\n{key} [{plugin_version}]"
|
||||||
|
|
||||||
await self.send_embed_msg(ctx, description=box(msg, lang="ini"))
|
await self.send_embed_msg(ctx, description=box(msg, lang="ini"))
|
||||||
|
|
||||||
@command_audioset.command(name="logs")
|
@command_audioset.command(name="logs")
|
||||||
|
|||||||
@ -49,7 +49,11 @@ if TYPE_CHECKING:
|
|||||||
_ = Translator("Audio", pathlib.Path(__file__))
|
_ = Translator("Audio", pathlib.Path(__file__))
|
||||||
log = getLogger("red.Audio.manager")
|
log = getLogger("red.Audio.manager")
|
||||||
|
|
||||||
_FAILED_TO_START: Final[Pattern] = re.compile(rb"Web server failed to start\. (.*)")
|
_LL_READY_LOG: Final[bytes] = b"Lavalink is ready to accept connections."
|
||||||
|
_LL_PLUGIN_LOG: Final[Pattern[bytes]] = re.compile(
|
||||||
|
rb"Found plugin '(?P<name>.+)' version (?P<version>\S+)$", re.MULTILINE
|
||||||
|
)
|
||||||
|
_FAILED_TO_START: Final[Pattern[bytes]] = re.compile(rb"Web server failed to start\. (.*)")
|
||||||
|
|
||||||
# Version regexes
|
# Version regexes
|
||||||
#
|
#
|
||||||
@ -295,11 +299,14 @@ class LavalinkVersion:
|
|||||||
|
|
||||||
class ServerManager:
|
class ServerManager:
|
||||||
JAR_VERSION: Final[str] = LavalinkVersion(3, 7, 11, red=3)
|
JAR_VERSION: Final[str] = LavalinkVersion(3, 7, 11, red=3)
|
||||||
|
YT_PLUGIN_VERSION: Final[str] = "1.4.0"
|
||||||
|
|
||||||
LAVALINK_DOWNLOAD_URL: Final[str] = (
|
LAVALINK_DOWNLOAD_URL: Final[str] = (
|
||||||
"https://github.com/Cog-Creators/Lavalink-Jars/releases/download/"
|
"https://github.com/Cog-Creators/Lavalink-Jars/releases/download/"
|
||||||
f"{JAR_VERSION}/"
|
f"{JAR_VERSION}/"
|
||||||
"Lavalink.jar"
|
"Lavalink.jar"
|
||||||
)
|
)
|
||||||
|
YT_PLUGIN_REPOSITORY: Final[str] = "https://maven.lavalink.dev/releases"
|
||||||
|
|
||||||
_java_available: ClassVar[Optional[bool]] = None
|
_java_available: ClassVar[Optional[bool]] = None
|
||||||
_java_version: ClassVar[Optional[Tuple[int, int]]] = None
|
_java_version: ClassVar[Optional[Tuple[int, int]]] = None
|
||||||
@ -323,6 +330,7 @@ class ServerManager:
|
|||||||
self.cog = cog
|
self.cog = cog
|
||||||
self._args = []
|
self._args = []
|
||||||
self._pipe_task = None
|
self._pipe_task = None
|
||||||
|
self.plugins: dict[str, str] = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lavalink_download_dir(self) -> pathlib.Path:
|
def lavalink_download_dir(self) -> pathlib.Path:
|
||||||
@ -422,7 +430,20 @@ class ServerManager:
|
|||||||
|
|
||||||
async def process_settings(self):
|
async def process_settings(self):
|
||||||
data = change_dict_naming_convention(await self._config.yaml.all())
|
data = change_dict_naming_convention(await self._config.yaml.all())
|
||||||
with open(self.lavalink_app_yml, "w") as f:
|
ll_config = data["lavalink"]
|
||||||
|
sources = ll_config["server"]["sources"]
|
||||||
|
plugins = ll_config.setdefault("plugins", [])
|
||||||
|
|
||||||
|
enable_yt_plugin = sources["youtube"]
|
||||||
|
if enable_yt_plugin:
|
||||||
|
sources["youtube"] = False
|
||||||
|
yt_plugin = {
|
||||||
|
"dependency": f"dev.lavalink.youtube:youtube-plugin:{self.YT_PLUGIN_VERSION}",
|
||||||
|
"repository": self.YT_PLUGIN_REPOSITORY,
|
||||||
|
}
|
||||||
|
plugins.append(yt_plugin)
|
||||||
|
|
||||||
|
with open(self.lavalink_app_yml, "w", encoding="utf-8") as f:
|
||||||
yaml.safe_dump(data, f)
|
yaml.safe_dump(data, f)
|
||||||
|
|
||||||
async def _get_jar_args(self) -> Tuple[List[str], Optional[str]]:
|
async def _get_jar_args(self) -> Tuple[List[str], Optional[str]]:
|
||||||
@ -518,12 +539,14 @@ class ServerManager:
|
|||||||
log.info("Waiting for Managed Lavalink node to be ready")
|
log.info("Waiting for Managed Lavalink node to be ready")
|
||||||
for i in itertools.cycle(range(50)):
|
for i in itertools.cycle(range(50)):
|
||||||
line = await self._proc.stdout.readline()
|
line = await self._proc.stdout.readline()
|
||||||
if b"Lavalink is ready to accept connections." in line:
|
if _LL_READY_LOG in line:
|
||||||
self.ready.set()
|
self.ready.set()
|
||||||
log.info("Managed Lavalink node is ready to receive requests.")
|
log.info("Managed Lavalink node is ready to receive requests.")
|
||||||
self._pipe_task = asyncio.create_task(self._pipe_output())
|
self._pipe_task = asyncio.create_task(self._pipe_output())
|
||||||
break
|
break
|
||||||
if _FAILED_TO_START.search(line):
|
if match := _LL_PLUGIN_LOG.search(line):
|
||||||
|
self.plugins[match["name"].decode()] = match["version"].decode()
|
||||||
|
elif _FAILED_TO_START.search(line):
|
||||||
raise ManagedLavalinkStartFailure(
|
raise ManagedLavalinkStartFailure(
|
||||||
f"Lavalink failed to start: {line.decode().strip()}"
|
f"Lavalink failed to start: {line.decode().strip()}"
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user