used black

This commit is contained in:
hhh
2024-11-02 00:10:24 +02:00
parent 1b1f217b75
commit e0a3d256d5
79 changed files with 658 additions and 733 deletions

View File

@@ -4,7 +4,7 @@ from bot.utils.config import config
spotify = Spotify(
client_id=config.tokens.spotify.client_id,
client_secret=config.tokens.spotify.client_secret
client_secret=config.tokens.spotify.client_secret,
)
__all__ = ['spotify']
__all__ = ["spotify"]

View File

@@ -9,12 +9,15 @@ class SongItem(BaseSongItem):
@classmethod
def from_spotify(cls, song_item: dict):
return cls(
name=song_item['name'],
id=song_item['id'],
artists=[artist['name'] for artist in song_item['artists']],
preview_url=song_item['preview_url'].split('?')[0] if
song_item['preview_url'] is not None else None,
thumbnail=song_item['album']['images'][1]['url']
name=song_item["name"],
id=song_item["id"],
artists=[artist["name"] for artist in song_item["artists"]],
preview_url=(
song_item["preview_url"].split("?")[0]
if song_item["preview_url"] is not None
else None
),
thumbnail=song_item["album"]["images"][1]["url"],
)
@@ -28,7 +31,7 @@ class Songs(object):
if r is None:
return None
return [SongItem.from_spotify(item) for item in r['tracks']['items']]
return [SongItem.from_spotify(item) for item in r["tracks"]["items"]]
def from_id(self, song_id: str) -> SongItem | None:
r = self.spotify.track(song_id)

View File

@@ -8,11 +8,10 @@ class Spotify(object):
def __init__(self, client_id, client_secret):
self.spotify = spotipy.Spotify(
client_credentials_manager=SpotifyClientCredentials(
client_id=client_id,
client_secret=client_secret
client_id=client_id, client_secret=client_secret
),
backoff_factor=0.1,
retries=10
retries=10,
)
self.songs = Songs(self.spotify)