我尝试使用mediaItems().search()
方法,使用以下主体:
body = {
"pageToken": page_token if page_token != "" else "",
"pageSize": 100,
"filters": {
"contentFilter": {
"includedContentCategories": {"LANDSCAPES","CITYSCAPES"}
}
},
"includeArchiveMedia": include_archive
}
但问题是,集合{"LANDSCAPES","CITYSCAPES"}
实际上应该是一组枚举(如Java枚举),而不是我编写的字符串。这在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) ] }
在python中有解决这个问题的正确方法吗
修改点:
albumId
和filters
时,发生The album ID cannot be set if filters are used.
错误。因此,当您想使用filters
时,请删除albumId
李>includedContentCategories
的值是一个数组,如下所示。"includedContentCategories": ["LANDSCAPES","CITYSCAPES"]
includeArchiveMedia
是includeArchivedMedia
李>filters
中包含includeArchivedMedia
李>当上述各点反映到脚本中时,它将变成如下所示
修改的脚本:
参考资料:
相关问题 更多 >
编程相关推荐