Skip to content

Instantly share code, notes, and snippets.

@moonhouse
Last active March 6, 2016 23:20
Show Gist options
  • Select an option

  • Save moonhouse/9a35751b07949efdaabe to your computer and use it in GitHub Desktop.

Select an option

Save moonhouse/9a35751b07949efdaabe to your computer and use it in GitHub Desktop.
Print subscriber count from a Youtube channel. Can be used with BitBar. Replace YOURAPIKEY with an actual Youtube API key from https://console.developers.google.com/
#!/bin/sh
curl 'https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UCSGHj0YjencmGUSksbMbBVQ&key=YOURAPIKEY' 2>/dev/null | grep -o '"subscriberCount": "\d*"' | tr -d -c 0-9
@moonhouse

Copy link
Copy Markdown
Author
  • Follow http://help.dimsemenov.com/kb/wordpress-royalslider-tutorials/wp-how-to-get-youtube-api-key for how to get an API key to place after key= in the URL on line 3.
  • Place in the BitBar plugin directory (you need to configure this the first time).
  • In the Terminal and standing in the directory run chmod +x youtube-subscriber.30m.sh
  • Choose Preferences > Refresh all to trigger the first time so you don't have to wait 30 minutes (or whatever you choose, see below).

The .30m. in the filename tells BitBar to refresh the data every 30 minutes (and can be changed to another number).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment