From 2d3ba940daa5a6462e0efb19cc00ef79f56060b3 Mon Sep 17 00:00:00 2001 From: MikeGawi Date: Tue, 2 Jan 2024 19:07:07 +0100 Subject: [PATCH] Preventing Google Photos API limit from being exceeded #92 --- .gitignore | 2 +- config.cfg | 2 +- ePiframe.py | 6 +++--- install.sh | 2 +- requirements.txt | 1 - 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 99cf360..63b38ed 100644 --- a/.gitignore +++ b/.gitignore @@ -144,4 +144,4 @@ dmypy.json /photo_thumb.jpg /gen_cc_badge.py /webtest.py -/list.fth +/list.pickle diff --git a/config.cfg b/config.cfg index b8da250..ec74c6d 100644 --- a/config.cfg +++ b/config.cfg @@ -27,7 +27,7 @@ album_names= # Possible values: always = every frame refresh, once = once a day. # This is to prevent a large number of photos from hitting the daily API limit (10k calls). # Default: always -refresh_rate=always +refresh_rate=once # Set 1 to get photos from local storage. ; The rest of the values in this section regarding local should be filled as well when enabled. diff --git a/ePiframe.py b/ePiframe.py index 63a436c..216d872 100755 --- a/ePiframe.py +++ b/ePiframe.py @@ -411,7 +411,7 @@ def should_data_be_refreshed(filename: str) -> bool: def read_stored_photos(self): photos = DataFrame() - filename: str = self.config.get("photo_list_file") + ".fth" + filename: str = self.config.get("photo_list_file") + ".pickle" should_refresh: bool = self.should_data_be_refreshed(filename) if ( self.config.get("refresh_rate") == Constants.REFRESH_ONCE @@ -423,7 +423,7 @@ def read_stored_photos(self): "Trying to read saved Google Photos data (according to refresh_rate setting set to " "'once' a day)..." ) - photos = pandas.read_feather(filename) + photos = pandas.read_pickle(filename) self.logging.log("Success!") except Exception: pass @@ -570,7 +570,7 @@ def get_google_source(self) -> DataFrame: ) self.logging.log("Success!") if not photos.empty: - photos.to_feather(self.config.get("photo_list_file") + ".fth") + photos.to_pickle(self.config.get("photo_list_file") + ".pickle") return photos def get_local_source(self, photos: DataFrame) -> DataFrame: diff --git a/install.sh b/install.sh index 24915f6..fa1b10a 100755 --- a/install.sh +++ b/install.sh @@ -46,7 +46,7 @@ function install_pips { echo -e '\n\033[0;30mInstalling Python components\033[0m' declare -A pips=( ["Requests"]="requests>=2.26.0" ["Pillow"]="pillow==9.3.0" ["Telebot"]="pyTelegramBotAPI" ["Dateutil"]="python-dateutil" ["ConfigParser"]="configparser>=5.0.0"\ ["Google components"]="google-api-python-client google-auth-httplib2 google-auth-oauthlib"\ - ["SPI Libs"]="spidev==3.5" ["Pandas"]="pandas==1.2.0 numpy==1.20 pyarrow" ["Flask"]="flask<2.2.0" ["Flask-WTF"]="flask-wtf==1.0.0" \ + ["SPI Libs"]="spidev==3.5" ["Pandas"]="pandas==1.2.0 numpy==1.20" ["Flask"]="flask<2.2.0" ["Flask-WTF"]="flask-wtf==1.0.0" \ ["Flask-Login"]="flask-login==0.5.0" ["WTForms"]="wtforms>=3.0.0" ["SMBus"]="smbus2") declare -a order; order+=( "Requests" ) diff --git a/requirements.txt b/requirements.txt index d4e7c01..2b559e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,6 @@ werkzeug==2.0.3 flask-wtf==1.0.0 flask-login==0.5.0 wtforms==3.0.1 -pyarrow==14.0.2 pytest starlette google-api-python-client