Skip to content

Commit

Permalink
refactor: request method use session
Browse files Browse the repository at this point in the history
  • Loading branch information
Mantouisyummy committed Jul 16, 2024
1 parent b6e8814 commit 1c6ca4d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tystream/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_user(self, streamer_name: str) -> TwitchUserData:
"""
headers = self._get_headers()

user = requests.get(
user = self.session.get(
"https://api.twitch.tv/helix/users?login=" + streamer_name,
headers=headers,
timeout=10
Expand Down Expand Up @@ -83,7 +83,7 @@ def check_stream_live(self, streamer_name: str) -> TwitchStreamData | bool:

user = self.get_user(streamer_name)

stream = requests.get(
stream = self.session.get(
"https://api.twitch.tv/helix/streams?user_login=" + streamer_name,
headers=headers,
timeout=10
Expand All @@ -96,6 +96,7 @@ def check_stream_live(self, streamer_name: str) -> TwitchStreamData | bool:
self.logger.log(25, "%s is live!", streamer_name)
return TwitchStreamData(**stream_data["data"][0], user=user)


def get_stream_vod(self, streamer_name: str) -> TwitchVODData:
"""
Retrieve the latest Twitch Stream VOD data.
Expand All @@ -118,7 +119,7 @@ def get_stream_vod(self, streamer_name: str) -> TwitchVODData:

user = self.get_user(streamer_name)

vod = requests.get(
vod = self.session.get(
f"https://api.twitch.tv/helix/videos?user_id={user.id}&type=archive",
headers=headers,
timeout=10
Expand Down

0 comments on commit 1c6ca4d

Please sign in to comment.