Google Photos API - 没有相册的媒体项目

问题描述

我喜欢 Google 相册,但我注意到它缺少一些基本指标,例如我的帐户中有多少媒体项目。我还想看看我的哪些媒体项目没有包含在我的任何专辑中。我最终使用 Google Photos REST API 创建了一个简单的控制台应用程序。它使用 GET /albumsPOST /mediaItems:search?albumId={id}获取每个专辑的媒体项目,然后将它们与 GET /mediaItems 返回的完整媒体项目列表进行交叉引用。

它运行得相当好,但我注意到共享项目存在问题。对于账号A拥有的共享相册,如果一个媒体项是从另一个账号B中添加的,那么在账号A的媒体项列表中就找不到它的id(这不是不合理)。如果此类共享媒体项保存在帐户 A 中,其 ID 将与添加到共享相册的原始共享媒体项的 ID 不匹配(由 POST /mediaItems:search?albumId={id} 返回)。如果没有某种指标来识别媒体项目是否属于另一个帐户,则很难将其过滤掉。我希望将 contributorInfo 视为 MediaItem 的一部分,但未返回该属性

如果我尝试使用 UI 将同一共享项目的已保存副本添加到相册中,我会收到一条通知消息,表明它已经存在,因此显然 Google 相册 UI 确实包含该信息。有没有人对如何将共享媒体项目的保存副本与原件进行匹配有任何聪明的想法?代码可在 https://github.com/pavelfomin/gphoto-manager

获得

解决方法

我最终在 https://github.com/pavelfomin/gphoto-manager 中使用了 ignore media items 列表,我在本地填充了我想忽略的媒体项:

Usage: com.droidablebee.gphoto.GooglePhotoApplication [options] -token=<access token> [-Dsuppress-warnings] [-Dignore-media-items-file=<file with media items to ignore>]
            --albums           list all albums,sorted by name
            --album-items      list all items per album (use with care for large number of media items)
            --items            list all items (use with care for large number of media items)
            --items-no-album   list all items not included in any album
            <access token>     OAuth 2 Access Token can be obtained from https://developers.google.com/oauthplayground
                               use 'https://www.googleapis.com/auth/photoslibrary.readonly' as the requested scope
            suppress-warnings  suppress all warnings,including album media count / items mismatch 

理想情况下,我会使用 Google 相册 REST API 过滤掉共享项目,但目前似乎不可能。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...