Pewdiepie vs T-Series Live Count

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

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


import json
import urllib2

name = "pewdiepie"
key = “your key”

data = urllib2.urlopen(""+name+"&key="+key).read()
subs = json.loads(data)["items"][0]["statistics"]["subscriberCount"]


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
The name there is the official name and paste that into where it says name in the script.


Glad to find someone who has made a guide for this. Unfortunately I wasn't able to get it to work.

I received this error and I saved and restarted BTT, two times:

File "", line 5
key = “ My inserted Google API Key”
SyntaxError: invalid syntax

A couple things I didn't understand in what you wrote. This for example:

"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."

You're talking about Touch Bar and advanced settings as two different things it seems like. Am I missing something?

Are you on one of the more recent versions of BetterTouchTool? I just updated mine after a while and it seems like many things have been moved around. The script is no longer hidden in an advanced settings section if you are using the new configuration UI.

I think I forgot to mention that under the Launch path, where it says Parameters, you should have a "-c".

So after messing with my script and breaking my widget, I have come to the conclusion that the script editor in better touch tool causes some issues. Specifically random characters that are unseen to us are read by the compiler.

To fix my script I did this:

  1. Open TextEdit on your computer
  2. Click on the top left where it says TextEdit > Preferences
  3. Under Format, hit Plain Text
  4. Copy and paste the script from my original post, the one above, into TextEdit
  5. Add your api key into the script, but do this by hand, without copying and pasting
    5b. Also maybe try in TextEdit removing the " key = "api key here" " and retyping the whole line if you get the same error after doing everything else
  6. Copy the script from TextEdit and paste it into BetterTouchTool.
  7. Profit??

If you get a weird error where it says "HTTP Error 400: Bad Request" that means that your API key is not correct. You probably typed a wrong letter somewhere. Edit your script in the TextEdit app, not the editor where you put the script. The editor breaks the script, so do not make any changes in that editor, use TextEdit and just copy and paste again.

If there are still issues, then your last resort should be typing the script out line for line completely in TextEdit and then copying and pasting to the script editor in BetterTouchTool.

Sorry for responding so late, it took me a while to figure out why exactly things weren't working. And hopefully my instructions are clear.

If you can't get it to work I am so sorry, the script does in fact work and it is not the problem, the editor where you put the script in BetterTouchTool seems to be the problem.

Yes I am, I downloaded it perhaps a week ago when I bought my 2019 MB Pro. I will try the new instructions you wrote and see if that works instead and report back!

Got this message now instead:

File "", line 4
name = “ pewdiepie ”
SyntaxError: invalid syntax

That's with pasting the text from TextEdit

I now tried to rewrite the text in its entirety in textEdit and paste it into BTT with no success. I got this message:

File "", line 1
Import json
SyntaxError: invalid syntax

Okay, so that is a syntax error with Python. Idk how familiar you are with coding and Python but just make the letter "I" in import lowercase.

Should be:

import json
import urllib2

followed by the rest of the code. Remember to do all of your edits in TextEdit and then copy and paste over to BetterTouchTool

You might want to download JSON Helper (App Store - FREE).