From b2825bed3d6e304d3a964cf5f752d719227dc533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Wed, 27 Jul 2022 15:47:50 +0200 Subject: [PATCH] added auth stuff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.py b/main.py index c090db3..b9fbd34 100644 --- a/main.py +++ b/main.py @@ -167,6 +167,19 @@ if __name__ == '__main__': else: load_dotenv() + sp_scopes = 'user-read-currently-playing user-read-playback-state streaming user-read-email user-read-private user-read-currently-playing user-read-playback-position user-read-playback-state' + global sp + sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=sp_scopes)) + one_device_is_active = False + for x in sp.devices()['devices']: + if x['is_active'] == True: + try: + sp.start_playback(x['id']) + except: + pass + one_device_is_active = True + break + strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL) strip.begin()