tfabris / CrowCam

A set of Bash scripts to control and maintain a YouTube live cam from a Synology NAS.
GNU General Public License v3.0
4 stars 3 forks source link

Make fewer YouTube API queries (hopefully help quota issue). #29

Closed tfabris closed 5 years ago

tfabris commented 5 years ago

I busted a 10,000-per-day YouTube API quota today.

There are some spots in my code which are related to calling of the YouTube API which will continue to hammer the server with queries even if the authentication failed or some variables were not retreived. For example, if I fail to get the accessToken or the boundStreamId, I keep continuing with the queries and just let them fail.

I'm not certain if these contribute to my quota busting. But whether they do or not, it's lazy programming from one point of view (from another point of view, it simplifies the code and makes it easier to read but whatever).

In any case, I need to fix this so that it correctly reports an API call failure and then stops querying for more API data if so. This is going to complicate the code where I need it to keep falling through instead of failing out but it's important.

Monitor your quota usage here: https://console.developers.google.com/apis/api/youtube.googleapis.com/quotas?project=crowcam

tfabris commented 5 years ago

Also trying the following fixes:

tfabris commented 5 years ago

Checked in new code: Attempt to address issues #23 and #29:

Need to test this on production system and see how it does for a day.

tfabris commented 5 years ago

Final script timing, results in a quota usage of 1/4 of my total per day. Closing bug as fixed.