Skip to content

Commit c6b2695

Browse files
authored
Merge pull request #2766 from adafruit/dhalbert-patch-2
PyPortal_Youtube: get youtube token from settings.toml
2 parents f92d93d + 34a9f51 commit c6b2695

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

PyPortal/PyPortal_Youtube/code.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,19 @@
99
1010
Requires a youtube API key!
1111
"""
12+
import os
1213
import time
1314
import board
1415
from adafruit_pyportal import PyPortal
1516

16-
# Get wifi details and more from a secrets.py file
17-
try:
18-
from secrets import secrets
19-
except ImportError:
20-
print("WiFi secrets are kept in secrets.py, please add them there!")
21-
raise
22-
2317
# Set up where we'll be fetching data from
2418
CHANNEL_ID = "UCpOlOeQjj7EsVnDh3zuCgsA" # this isn't a secret but you have to look it up
2519
#CHANNEL_ID = "UC6p-tjZN8s9GBSbiN4K-bwg"
2620
CAPTION = "www.youtube.com/adafruit"
2721
#CAPTION = "www.youtube.com/c/JohnParkMakes"
2822

2923
# pylint: disable=line-too-long
30-
DATA_SOURCE = "https://www.googleapis.com/youtube/v3/channels/?part=statistics&id="+CHANNEL_ID+"&key="+secrets['youtube_token']
24+
DATA_SOURCE = "https://www.googleapis.com/youtube/v3/channels/?part=statistics&id="+CHANNEL_ID+"&key="+os.getenv("YOUTUBE_TOKEN")
3125
DATA_LOCATION1 = ["items", 0, "statistics", "viewCount"]
3226
DATA_LOCATION2 = ["items", 0, "statistics", "subscriberCount"]
3327
# pylint: enable=line-too-long

0 commit comments

Comments
 (0)