Pewdiepie vs T-Series Live Count

touch-bar

#1

Here is a Touch Bar widget that will display the live youtube sub count. You can set it to repeat as quickly as you want. 1 second is the refresh rate of the live count that socialblade uses but yours can be slower if you do not want to send that many requests in a day.

In order for this to work all you need is a gmail and an api key.

Once signed in to your gmail/Google account go to https://console.developers.google.com

From there you should be able to activate/begin using Google's APIs completely free.

Next, go to the Library tab on the left and then scroll down to YouTube, then YouTube Data API v3 and hit Enable

Now go to credentials and hit Create Credentials to generate your API key and then copy that and paste it into the advanced settings where you see the python script.

Can't get link to work. So instead here is the script

Go to Touch Bar settings > New Widget > Run Shell script and show return value

SCRIPT HERE

import json
import urllib2

name = "pewdiepie"
key = “your key”

data = urllib2.urlopen("https://www.googleapis.com/youtube/v3/channels?part=statistics&forUsername="+name+"&key="+key).read()
subs = json.loads(data)["items"][0]["statistics"]["subscriberCount"]

print("{:,d}".format(int(subs)))

Paste it in to where it says

key = "your key"

At the top your Launch Path: must be set to: /usr/bin/python

And done, if when hitting "run script" does not work save it anyway and restart BetterTouchTool.
Sometimes the script will not work in the advanced settings but works fine on the Touch Bar.

Also, the icons I just got from Google searching "pewdiepie icon" and dragging over the best looking one. Would recommend one with no background.

Now to get the T-Series Counter just hit the link once more to get two pewdiepie counters and then go into the advanced settings and in the script paste in your api key and then in the name put in tseries for the second one and boom you now have both of your counters.

Note* Yes this works for any YouTube channel so you could track your own subscribers if you wanted, but I have had issues to where really small channels do not report back subscribers.

The name field just has to change to the name that was first associated with the channel. So go straight to the channel and look at the link. It will say youtube.com/user/NAME
The name there is the official name and paste that into where it says name in the script.

Screenshots