Created
April 21, 2014 23:07
-
-
Save Sawboo/11159590 to your computer and use it in GitHub Desktop.
Twitch.tv Channel Viewers - Text File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.