Skip to content

Instantly share code, notes, and snippets.

@D-32
Created December 20, 2016 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save D-32/0098b03b9074047007a21eb4abc0fdc8 to your computer and use it in GitHub Desktop.
Save D-32/0098b03b9074047007a21eb4abc0fdc8 to your computer and use it in GitHub Desktop.
Notify when youtube subscriber count changes
import requests
import json
import time
import os
from datetime import datetime
stat = ""
while True:
r = requests.get("https://www.googleapis.com/youtube/v3/channels?part=statistics&id=$$$CHANNEL_ID$$$&key=$$$YOUR_API_KEY$$$")
j = json.loads(r.content)
newStat = j['items'][0]['statistics']['subscriberCount']
print datetime.now()
print newStat
print "----"
if stat != newStat:
os.system('osascript -e "display notification \"' + newStat + '\""')
stat = newStat
time.sleep(60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment