lrrbot icon indicating copy to clipboard operation
lrrbot copied to clipboard

`!live` broken because `_total` is missing

Open andreasots opened this issue 4 years ago • 3 comments

This is also affecting eris: andreasots/eris#974. Log fragment:

[2020-06-27 21:53:36,635] INFO:command_parser:Command from qrpth: !live 
[2020-06-27 21:53:36,664] DEBUG:common.http:GET 'https://api.twitch.tv/kraken/streams/followed'{'offset': 0, 'limit': 25}...
[2020-06-27 21:53:36,901] ERROR:utils:Exception in future
Traceback (most recent call last):
  File "/srv/lrrbot/lrrbot/common/utils.py", line 245, in check_exception
    future.result()
  File "/srv/lrrbot/lrrbot/common/utils.py", line 156, in wrapper
    return (await func(*args, **kwargs))
  File "/srv/lrrbot/lrrbot/lrrbot/decorators.py", line 160, in wrapper
    return await func(self, conn, event, respond_to, *args, **kwargs)
  File "/srv/lrrbot/lrrbot/lrrbot/commands/live.py", line 62, in live
    streams = await twitch.get_streams_followed()
  File "/srv/lrrbot/lrrbot/common/twitch.py", line 316, in get_streams_followed
    return await utils.async_to_list(get_paginated_by_offset("https://api.twitch.tv/kraken/streams/followed", 'streams', headers=headers))
  File "/srv/lrrbot/lrrbot/common/utils.py", line 380, in async_to_list
    async for i in aiter:
  File "/srv/lrrbot/lrrbot/common/twitch.py", line 124, in __anext__
    self.total = res['_total']
KeyError: '_total'

andreasots avatar Jun 27 '20 22:06 andreasots

I don't know that "Twitch pls" is fair, iirc _total is an undocumented property here, they're allowed to get rid of it. Though it does mean we'll need a different way to be able to tell when the pagination ends...

mrphlip avatar Jun 28 '20 14:06 mrphlip

It looks like it used to be documented (https://web.archive.org/web/20191223083704/https://dev.twitch.tv/docs/v5/reference/streams#get-followed-streams) and now it's just gone.

andreasots avatar Jun 28 '20 17:06 andreasots

There seems to have been an announcement back in February: https://discuss.dev.twitch.tv/t/upcoming-changes-to-the-streams-v5-endpoints/23926

andreasots avatar Jun 28 '20 17:06 andreasots

Fixed in 6795f657279ee28d3da229b68cacadaa076d0090.

andreasots avatar Mar 24 '23 23:03 andreasots