Skip to content

Instantly share code, notes, and snippets.

@Sawboo
Created April 21, 2014 23:07
Show Gist options
  • Save Sawboo/11159590 to your computer and use it in GitHub Desktop.
Save Sawboo/11159590 to your computer and use it in GitHub Desktop.
Twitch.tv Channel Viewers - Text File
import requests
import time
CHANNEL = 'Zfg1'
headers = {'content-type': 'application/vnd.twitchtv.v2+json'}
while 1:
r = requests.get(
'https://api.twitch.tv/kraken/streams/summary.xml?channel=%s' % CHANNEL,
headers=headers)
print r.json()['viewers']
f = open('viewers.txt', 'r+')
f.seek(0)
f.write('%s viewers' % r.json()['viewers'])
f.truncate()
time.sleep(8)
# f.close()
@Sawboo
Copy link
Author

Sawboo commented Apr 22, 2014

Create the viewers.txt file in the same directory as tcvw.py. Change the string on line 5 to you desired twitch.tv channel and run the script. Now add a text source in OBS and use the viewers.txt as the source to get a live viewer count displayed on stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment