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

Consider giving a proper error and bail-out if there is a Quota problem. #36

Closed tfabris closed 5 years ago

tfabris commented 5 years ago

The YouTube API has a quota, and if we exceed that quota, all API access is locked until midnight.

If I don't detect this situation when it occurs and do something about it, I'll hammer the API blindly.

I've made the code pretty good and now it uses less than 25% of the total quota in a day, so this isn't an emergency, but it might be nice to handle this gracefully. The trick is that I'd have to write a file to the disk which keeps track of which day I busted the quota, keep the scripts from running on that day, then unlock it once midnight rolls around. This might be more trouble than it's worth and perhaps the 25% usage is fine.

In any case, here's what the error messages look like when it happens:

Error 2019-05-13 19:51:32 CrowCam Controller - The variable streamName came up empty. Error accessing YouTube API
Error 2019-05-13 19:51:32 CrowCam Controller - The liveStreamsOutput was { "error": { "errors": [ { "domain": "youtube.quota", "reason": "quotaExceeded", "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e." } ], "code": 403, "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e." } } .
Error 2019-05-13 19:51:32 CrowCam Controller - Unable to obtain all of the YouTube API stream data for CrowCam live stream - Will not attempt the Stream Key fix procedure.
Error 2019-05-13 19:52:25 CrowCam Controller - The variable streamStatus came up empty. Error accessing YouTube API.
Error 2019-05-13 19:52:25 CrowCam Controller - The liveStreamsOutput was { "error": { "errors": [ { "domain": "youtube.quota", "reason": "quotaExceeded", "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e." } ], "code": 403, "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e." } } .
Error 2019-05-13 19:52:25 CrowCam Controller - The variable healthStatus came up empty. Error accessing YouTube API.
Error 2019-05-13 19:52:25 CrowCam Controller - The liveStreamsOutput was { "error": { "errors": [ { "domain": "youtube.quota", "reason": "quotaExceeded", "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e." } ], "code": 403, "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e." } } .
Info  2019-05-13 19:52:42 CrowCam Controller - The network is up, but the YouTube stream is down. Pausing to give it a chance to come up. Inner stream test loop, retry attempt 1 of 6 . Sleeping 15 seconds before trying again.
Info  2019-05-13 19:53:18 CrowCam Controller - Live stream came back up.
Error 2019-05-13 19:53:23 CrowCam Controller - The variable streamName came up empty. Error accessing YouTube API.
Error 2019-05-13 19:53:23 CrowCam Controller - The liveStreamsOutput was { "error": { "errors": [ { "domain": "youtube.quota", "reason": "quotaExceeded", "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e." } ], "code": 403, "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e." } } .
Error 2019-05-13 19:53:23 CrowCam Controller - Unable to obtain all of the YouTube API stream data for CrowCam live stream - Will not attempt the Stream Key fix procedure.
Error 2019-05-13 19:54:14 CrowCam Controller - The variable boundStreamId came up empty. Error accessing YouTube API. Test_Stream failed.
Error 2019-05-13 19:54:14 CrowCam Controller - The liveBroadcastOutput was { "error": { "errors": [ { "domain": "usageLimits", "reason": "dailyLimitExceeded", "message": "Daily Limit Exceeded. The quota will be reset at midnight Pacific Time (PT). You may monitor your quota usage and adjust limits in the API Console: https://console.developers.google.com/apis/api/youtube.googleapis.com/quotas?project=xxxxxxxxxx", "extendedHelp": "https://console.developers.google.com/apis/api/youtube.googleapis.com/quotas?project=xxxxxxxxx" } ], "code": 403, "message": "Daily Limit Exceeded. The quota will be reset at midnight Pacific Time (PT). You may monitor your quota usage and adjust limits in the API Console: https://console.developers.google.com/apis/api/youtube.googleapis.com/quotas?project=xxxxxxx" } } .
Info  2019-05-13 19:54:32 CrowCam Controller - The network is up, but the YouTube stream is down. Pausing to give it a chance to come up. Inner stream test loop, retry attempt 1 of 6 . Sleeping 15 seconds before trying again.
tfabris commented 5 years ago

This seems to complicated to actually do. Closing this as "won't fix".