#UNFINISHED
Retrieves follower and/or subscriber information from the Twitch API and saves it to a file in a format set by the user in a configuration file.
##Setup
###Prerequisites
- Joyent Node.js
- A Twitch account
- Client ID from a registered application
- An OAuth token if you want access to subscription data (optional)
###Instructions
####Install Node.js
- Go to the Node.js download page and download the version for your system.
- Install Node.js for your system.
####Download the code
- Saving the source code
- Click
followers.js
in the file navigator on GitHub to display the source code. - Click "Raw" in the grey box above the code.
- Save this page (Ctrl+S or right-click "Save as...")
- Place it in a folder where OBS or some other program can read the resulting file "followers.txt"
- Click
####Run followers.js
You have severals options to run the file. Choose from below.
Once you have run the program once, it should create a configuration file called "config.json." It's formatted in JSON. There's another section about editing the configuration file below.
#####Directly into a command prompt/terminal
The basic way would be to open a command prompt/terminal and cd
to the location of followers.js
and run using node
:
$ cd followers
$ node followers.js
#####Folder Address Bar
If you have the folder open in Windows, you can press alt+d (to select the text for the current folder's address) and type "cmd
" to open a command prompt or simply "node followers.js
" to automatically run the file.
#####Shortcut to batch file
You can create a start.bat
file in the same folder with follower.js
and write the following:
node followers.js
pause
Then you can either run this file, create a shortcut to start.bat
and move it to some other folder, or pin it to your Start menu (or similar).
#####Associate Node with .js
######Windows
- Context menu:
- Right-click
followers.js
and choose "Open with" -> "Choose default program..." - Select Node. Node.js will appear as a green hexagon labeled as "Evented I/O for V8 JavaScript" by "Joyent, Inc."
- Right-click
- Use the control panel:
- Open the file association helper in the control panel:
- Windows 7 and probably 8: Open the start menu and type "asso" and press enter. This will open the control panel to the "Set Associations" helper.
- Otherwise, open the Windows control panel and:
- Click Programs.
- Click "Make a file type always open in a specific program" or similar.
- Then scroll to file ".js" on the left and double click the line or click "Change program..." near the top right-hand corner of the window.
- Select Node.js. Node.js will probably appear as a green hexagon labeled as "Evented I/O for V8 JavaScript" by "Joyent, Inc."
- Hit "OK" to close the dialog and "Close" to exit the control panel.
- Open the file association helper in the control panel:
######Mac
- Right-click
followers.js
and choose "Get info." - Change "Open with" to Node.js or however it appears on Mac.
######Linux
- Right-click
followers.js
and choose "Properties." - Go to the "Open with" tab and select Node.js or however it appears on Linux.
####Modify The Configuration File
The file is formatted in JSON. There are plenty of online converters and documentation if you need fundamental help working with this file.
- "client_id" - String - This is the client ID of a Twitch application you must create for the purpose of this application to prevent the Twitch API from rate limiting you.
- "oauth_token" - String -
- "channel" - String - The channel you want to access information for.
- "info" - String - Can be
followers
,subscribers
, orboth
. You may also usefol
,sub
, orfolsub
/subfol
. - "message_args" - Array - This is merely a list of variables used in the message and changing or removing this does not affect the program.
- "[follower/subscriber]_message" - String - What you want written to "[
follower
/subscriber
].txt" by the program. You can use the variables inmessage_args
to input infomation into your message.- "%[FOLLOWER/SUBSCRIBER]_COUNT%" - The
channel
's current number of [follower
/subscriber
] as reported by the Twitch API. - "%CHANNEL%" - The
channel
that it's checking for written exactly as it is in the config. - "%LAST_[FOLLOWER/SUBSCRIBER]%" - The
display_name
of the last [follower
/subscriber
]. - "%RAW_JSON%" - The raw output from the Twitch API.
- "%[FOLLOWER/SUBSCRIBER]_COUNT%" - The
- "delay_sec" - Number - Number of seconds to wait between requests to the Twitch API.
5
is the default value. - "delay_to" - Boolean - Can be
true
orfalse
.false
is the default value. This tells the program to send a request everydelay_sec
seconds (false) ordelay_sec
after the last request to the Twitch API (true). ("to" means timeout like setTimeout)
####Twitch Application Registration And Retrieving The Client ID And OAuth Token You may use an application you've already registered for the purpose of obtaining a client ID and OAuth token.
-
Obtain a client ID:
- Go to Twitch.tv and log in to your account.
- Go to the settings.
- Go to the Connections tab.
- At the bottom, click "Register your application."
- Enter an application name like "Follow Count" and "http://localhost" for the "Redirect URI."
- Copy the client ID from the resulting page into the
config.json
file.
"client_id": "INSERT_CLIENT_ID_HERE",
-
Obtain an oauth token: (optional, but required for subscriber-related info)
- To get to an authorize page for your application, change and load the following URL in your browser. Replace
INSERT_CLIENT_ID_HERE
with your client ID you retrieved previously. The URL:https://api.twitch.tv/kraken/oauth2/authorize?response_type=token&client_id=INSERT_CLIENT_ID_HERE&redirect_uri=http://localhost&scope=channel_subscriptions
- Click "Authorize."
- You should be at the following URL:
http://localhost/#access_token=123asdf123asdf123asdf123asdf123&scope=channel_subscriptions
- Copy the
access_token
from the hash in the URL into theconfig.json
file.
"oauth_token": "INSERT_OAUTH_TOKEN_HERE",
- To get to an authorize page for your application, change and load the following URL in your browser. Replace