Merge branch 'cloudwithax:main' into main

This commit is contained in:
MiroslavRosenov 2022-03-07 11:22:31 +02:00 committed by GitHub
commit ec8b8dc9c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -255,10 +255,13 @@ class Node:
""" """
for player in self.players.copy().values(): for player in self.players.copy().values():
await player.destroy() await player.destroy()
if self._spotify_client_id and self._spotify_client_secret:
await self._spotify_client.close()
await self._websocket.close() await self._websocket.close()
del self._pool.nodes[self._identifier] del self._pool._nodes[self._identifier]
self.available = False self._available = False
self._task.cancel() self._task.cancel()
async def build_track( async def build_track(

View File

@ -50,6 +50,8 @@ class Client:
self._bearer_token = data["access_token"] self._bearer_token = data["access_token"]
self._expiry = time.time() + (int(data["expires_in"]) - 10) self._expiry = time.time() + (int(data["expires_in"]) - 10)
self._bearer_headers = {"Authorization": f"Bearer {self._bearer_token}"} self._bearer_headers = {"Authorization": f"Bearer {self._bearer_token}"}
async def search(self, *, query: str): async def search(self, *, query: str):
if not self._bearer_token or time.time() >= self._expiry: if not self._bearer_token or time.time() >= self._expiry:
@ -127,3 +129,7 @@ class Client:
next_page_url = next_data["next"] next_page_url = next_data["next"]
return Playlist(data, tracks) return Playlist(data, tracks)
async def close(self):
await self.session.close()