Instinctlol / automatic-twitch-recorder

Checks if a user on twitch is currently streaming and then records the stream via streamlink
186 stars 40 forks source link

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url #22

Closed prettymuchbryce closed 4 years ago

prettymuchbryce commented 5 years ago

Repeating an example from the documentation results in a 400 Error.

➜  automatic-twitch-recorder git:(master) ✗ python3 atr_cmd.py
(Cmd) add forsen
Traceback (most recent call last):
  File "atr_cmd.py", line 96, in <module>
    AtrCmd().cmdloop_with_keyboard_interrupt()
  File "atr_cmd.py", line 90, in cmdloop_with_keyboard_interrupt
    self.cmdloop()
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/cmd.py", line 217, in onecmd
    return func(arg)
  File "atr_cmd.py", line 20, in do_add
    self.daemon.add_streamer(line[0])
  File "/Users/bryce/projects/automatic-twitch-recorder/daemon.py", line 38, in add_streamer
    user_info = self.CLIENT.users.translate_usernames_to_ids(streamer)
  File "/usr/local/lib/python3.7/site-packages/twitch/api/users.py", line 94, in translate_usernames_to_ids
    response = self._request_get('users?login={}'.format(usernames))
  File "/usr/local/lib/python3.7/site-packages/twitch/api/base.py", line 53, in _request_get
    response.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.twitch.tv/kraken/users?login=forsen
M08s commented 5 years ago

I'm having this issue too. Have you been able to figure it out? I can't add streamers to client_id either

prettymuchbryce commented 5 years ago

@M08s My best guess is that this project is just no longer maintained and the underlying API has changed. Maybe someone should fork it, or create something new?

M08s commented 5 years ago

Yeah... Bummer. My quick search it seems to make API calls with Twitch you need a client ID. When you request https://api.twitch.tv/kraken/streams/'STREAMERS NAME' you get an error now. Not sure how to work around.

Instinctlol commented 5 years ago

Hello, the project is still being maintained by myself. I have to do it in my free time, though, which is why I haven't had the time to fix it. A lof of things are just more important than this small project, but I always welcome people to make pull requests. As is explained here, the project will implement webhooks to avoid the shadow banning. This is why it doesn't make sense to update the current codebase.

M08s commented 5 years ago

Good to hear! Instead of webhooks what if it used notifications from IMAP? Wouldn't that avoid the mess?

Instinctlol commented 4 years ago

Please check out the webhooks branch. Though there's support included for webhooks, I decided to take it out. I migrated to the new Twitch API and now one can make 800 API Calls per minute per user. So with an interval of 1 seconds, theoretically, checking if a streamer or if multiple streamers is / are online every second makes 60 API calls per minute, which is far from the allowed 800. So right now, there's no need for webhooks for this project.

However, there's a weird bug with streamlink currently, I need to investigate that.