You need to use the twtich API, you can register an app in the Developer portal, the use this code to get the channel name:
import requests
import json
CHANNEL_ID = '51496027'
#https://dev.twitch.tv/console/apps/create
client_id = '**client_id_here**'
client_secret = '**client_secret_here**'
grant_type = 'client_credentials'
# Get access token using app authentication exchange
url = 'https://id.twitch.tv/oauth2/token'
payload = {
'client_id': client_id,
'client_secret': client_secret,
'grant_type': grant_type,
}
response = requests.post(url, data=payload)
access_token = json.loads(response.text)['access_token']
# Set up headers with access token for API requests
headers = {
'Authorization': f'Bearer {access_token}',
'Client-Id': client_id,
}
# Make API requests
url = f'https://api.twitch.tv/helix/channels?broadcaster_id={CHANNEL_ID}'
response = requests.get(url, headers=headers)
data = json.loads(response.text)
print(data['data'][0]['broadcaster_name'])