chapnickc / WizHook

Synchronize your Wiz connected light with the music you play on Spotify
MIT License
18 stars 2 forks source link

Error in Terminal #2

Open Unknown303YT opened 1 year ago

Unknown303YT commented 1 year ago

Hi @larochefoucald! After running these commands*, I occasionaly get this error: ERROR:root:0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('https://api.spotify.com/v1/me/player/currently-playing') Traceback (most recent call last): File "/home/[user]/Downloads/WizHook-main/app/SpotifyChangeListener.py", line 66, in listen async for event in self._listen_for_events(session): File "/home/[user]/Downloads/WizHook-main/app/SpotifyChangeListener.py", line 48, in _listen_for_events current = await self._get_current_playing(session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/[user]/Downloads/WizHook-main/app/SpotifyChangeListener.py", line 34, in _get_current_playing return await response.json() ^^^^^^^^^^^^^^^^^^^^^ File "/home/[user]/.local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1104, in json raise ContentTypeError( aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('https://api.spotify.com/v1/me/player/currently-playing') Afterwards, the program keeps running, and I'm not sure why. Could someone please help?

Thanks, Aidan R

*. ./env.sh & python3 main.py

smartsousa commented 1 year ago

Hi friend...after run Terminal this happens to me

ERROR:root:Cannot connect to host api.spotify.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)')] Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection transport, protocol = await self._create_connection_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport await waiter File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/sslproto.py", line 574, in _on_handshake_complete raise handshake_exc File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/sslproto.py", line 556, in _do_handshake self._sslobj.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 979, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Users/pedrosousa/WizHook/app/SpotifyChangeListener.py", line 66, in listen async for event in self._listen_for_events(session): File "/Users/pedrosousa/WizHook/app/SpotifyChangeListener.py", line 48, in _listen_for_events current = await self._get_current_playing(session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pedrosousa/WizHook/app/SpotifyChangeListener.py", line 33, in _get_current_playing async with session.get(config.API_CURRENT_PLAYING) as response: File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection raise last_exc File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 982, in _wrap_create_connection raise ClientConnectorCertificateError(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host api.spotify.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)')]

Can you help me?

chapnickc commented 1 year ago

Hi there, this looks like an issue with the request to the Spotify API. Just tested the latest main branch with python3.11--that does not seem to be the issue. Could be environment specific. There is a step in the README about

The first time you run the script you need to obtain credentials. The workflow for this is a little funky. Running main.py should start your browser and redirect you to a URL. Copy and paste the url from the browser into Terminal.app.

Double checking this step may be helpful. Another item is to try to pin the set of libraries you are using by creating a virtual environment for your project.

This is not related to the original issue, so feel free to create a new one.