Compare commits

...

3 Commits

Author SHA1 Message Date
Derek 9e8d05fc90 Make consent code message a little more clear 2020-12-06 21:05:43 -07:00
Derek 0ad7318b98 Fix timeout bleeding over states 2020-12-06 21:05:33 -07:00
Derek b69253c485 Fix setup bug 2020-12-06 21:05:04 -07:00
3 changed files with 5 additions and 5 deletions

View File

@ -73,8 +73,8 @@ class ChatProcess(Process, ABC):
def run(self): def run(self):
try: try:
timeout = 0
while True: while True:
timeout = 0
response = self.loop(self._next_state) response = self.loop(self._next_state)
if response is None or type(response) is int or type(response) is float: if response is None or type(response) is int or type(response) is float:
timeout = response timeout = response

View File

@ -167,9 +167,9 @@ class YoutubeLiveProcess(ChatProcess):
url = f"{self._client_secrets['auth_uri']}?{param_str}" url = f"{self._client_secrets['auth_uri']}?{param_str}"
webbrowser.open(url) webbrowser.open(url)
def setup_oauth_consent(self): def setup_oauth_consent(self, consent_code):
response = requests.post(YoutubeLiveProcess.GOOGLE_OAUTH_TOKEN_URL, data={ response = requests.post(YoutubeLiveProcess.GOOGLE_OAUTH_TOKEN_URL, data={
'code': self._consent_code, 'code': consent_code,
'client_id': self._client_secrets['client_id'], 'client_id': self._client_secrets['client_id'],
'client_secret': self._client_secrets['client_secret'], 'client_secret': self._client_secrets['client_secret'],
'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob', 'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob',
@ -180,7 +180,7 @@ class YoutubeLiveProcess(ChatProcess):
with open('refresh_token.secret', 'w') as f: with open('refresh_token.secret', 'w') as f:
f.write(auth['refresh_token']) f.write(auth['refresh_token'])
self._access_token = auth['access_token'] self._access_token = auth['access_token']
self._access_token = auth['refresh_token'] self._refresh_token = auth['refresh_token']
def get_fresh_access_token(self): def get_fresh_access_token(self):
response = requests.post(YoutubeLiveProcess.GOOGLE_OAUTH_TOKEN_URL, data={ response = requests.post(YoutubeLiveProcess.GOOGLE_OAUTH_TOKEN_URL, data={

View File

@ -32,7 +32,7 @@ if __name__ == '__main__':
if process.control_pipe.poll(): if process.control_pipe.poll():
chat_control_msg = process.control_pipe.recv() chat_control_msg = process.control_pipe.recv()
if chat_control_msg == YoutubeLive.CONTROL_MESSAGES.NEEDS_OAUTH_CONSENT_TOKEN: if chat_control_msg == YoutubeLive.CONTROL_MESSAGES.NEEDS_OAUTH_CONSENT_TOKEN:
code = input('Paste response code here: ') code = input('Allow access in your browser and paste response code here: ')
process.control_pipe.send({ process.control_pipe.send({
'type': YoutubeLive.CONTROL_MESSAGES.OAUTH_CONSENT_TOKEN, 'type': YoutubeLive.CONTROL_MESSAGES.OAUTH_CONSENT_TOKEN,
'token': code 'token': code