Twitch streaming widget – dynamic Twitch data in file form

Posted by adrian on December 22nd, 2016

If you’ve read any of my other posts you’ll know that I am a keen streamer on Twitch and that I have also written some javascript code which you can use in OBS or XSplit to display information like poster art for the game you are playing. I got a DM on Twitter the other day asking if I could write the name of the game to a file to be used in a text field in OBS. Unfortunately  it’s not possible to achieve this in javascript because the browser does not allow javascript to access local resources like hard drives to enable reading and writing of files. So I had a think about what I could do to resolve the problem and that was the inspiration for this project. What I normally do in these situations is write a simple application that runs from the command line, this is fine for me but for others it can be a bit of a drag and also the application is prone to being closed by accident.

So I thought I’d do something more complex and I have written an application which runs in the Windows System Tray. The tool checks on Twitch to find your channel and writes the name of the game you have configured in your dashboard to a file as well as other items. Then the name of the game is easily accessible to add to a scene in OBS or XSplit using a Text box. Please note that I consider this tool to be very early in development, effectively Alpha. However please do let me know via comments or DM on Twitter if you are having problems and I will try and help you out

To install the tool download the zip file here: http://unshapedadrian.co.uk/downloads/twitchfiles.zip. Unzip and copy the folder and all files to a place on your hard drive, as an example d:\temp. Find the file d:\temp\twitchfiles\twitchfiles.exe, right click it and choose copy. On your desktop right click and choose Paste shortcut. Right click the shortcut you created and choose Properties, in the “Target:” box add a space and then your Twitch channel name. If you want the files the tool generates to be in a different folder than the application then put that folder in the “Start in:” box, make sure you create the relevant folder otherwise you won’t be able to update the shortcut.  Mine looks like this:

Click OK and then run the tool by double clicking on the shortcut. If you get an error from Windows SmartScreen Filter please go ahead and run the application I promise you that there is nothing untoward about the application.

What you should see now is the tool running in the System Tray like this:

If you Right Click you will see the menu which you can use to Exit and force the tool to refresh your data from Twitch.

Three files will be generated in the folder you configured in the shortcut properties:

Game.txt – contains the name of the game you have configured in your Twitch Dashboard

Status.txt – contains the Stream title  you have configured in your Twitch Dashboard

NumberofFollowers.txt – contains (believe it or not) the number of followers your channel has.

The tool polls Twitch for changes every five minutes but if you want to you can force the tool to refresh by using the Force Refresh option, please bear in mind that after you change something in your Twitch dashboard it can take up to a minute for that information to be reflected in the API. So if you change you game and want the tool to pick up the change I’d give it 30 seconds at least before hitting the Force Refresh button

Last but by no means least if you can’t get the tool to work properly have a look for the error.log file in the application folder and see if that helps you understand what’s not working.

You can add the text in these files to your OBS Studio scene using the Text (GDI+) source and configuring your settings like this:

 

I couldn’t have got started in this application without the following resources.

https://www.codeproject.com/Articles/36468/WPF-NotifyIcon

https://www.iconfinder.com/icons/306173/twitch_twitchtv_icon#size=120

 

/* */