MikeGawi / ePiframe

ePiframe is an e-Paper (or HDMI, Composite display) Raspberry Pi Photo Frame with Google Photos and more
GNU General Public License v3.0
63 stars 10 forks source link

Preventing Google Photos API limit from being exceeded #92

Closed MikeGawi closed 6 months ago

MikeGawi commented 6 months ago

According to Google Photos API specification:

All requests sent to the Google Photos Library API are counted toward a quota. We put these limits in place to protect the system and its users. ... The quota limit for requests to the Library API is 10,000 requests per project per day.

and this issue(#89) I need to find a way how to minimize number of requests (currently the whole data is taken every frame refresh, 50 items every time /another Google limit/).

MikeGawi commented 6 months ago

The solution is to store downloaded Google Photos API data once a day and then load it when needed. As we have Pandas on board I can use a simple DataFrame dump/load mechanism (Feather format seems to be fast and enough for this). The data will be downloaded at first run every day and then for the rest it will be loaded and reused. The problem is that photos download URLs are expiring but in that case I can refresh it when something like this happens (with two retries). With that refresh requests number will be maximum 2% of the 10k requests limit, leaving the rest for the initial download.

This setting controls this behavior: https://github.com/MikeGawi/ePiframe/blob/master/config.cfg#L30

always = every frame refresh, once = once a day

MikeGawi commented 6 months ago

Fixed in #93