An easy to use Python bot for retrieving Twitch chat data from multiple streams/channels simultaneously. Includes functionality to generate adjacency matrices between the streams, for the purpose of network modelling. All files are generated in your working directory.
pip install twitch-listener
- Get a twitch.tv account
- get one here https://www.twitch.tv/signup
- Obtain a Twitch client id
- Get yours by registering an app here https://dev.twitch.tv/console/apps/create
- (You can set 'OAuth Redirect URL' to 'http://localhost')
- Acquire a Twitch OAuth token
- Get yours here https://twitchapps.com/tmi/
Store these values securely. You now have everything you need to use TwitchListener.
from twitch_listener import listener
# Connect to Twitch
bot = listener.connect_twitch('yourUsernameHere',
'yourOauthHere',
'yourClientIDHere')
# List of channels to connect to
channels_to_listen_to = ['Northernlion', 'DumbDog', 'DanGheesling']
# Scrape live chat data into raw log files. (Duration is seconds)
bot.listen(channels_to_listen_to, duration = 1800)
# Convert log files into .CSV format
bot.parse_logs(timestamp = True)
# Generate adjacency matrix
bot.adj_matrix(weighted = False, matrix_name = "streamer_network.csv")