Skip to content

Commit

Permalink
update: If stream is not live, return False.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mantouisyummy committed Mar 6, 2024
1 parent ff128d9 commit a8d68eb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tystream/async_api/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def check_stream_live(self, streamer_name: str) -> TwitchStreamData:
-------
:class:`TwitchStreamData`
An instance of the TwitchStreamData class containing information about the live stream.
If the stream is not live, an empty TwitchStreamData instance is returned.
If the stream is not live, returned False.
"""
headers = await self._get_headers()
async with aiohttp.ClientSession() as session:
Expand All @@ -52,7 +52,7 @@ async def check_stream_live(self, streamer_name: str) -> TwitchStreamData:

if not stream_data["data"]:
self.logger.log(25, f"{streamer_name} is not live.")
return TwitchStreamData()
return False
else:
self.logger.log(25, f"{streamer_name} is live!")
return TwitchStreamData(**stream_data["data"][0])
6 changes: 3 additions & 3 deletions tystream/async_api/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def _get_live_id(self, channelid: str) -> str:
-------
:class:`str`
The ID of the live stream if a live stream is found.
False if no live stream is found.
Return False if no live stream is found.
"""
url = f"https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={channelid}&eventType=live&type=video&key={self.api_key}"

Expand All @@ -87,7 +87,7 @@ async def check_stream_live(self, username: str) -> YoutubeStreamData:
-------
:class:`YoutubeStreamData`
An instance of the YoutubeStreamData class containing information about the live stream.
If the stream is not live, an empty YoutubeStreamData instance is returned.s
If the stream is not live, returned False.
"""
channelId = await self._get_channel_id(username)
LiveId = await self._get_live_id(channelId)
Expand All @@ -105,4 +105,4 @@ async def check_stream_live(self, username: str) -> YoutubeStreamData:
return YoutubeStreamData(id=LiveId, **data)
else:
self.logger.log(20, f"{username} is not live.")
return YoutubeStreamData()
return False
2 changes: 1 addition & 1 deletion tystream/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def check_stream_live(self, streamer_name: str) -> TwitchStreamData:
-------
:class:`TwitchStreamData`
An instance of the TwitchStreamData class containing information about the live stream.
If the stream is not live, an empty TwitchStreamData instance is returned.
If the stream is not live, returned False.
"""
headers = self._get_headers()
stream = requests.get(
Expand Down
4 changes: 2 additions & 2 deletions tystream/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def check_stream_live(self, username: str) -> YoutubeStreamData:
-------
:class:`YoutubeStreamData`
An instance of the YoutubeStreamData class containing information about the live stream.
If the stream is not live, an empty YoutubeStreamData instance is returned.s
If the stream is not live, returned False.
"""
channelId = self._get_channel_id(username)
LiveId = self._get_live_id(channelId)
Expand All @@ -107,4 +107,4 @@ def check_stream_live(self, username: str) -> YoutubeStreamData:
return YoutubeStreamData(id=LiveId, **data)
else:
self.logger.log(20, f"{username} is not live.")
return YoutubeStreamData()
return False

0 comments on commit a8d68eb

Please sign in to comment.