示例#1
0
def showYoutubeStats(channelId):

    global rootDirectory
    global statusNeopixel
    global setBackground
    global jsonTraverse
    global board
    global collegiateFont
    global primaryDisplayGroup

    url = "https://www.googleapis.com/youtube/v3/channels/?part=statistics&id=" + channelId + "&key=" + secrets['youtube_token']
    countJsonPropPath = ["items", 0, "statistics", "viewCount"]
    count2JsonPropPath = ["items", 0, "statistics", "subscriberCount"]

    # get data from url
    statusNeopixel.fill((100, 100, 0))   # yellow = fetching data
    gc.collect()
    r = requests.get(url)
    gc.collect()
    statusNeopixel.fill((0, 0, 100))   # green = got data
    jsonData = r.json()
    r.close()
    gc.collect()

    count = jsonTraverse(jsonData, countJsonPropPath)
    count2 = jsonTraverse(jsonData, count2JsonPropPath)

    # display data
    countLabel = Label(collegiateFont, text=str(count))
    countLabel.x = 100
    countLabel.y = 129
    countLabel.color = 0xFFFFFF

    countLabel2 = Label(collegiateFont, text=str(count))
    countLabel2.x = 155
    countLabel2.y = 180
    countLabel2.color = 0xFFFFFF

    primaryDisplayGroup.append(countLabel)
    primaryDisplayGroup.append(countLabel2)

    # load github stat background
    setBackground(rootDirectory + "/youtube_background.bmp")

    # wait
    time.sleep(60)

    # cleanup!
    while countLabel:
        countLabel.pop()

    while countLabel2:
        countLabel.pop()
示例#2
0
def showRedditStats(subreddit):

    global rootDirectory
    global statusNeopixel
    global setBackground
    global jsonTraverse
    global board
    global collegiateFont
    global primaryDisplayGroup

    url = "https://www.reddit.com/r/" + subreddit + "/about.json"
    countJsonPropPath = ["data", "subscribers"]

    # get data from url
    statusNeopixel.fill((100, 100, 0))   # yellow = fetching data
    gc.collect()
    r = requests.get(url)
    gc.collect()
    statusNeopixel.fill((0, 0, 100))   # green = got data
    jsonData = r.json()
    r.close()
    gc.collect()

    count = jsonTraverse(jsonData, countJsonPropPath)

    # display data
    countLabel = Label(collegiateFont, text=str(count))
    countLabel.x = 200
    countLabel.y = 100
    countLabel.color = 0xFFFFFF
    primaryDisplayGroup.append(countLabel)

    # load github stat background
    setBackground(rootDirectory + "/reddit_background.bmp")

    # wait
    time.sleep(60)

    # cleanup!
    while countLabel:
        countLabel.pop()
示例#3
0
def showTwitterStats(twitterName):

    global rootDirectory
    global statusNeopixel
    global setBackground
    global jsonTraverse
    global board
    global collegiateFont
    global primaryDisplayGroup

    url = "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=" + twitterName
    countJsonPropPath = [0, "followers_count"]

    # get data from url
    statusNeopixel.fill((100, 100, 0))   # yellow = fetching data
    gc.collect()
    r = requests.get(url)
    gc.collect()
    statusNeopixel.fill((0, 0, 100))   # green = got data
    jsonData = r.json()
    r.close()
    gc.collect()

    count = jsonTraverse(jsonData, countJsonPropPath)

    # display data
    countLabel = Label(collegiateFont, text=str(count))
    countLabel.x = 200
    countLabel.y = 100
    countLabel.color = 0xFFFFFF
    primaryDisplayGroup.append(countLabel)

    # load github stat background
    setBackground(rootDirectory + "/twitter_background.bmp")

    # wait
    time.sleep(60)

    # cleanup!
    while countLabel:
        countLabel.pop()
示例#4
0
def showGithubStats(repo):

    global rootDirectory
    global statusNeopixel
    global setBackground
    global jsonTraverse
    global board
    global collegiateFont
    global primaryDisplayGroup

    url = "https://api.github.com/repos" + repo + "?access_token="+secrets['github_token']
    countJsonPropPath = ["stargazers_count"]

    # get data from url
    statusNeopixel.fill((100, 100, 0))   # yellow = fetching data
    gc.collect()
    r = requests.get(url)
    gc.collect()
    statusNeopixel.fill((0, 0, 100))   # green = got data
    jsonData = r.json()
    r.close()
    gc.collect()

    count = jsonTraverse(jsonData, countJsonPropPath)

    # display data
    countLabel = Label(collegiateFont, text=str(count))
    countLabel.x = 200
    countLabel.y = 100
    countLabel.color = 0xFFFFFF
    primaryDisplayGroup.append(countLabel)

    # load github stat background
    setBackground(rootDirectory + "/githubstar.bmp")

    # wait
    time.sleep(60)

    # cleanup!
    while countLabel:
        countLabel.pop()