Commit 777f7252 authored by Alp Deniz Ogut's avatar Alp Deniz Ogut
Browse files

Limit number of imported images by default

parent 35ff1222
Pipeline #15210 passed with stages
in 1 minute and 43 seconds
Showing with 5 additions and 2 deletions
+5 -2
......@@ -17,4 +17,5 @@ ACTION_COMPLETED = "action_completed"
SUCCESS = "success"
FAIL = "fail"
AUTH_TIMEOUT = 120
\ No newline at end of file
AUTH_TIMEOUT = 120
IMPORT_LIMIT = os.environ.get("IMPORT_LIMIT", 100)
\ No newline at end of file
......@@ -16,7 +16,7 @@ from google_photos.data.schema import (
AuthenticationFlow,
)
from pymemri.plugin.pluginbase import PluginBase
from .constants import SERVICE_NAME, CLIENT_ID, CLIENT_SECRET, PROJECT_ID
from .constants import SERVICE_NAME, CLIENT_ID, CLIENT_SECRET, PROJECT_ID, IMPORT_LIMIT
from .constants import IMAGE_FORMATS, VIDEO_FORMATS, THUMBNAIL_DIM
from .constants import AWAIT_USER_ACTION, ACTION_COMPLETED, SUCCESS, FAIL, AUTH_TIMEOUT
......@@ -323,6 +323,8 @@ class GooglePhotos(PluginBase):
if "mediaItems" in items:
self.number_of_images = len(items['mediaItems'])
logger.info(f"Service has {self.number_of_images} images")
if IMPORT_LIMIT:
items["mediaItems"] = items["mediaItems"][:int(IMPORT_LIMIT)]
for item in items["mediaItems"]:
executor.submit(self.import_media_file, item)
executor.shutdown()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment