Skip to content

Commit

Permalink
Fix the previous commit. Set cookie after login
Browse files Browse the repository at this point in the history
  • Loading branch information
Tkd-Alex committed Jan 22, 2021
1 parent 87da61b commit c4e9466
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion TwitchChannelPointsMiner/classes/Twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, username):
cookies_path = os.path.join(Path().absolute(), "cookies")
Path(cookies_path).mkdir(parents=True, exist_ok=True)
self.cookies_file = os.path.join(cookies_path, f"{username}.pkl")
self.twitch_login = TwitchLogin(TWITCH_CLIENT_ID, username)
self.twitch_login = TwitchLogin(TWITCH_CLIENT_ID, username, USER_AGENT)
self.running = True

def login(self):
Expand All @@ -42,6 +42,7 @@ def login(self):
self.twitch_login.save_cookies(self.cookies_file)
else:
self.twitch_login.load_cookies(self.cookies_file)
self.twitch_login.set_token(self.twitch_login.get_auth_token())

def update_minute_watched_event_request(self, streamer):
event_properties = {
Expand Down
7 changes: 5 additions & 2 deletions TwitchChannelPointsMiner/classes/TwitchLogin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@


class TwitchLogin:
def __init__(self, client_id, username):
def __init__(self, client_id, username, user_agent):
self.client_id = client_id
self.token = None
self.login_check_result = False
self.session = requests.session()
self.session.headers.update({"Client-ID": self.client_id})
self.session.headers.update({
"Client-ID": self.client_id,
"User-Agent": user_agent
})
self.username = username
self.user_id = None
self.email = None
Expand Down

0 comments on commit c4e9466

Please sign in to comment.