SwagLyrics / SwSpotify

Cross-platform library to get the currently playing song and artist from Spotify w/o using the API or the internet. Very fast.
MIT License
85 stars 12 forks source link

spotify.current() throws blocking runtime error if Spotify is not playing #48

Open Coolisbetter opened 2 years ago

Coolisbetter commented 2 years ago

When running

from SwSpotify import spotify
try:
    title, artist = spotify.current()
except:
    print(f"Song lookup timed out")
    return

I get the below error message. Furthermore, the python script will hang until I send a Ctrl-C keyboard interrupt to the console.

Not sure why my try:except isn't catching the error, also not sure why I have to send Ctrl-C to let the python script continue.

[2022-08-16 18:08:53,054] ERROR in app: Exception on /shutdown [POST]
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_cors\extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\SwSpotify\web_server.py", line 40, in shutdown_server
    shutdown()
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\SwSpotify\web_server.py", line 47, in shutdown
    raise RuntimeError('Not running with the Werkzeug Server')
RuntimeError: Not running with the Werkzeug Server
aadibajpai commented 2 years ago

@Ace314159 is windows so your help would be appreciated

SpamixOfficial commented 9 months ago

I know this is an old issue but I'm having the exact same issue at the moment. I'm on linux.