I'm trying to use the mediaItems().search()
method, using the following body:
body = {
"pageToken": page_token if page_token != "" else "",
"pageSize": 100,
"filters": {
"contentFilter": {
"includedContentCategories": {"LANDSCAPES","CITYSCAPES"}
}
},
"includeArchiveMedia": include_archive
}
but the problem is that the set {"LANDSCAPES","CITYSCAPES"}
should actually be a set of enums (as in Java enums), and not strings as ive written. this is specified in the API: (https://developers.google.com/photos/library/reference/rest/v1/albums)
ContentFilter - This filter allows you to return media items based on the content type.
JSON representation
{ "includedContentCategories": [ enum (ContentCategory) ], "excludedContentCategories": [ enum (ContentCategory) ] }
is there a proper way of solving this in python?
Modification points:
albumId
andfilters
are used, an error ofThe album ID cannot be set if filters are used.
occurs. So when you want to usefilters
, please removealbumId
.includedContentCategories
is an array as follows."includedContentCategories": ["LANDSCAPES","CITYSCAPES"]
includeArchiveMedia
isincludeArchivedMedia
.includeArchivedMedia
infilters
.When above points are reflected to your script, it becomes as follows.
Modified script:
Reference: