@@ -45,44 +45,44 @@ Take note that the creation of the YoutubeAPI() instance is done using the **wit
45
45
.. code-block :: python
46
46
47
47
from micropython_youtube_api import YoutubeAPI
48
- import network, json, time
48
+ import network, json, time
49
49
50
- # Read config
51
- with open('config.json') as f:
52
- config = json.load(f)
50
+ # Read config
51
+ with open (' config.json' ) as f:
52
+ config = json.load(f)
53
53
54
- # Check config.json has updated credentials
55
- if config['ssid'] == 'Enter_Wifi_SSID':
56
- assert False, ("config.json has not been updated with your unique keys and data")
54
+ # Check config.json has updated credentials
55
+ if config[' ssid' ] == ' Enter_Wifi_SSID' :
56
+ assert False , (" config.json has not been updated with your unique keys and data" )
57
57
58
- # Create WiFi connection and turn it on
59
- wlan = network.WLAN(network.STA_IF)
60
- wlan.active(True)
58
+ # Create WiFi connection and turn it on
59
+ wlan = network.WLAN(network.STA_IF )
60
+ wlan.active(True )
61
61
62
- # Connect to WiFi router
63
- print ("Connecting to WiFi: {}".format( config['ssid'] ) )
64
- wlan.connect( config['ssid'], config['ssid_password'])
62
+ # Connect to WiFi router
63
+ print (" Connecting to WiFi: {} " .format( config[' ssid' ] ) )
64
+ wlan.connect( config[' ssid' ], config[' ssid_password' ])
65
65
66
- # Wait until wifi is connected
67
- while not wlan.isconnected:
68
- pass
66
+ # Wait until wifi is connected
67
+ while not wlan.isconnected:
68
+ pass
69
69
70
- # Create an instance of the YoutubeApi
71
- with YoutubeAPI( config["channelid"], config["appkeyid"], config["query_interval_sec"] ) as data:
70
+ # Create an instance of the YoutubeApi
71
+ with YoutubeAPI( config[" channelid" ], config[" appkeyid" ], config[" query_interval_sec" ] ) as data:
72
72
73
- # Read the data every X seconds
74
- update_interval = 5
75
- update_stats_time = time.time() - 10
73
+ # Read the data every X seconds
74
+ update_interval = 5
75
+ update_stats_time = time.time() - 10
76
76
77
- while True:
77
+ while True :
78
78
79
- if update_stats_time < time.time():
80
- update_stats_time = time.time() + update_interval
79
+ if update_stats_time < time.time():
80
+ update_stats_time = time.time() + update_interval
81
81
82
- print ("Subs {}".format( data.subs ) )
83
- print ("Views {}".format( data.views ) )
84
- print ("Videos {}".format( data.videos ) )
85
- print ("Comments {}".format( data.comments ) )
82
+ print (" Subs {} " .format( data.subs ) )
83
+ print (" Views {} " .format( data.views ) )
84
+ print (" Videos {} " .format( data.videos ) )
85
+ print (" Comments {} " .format( data.comments ) )
86
86
..
87
87
88
88
Getting a Google Apps API key (Required!)
0 commit comments