Chat monitors stream to end
This commit is contained in:
parent
b50a4bad02
commit
38d51636af
4 changed files with 89 additions and 1 deletions
|
|
@ -115,6 +115,34 @@ class StreamMonitor:
|
|||
print(f'{Fore.YELLOW} {str(e)}{Style.RESET_ALL}')
|
||||
sys.exit(1)
|
||||
|
||||
def is_user_live(self) -> bool:
|
||||
"""
|
||||
Check if the configured user is currently live.
|
||||
|
||||
Returns:
|
||||
bool: True if user is live, False if offline
|
||||
|
||||
Raises:
|
||||
Exception: If API request fails (caller should handle)
|
||||
"""
|
||||
query = f'query{{user(login: "{self.username}") {{stream{{id title}}}}}}'
|
||||
|
||||
try:
|
||||
response = requests.post(
|
||||
TWITCH_GQL_URL,
|
||||
json={'query': query},
|
||||
headers={"Client-ID": TWITCH_GQL_CLIENT_ID},
|
||||
timeout=15
|
||||
)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
stream_data = data.get('data', {}).get('user', {}).get('stream')
|
||||
return stream_data is not None
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
# Don't exit, let caller handle this
|
||||
raise Exception(f"Failed to check if user is live: {str(e)}")
|
||||
|
||||
def get_latest_vod(self) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Get the most recent VOD for the configured user.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue