dunossauro / livestream-chat

livestream-chat
GNU General Public License v3.0
23 stars 4 forks source link

tratar a chamada do id do chat para caso não esteja disponível #6

Closed dunossauro closed 2 years ago

dunossauro commented 2 years ago

Essa linha precisa de tratamento

            chat_id = video_info["items"][0]["liveStreamingDetails"]["activeLiveChatId"]
dunossauro commented 2 years ago

exemplo do trace

± |main U:6 ✗| → LIVESTREAM_ID=f8WKi3Rz3Y uvicorn app.app:app
INFO:     Started server process [14393]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     127.0.0.1:45692 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:45692 - "GET /styles.css HTTP/1.1" 200 OK
INFO:     127.0.0.1:45692 - "GET /favicon.ico HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:45694 - "GET /chat_websocket.py?1649566521131 HTTP/1.1" 200 OK
INFO:     ('127.0.0.1', 45696) - "WebSocket /ws/chat" [accepted]
INFO:     connection open
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 184, in run_asgi
    result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 261, in __call__
    await super().__call__(scope, receive, send)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 146, in __call__
    await self.app(scope, receive, send)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/starlette/exceptions.py", line 58, in __call__
    await self.app(scope, receive, send)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/starlette/routing.py", line 315, in handle
    await self.app(scope, receive, send)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/starlette/routing.py", line 77, in app
    await func(session)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 274, in app
    await dependant.call(**values)
  File "/home/dunossauro/git/livestream-chat/./app/app.py", line 33, in chat
    chat_id = await get_chat_id()
  File "/home/dunossauro/git/livestream-chat/./app/chat.py", line 21, in get_chat_id
    chat_id = video_info["items"][0]["liveStreamingDetails"]["activeLiveChatId"]
IndexError: list index out of range
ERROR:    closing handshake failed
Traceback (most recent call last):
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/websockets/legacy/server.py", line 240, in handler
    await self.close()
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 779, in close
    await asyncio.shield(self.close_connection_task)
  File "/home/dunossauro/git/livestream-chat/.venv/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 1312, in close_connection
    self.transport.write_eof()
  File "uvloop/handles/stream.pyx", line 696, in uvloop.loop.UVStream.write_eof
  File "uvloop/handles/handle.pyx", line 159, in uvloop.loop.UVHandle._ensure_alive
RuntimeError: unable to perform operation on <TCPTransport closed=True reading=False 0x564028a8b250>; the handler is closed
INFO:     connection closed