From 53269ea98801b1021b2342d1437152319a024ec9 Mon Sep 17 00:00:00 2001 From: apoleon33 Date: Sun, 5 Apr 2026 21:46:22 +0200 Subject: [PATCH 1/2] barebone spotify implem (litteraly) --- lib/api.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/api.py b/lib/api.py index 962ca25..f343e7f 100644 --- a/lib/api.py +++ b/lib/api.py @@ -66,3 +66,8 @@ def username(self): return self.params.user @property def totalScrobbles(self): return self.totalScrobbles if self.totalScrobbles is not None else \ self._callApi()["recenttracks"]["@attr"]["total"] + + +class Spotify: + """Class to interact with Spotify's API.""" + pass \ No newline at end of file From 53f57d6338ededb7f6059d7a03e05a6bd71655d1 Mon Sep 17 00:00:00 2001 From: apoleon33 Date: Tue, 7 Apr 2026 20:13:19 +0200 Subject: [PATCH 2/2] baseline spotify implem --- lib/api.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/api.py b/lib/api.py index f343e7f..7ba1893 100644 --- a/lib/api.py +++ b/lib/api.py @@ -1,4 +1,6 @@ import requests +import spotipy +from spotipy import SpotifyOAuth from lib.track import Track from lib.user_config import ConfigFile, AppSettings @@ -27,6 +29,11 @@ def __str__(self): return f"?api_key={self.apiKey}&method={self.method}&user={self.user}&format={self.format}" +class SpotifyParams(AppSettings): + client_id: str + client_secret: str + + class LastFM: """Class to interact with Last.fm's API.""" params: Params @@ -70,4 +77,16 @@ def totalScrobbles(self): return self.totalScrobbles if self.totalScrobbles is n class Spotify: """Class to interact with Spotify's API.""" - pass \ No newline at end of file + sp: spotipy.Spotify + redirect_uri: str = "https://example.com" # maybe user config? + scope = "user-read-currently-playing" + + def __init__(self, params: SpotifyParams): + self.sp = spotipy.Spotify( + auth_manager=SpotifyOAuth( + client_id=params.client_id, + client_secret=params.client_secret, + redirect_uri=self.redirect_uri, + scope=self.scope, + ) + )