[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
0bdca1975c
commit
5c5d68d1f2
|
|
@ -18,7 +18,8 @@ from urllib.parse import quote
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import orjson as json
|
import orjson as json
|
||||||
from discord import Client, VoiceChannel
|
from discord import Client
|
||||||
|
from discord import VoiceChannel
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -31,13 +32,7 @@ from websockets import exceptions
|
||||||
from . import __version__
|
from . import __version__
|
||||||
from . import applemusic
|
from . import applemusic
|
||||||
from . import spotify
|
from . import spotify
|
||||||
from .enums import (
|
from .enums import TrackType, NodeAlgorithm, PlaylistType, SearchType, URLRegex
|
||||||
TrackType,
|
|
||||||
NodeAlgorithm,
|
|
||||||
PlaylistType,
|
|
||||||
SearchType,
|
|
||||||
URLRegex
|
|
||||||
)
|
|
||||||
from .exceptions import InvalidSpotifyClientAuthorization
|
from .exceptions import InvalidSpotifyClientAuthorization
|
||||||
from .exceptions import LavalinkVersionIncompatible
|
from .exceptions import LavalinkVersionIncompatible
|
||||||
from .exceptions import NodeConnectionFailure
|
from .exceptions import NodeConnectionFailure
|
||||||
|
|
@ -984,7 +979,9 @@ class NodePool:
|
||||||
return len(self._nodes.values())
|
return len(self._nodes.values())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_best_node(cls, *, algorithm: NodeAlgorithm, channel: Optional[VoiceChannel] = None) -> Node:
|
def get_best_node(
|
||||||
|
cls, *, algorithm: NodeAlgorithm, channel: Optional[VoiceChannel] = None,
|
||||||
|
) -> Node:
|
||||||
"""Fetches the best node based on an NodeAlgorithm.
|
"""Fetches the best node based on an NodeAlgorithm.
|
||||||
This option is preferred if you want to choose the best node
|
This option is preferred if you want to choose the best node
|
||||||
from a multi-node setup using either the node's latency
|
from a multi-node setup using either the node's latency
|
||||||
|
|
@ -1019,10 +1016,9 @@ class NodePool:
|
||||||
if not chosen_region:
|
if not chosen_region:
|
||||||
return cls.get_best_node(algorithm=NodeAlgorithm.by_ping)
|
return cls.get_best_node(algorithm=NodeAlgorithm.by_ping)
|
||||||
|
|
||||||
if (node := next(
|
if node := next(
|
||||||
(node for node in available_nodes if node.location == chosen_region),
|
(node for node in available_nodes if node.location == chosen_region), None,
|
||||||
None
|
):
|
||||||
)):
|
|
||||||
return node
|
return node
|
||||||
|
|
||||||
return random.choice(available_nodes)
|
return random.choice(available_nodes)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue