mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Merge pull request #4007 from Drapersniper/wavelink
[Audio RW] Add WL dep and WL overides
This commit is contained in:
commit
5417d871c6
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -1,4 +1,5 @@
|
|||||||
# Core
|
# Core
|
||||||
|
redbot/core/apis/audio/** @aikaterna @Drapersniper
|
||||||
redbot/core/bank.py @palmtree5
|
redbot/core/bank.py @palmtree5
|
||||||
redbot/core/checks.py @tekulvw
|
redbot/core/checks.py @tekulvw
|
||||||
redbot/core/cli.py @tekulvw
|
redbot/core/cli.py @tekulvw
|
||||||
|
|||||||
0
redbot/core/apis/__init__.py
Normal file
0
redbot/core/apis/__init__.py
Normal file
2
redbot/core/apis/audio/__init__.py
Normal file
2
redbot/core/apis/audio/__init__.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
from . import regex as regex
|
||||||
|
from . import wavelink as wavelink
|
||||||
74
redbot/core/apis/audio/regex.py
Normal file
74
redbot/core/apis/audio/regex.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
from typing import Final, Pattern
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"YOUTUBE_ID",
|
||||||
|
"YOUTUBE_TIMESTAMP",
|
||||||
|
"YOUTUBE_LIST_PLAYLIST",
|
||||||
|
"YOUTUBE_INDEX",
|
||||||
|
"SPOTIFY_TIMESTAMP",
|
||||||
|
"SPOTIFY_URL",
|
||||||
|
"SOUNDCLOUD_TIMESTAMP",
|
||||||
|
"TWITCH_TIMESTAMP",
|
||||||
|
"ICYCAST_STREAM_TITLE",
|
||||||
|
"REMOVE_START",
|
||||||
|
"SQUARE",
|
||||||
|
"MENTION",
|
||||||
|
"FAILED_CONVERSION",
|
||||||
|
"TIME_CONVERTER",
|
||||||
|
"LAVALINK_READY_LINE",
|
||||||
|
"LAVALINK_FAILED_TO_START",
|
||||||
|
"LAVALINK_BUILD_LINE",
|
||||||
|
"LAVALINK_LAVAPLAYER_LINE",
|
||||||
|
"LAVALINK_JAVA_LINE",
|
||||||
|
"LAVALINK_BRANCH_LINE",
|
||||||
|
"LAVALINK_BUILD_TIME_LINE",
|
||||||
|
"JAVA_VERSION_LINE",
|
||||||
|
"JAVA_SHORT_VERSION",
|
||||||
|
"CURLY_BRACKETS",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
YOUTUBE_ID: Final[Pattern] = re.compile(r"^[a-zA-Z0-9_-]{11}$")
|
||||||
|
YOUTUBE_TIMESTAMP: Final[Pattern] = re.compile(r"[&|?]t=(\d+)s?")
|
||||||
|
YOUTUBE_LIST_PLAYLIST: Final[Pattern] = re.compile(
|
||||||
|
r"^(https?://)?(www\.)?(youtube\.com|youtu\.?be)(/playlist\?).*(list=)(.*)(&|$)"
|
||||||
|
)
|
||||||
|
YOUTUBE_INDEX: Final[Pattern] = re.compile(r"&index=(\d+)")
|
||||||
|
|
||||||
|
SPOTIFY_TIMESTAMP: Final[Pattern] = re.compile(r"#(\d+):(\d+)")
|
||||||
|
SPOTIFY_URL: Final[Pattern] = re.compile(r"(http[s]?://)?(open.spotify.com)/")
|
||||||
|
|
||||||
|
SOUNDCLOUD_TIMESTAMP: Final[Pattern] = re.compile(r"#t=(\d+):(\d+)s?")
|
||||||
|
|
||||||
|
TWITCH_TIMESTAMP: Final[Pattern] = re.compile(r"\?t=(\d+)h(\d+)m(\d+)s")
|
||||||
|
|
||||||
|
ICYCAST_STREAM_TITLE: Final[Pattern] = re.compile(br"StreamTitle='([^']*)';")
|
||||||
|
|
||||||
|
|
||||||
|
REMOVE_START: Final[Pattern] = re.compile(r"^(sc|list) ")
|
||||||
|
|
||||||
|
SQUARE = re.compile(r"[\[\]]")
|
||||||
|
MENTION: Final[Pattern] = re.compile(r"^<?(?:(?:@[!&]?)?|#)(\d{15,21})>?$")
|
||||||
|
|
||||||
|
FAILED_CONVERSION: Final[Pattern] = re.compile('Converting to "(.*)" failed for parameter "(.*)".')
|
||||||
|
TIME_CONVERTER: Final[Pattern] = re.compile(r"(?:(\d+):)?([0-5]?[0-9]):([0-5][0-9])")
|
||||||
|
|
||||||
|
LAVALINK_READY_LINE: Final[Pattern] = re.compile(rb"Started Launcher in \S+ seconds")
|
||||||
|
LAVALINK_FAILED_TO_START: Final[Pattern] = re.compile(rb"Web server failed to start. (.*)")
|
||||||
|
LAVALINK_BUILD_LINE: Final[Pattern] = re.compile(rb"Build time:\s+(?P<build_time>\d+[.\d+]*)")
|
||||||
|
LAVALINK_LAVAPLAYER_LINE: Final[Pattern] = re.compile(rb"Lavaplayer\s+(?P<lavaplayer>\d+[.\d+]*)")
|
||||||
|
LAVALINK_JAVA_LINE: Final[Pattern] = re.compile(rb"JVM:\s+(?P<jvm>\d+[.\d+]*)")
|
||||||
|
LAVALINK_BRANCH_LINE: Final[Pattern] = re.compile(rb"Branch\s+(?P<branch>[\w\-\d_.]+)")
|
||||||
|
LAVALINK_BUILD_TIME_LINE: Final[Pattern] = re.compile(rb"Build time:\s+(?P<build_time>\d+[.\d+]*)")
|
||||||
|
|
||||||
|
|
||||||
|
JAVA_VERSION_LINE: Final[Pattern] = re.compile(
|
||||||
|
r'version "(?P<major>\d+).(?P<minor>\d+).\d+(?:_\d+)?(?:-[A-Za-z0-9]+)?"'
|
||||||
|
)
|
||||||
|
JAVA_SHORT_VERSION: Final[Pattern] = re.compile(r'version "(?P<major>\d+)"')
|
||||||
|
|
||||||
|
CURLY_BRACKETS: Final[Pattern] = re.compile(r"[{}]")
|
||||||
3
redbot/core/apis/audio/wavelink/__init__.py
Normal file
3
redbot/core/apis/audio/wavelink/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from . import constants as constants
|
||||||
|
from . import events as events
|
||||||
|
from . import overwrites as overwrites
|
||||||
14
redbot/core/apis/audio/wavelink/constants.py
Normal file
14
redbot/core/apis/audio/wavelink/constants.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import typing
|
||||||
|
|
||||||
|
__all__ = ["REGION_AGGREGATION"]
|
||||||
|
|
||||||
|
REGION_AGGREGATION: typing.Dict[str, str] = {
|
||||||
|
"dubai": "singapore",
|
||||||
|
"amsterdam": "europe",
|
||||||
|
"london": "europe",
|
||||||
|
"frankfurt": "europe",
|
||||||
|
"eu-central": "europe",
|
||||||
|
"eu-west": "europe",
|
||||||
|
}
|
||||||
27
redbot/core/apis/audio/wavelink/events.py
Normal file
27
redbot/core/apis/audio/wavelink/events.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import typing
|
||||||
|
|
||||||
|
if typing.TYPE_CHECKING:
|
||||||
|
from .overwrites import RedPlayer, RedTrack
|
||||||
|
|
||||||
|
|
||||||
|
class QueueEnd:
|
||||||
|
"""Event dispatched on QueueEnd.
|
||||||
|
|
||||||
|
Attributes
|
||||||
|
------------
|
||||||
|
player: :class:`RedPlayer`
|
||||||
|
The player associated with the event.
|
||||||
|
track: :class:`RedTrack`
|
||||||
|
The track associated with the event.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__slots__ = ("track", "player")
|
||||||
|
|
||||||
|
def __init__(self, data: dict):
|
||||||
|
self.track = data.get("track")
|
||||||
|
self.player = data.get("player")
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "QueueEnd"
|
||||||
1481
redbot/core/apis/audio/wavelink/overwrites.py
Normal file
1481
redbot/core/apis/audio/wavelink/overwrites.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -33,6 +33,7 @@ from discord.ext.commands import when_mentioned_or
|
|||||||
from discord.ext.commands.bot import BotBase
|
from discord.ext.commands.bot import BotBase
|
||||||
|
|
||||||
from . import Config, i18n, commands, errors, drivers, modlog, bank
|
from . import Config, i18n, commands, errors, drivers, modlog, bank
|
||||||
|
from .apis.audio.wavelink.overwrites import RedClient
|
||||||
from .cog_manager import CogManager, CogManagerUI
|
from .cog_manager import CogManager, CogManagerUI
|
||||||
from .core_commands import license_info_command, Core
|
from .core_commands import license_info_command, Core
|
||||||
from .data_manager import cog_data_path
|
from .data_manager import cog_data_path
|
||||||
@ -191,6 +192,7 @@ class RedBase(
|
|||||||
self._permissions_hooks: List[commands.CheckPredicate] = []
|
self._permissions_hooks: List[commands.CheckPredicate] = []
|
||||||
self._red_ready = asyncio.Event()
|
self._red_ready = asyncio.Event()
|
||||||
self._red_before_invoke_objs: Set[PreInvokeCoroutine] = set()
|
self._red_before_invoke_objs: Set[PreInvokeCoroutine] = set()
|
||||||
|
self.wavelink = RedClient(bot=self)
|
||||||
|
|
||||||
def get_command(self, name: str) -> Optional[commands.Command]:
|
def get_command(self, name: str) -> Optional[commands.Command]:
|
||||||
com = super().get_command(name)
|
com = super().get_command(name)
|
||||||
|
|||||||
@ -49,6 +49,7 @@ install_requires =
|
|||||||
schema==0.7.1
|
schema==0.7.1
|
||||||
tqdm==4.45.0
|
tqdm==4.45.0
|
||||||
uvloop==0.14.0; sys_platform != "win32" and platform_python_implementation == "CPython"
|
uvloop==0.14.0; sys_platform != "win32" and platform_python_implementation == "CPython"
|
||||||
|
Wavelink==0.9.2
|
||||||
websockets==8.1
|
websockets==8.1
|
||||||
yarl==1.4.2
|
yarl==1.4.2
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ install_requires =
|
|||||||
schema
|
schema
|
||||||
tqdm
|
tqdm
|
||||||
uvloop; sys_platform != "win32" and platform_python_implementation == "CPython"
|
uvloop; sys_platform != "win32" and platform_python_implementation == "CPython"
|
||||||
|
Wavelink
|
||||||
# Websockets is a secondary dependency, but until pip has a complete dependency resolver, we
|
# Websockets is a secondary dependency, but until pip has a complete dependency resolver, we
|
||||||
# need to list it here to avoid an incompatible version being installed.
|
# need to list it here to avoid an incompatible version being installed.
|
||||||
# See under point 2 here: https://pip.pypa.io/en/stable/user_guide/#requirements-files
|
# See under point 2 here: https://pip.pypa.io/en/stable/user_guide/#requirements-files
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user