【问题标题】:Google Photos API - media items without albumsGoogle Photos API - 没有相册的媒体项目
【发布时间】:2021-02-14 23:02:35
【问题描述】:

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

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

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

【问题讨论】:

    标签: google-photos-api


    【解决方案1】:

    我最终在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 Photos REST API 过滤掉共享项目,但目前这似乎不可能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-11
      • 2019-02-16
      • 2019-07-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多