diff --git a/pyproject.toml b/pyproject.toml index 384ff7bd..eb90c32d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "wavelink" -version = "3.2.0" +version = "3.2.1" authors = [ { name="PythonistaGuild, EvieePy", email="evieepy@gmail.com" }, ] diff --git a/wavelink/__init__.py b/wavelink/__init__.py index 61e9edb4..1d059052 100644 --- a/wavelink/__init__.py +++ b/wavelink/__init__.py @@ -25,7 +25,7 @@ __author__ = "PythonistaGuild, EvieePy" __license__ = "MIT" __copyright__ = "Copyright 2019-Present (c) PythonistaGuild, EvieePy" -__version__ = "3.2.0" +__version__ = "3.2.1" from .enums import * diff --git a/wavelink/player.py b/wavelink/player.py index 39d04aad..6a0a0cd8 100644 --- a/wavelink/player.py +++ b/wavelink/player.py @@ -351,24 +351,19 @@ async def _search(query: str | None) -> T_a: # track for result in results for track in result... filtered_r: list[Playable] = [t for r in results for t in r] - if not filtered_r: - logger.debug(f'Player "{self.guild.id}" could not load any songs via AutoPlay.') + if not filtered_r and not self.auto_queue: + logger.info(f'Player "{self.guild.id}" could not load any songs via AutoPlay.') self._inactivity_start() return - if not self._current: - now: Playable = filtered_r.pop(1) - now._recommended = True - self.auto_queue.history.put(now) - - await self.play(now, add_history=False) - # Possibly adjust these thresholds? history: list[Playable] = ( self.auto_queue[:40] + self.queue[:40] + self.queue.history[:-41:-1] + self.auto_queue.history[:-61:-1] ) added: int = 0 + + random.shuffle(filtered_r) for track in filtered_r: if track in history: continue @@ -376,11 +371,17 @@ async def _search(query: str | None) -> T_a: track._recommended = True added += await self.auto_queue.put_wait(track) - random.shuffle(self.auto_queue._items) logger.debug(f'Player "{self.guild.id}" added "{added}" tracks to the auto_queue via AutoPlay.') - # Probably don't need this here as it's likely to be cancelled instantly... - self._inactivity_start() + if not self._current: + try: + now: Playable = self.auto_queue.get() + self.auto_queue.history.put(now) + + await self.play(now, add_history=False) + except wavelink.QueueEmpty: + logger.info(f'Player "{self.guild.id}" could not load any songs via AutoPlay.') + self._inactivity_start() @property def inactive_timeout(self) -> int | None: