如何获取相应的Google照片ID和Google文件?

时间:2019-01-12 06:55:04

标签: google-api google-drive-api google-python-api

用户可以选择将其Google相册显示为Google云端硬盘中的文件夹。删除云端硬盘中的照片会删除照片,反之亦然(相册和其他陷阱除外)。有关详细信息,请参见https://support.google.com/photos/answer/6156103

是否可以通过API获得照片mediaItem resource和云端硬盘files resource之间的对应关系?

我已经做过幼稚的事情:在两者中查找匹配的ID和嵌入的ID。没运气。 API的示例返回值如下所示。 (对ID和URL进行了轻微调整,使其无法正常工作。)

示例mediaItem:

{'id': 'APyCggKCjFW9fw_WJwaa5OUXE4Yp9nO2xk1Srkm9Eb-mA9l2pXRAy4oihnPfcAbez7',
 'productUrl': 'https://photos.google.com/lr/album/APyCggJA4K-E0UOQMMAtnShqRVdP057VPEROpkqN2FYZcoVd4v8iz_3bu/photo/APyCggKCjFa8g5W9fw_WJwaaQObO2xk1Srk6Eb-mA9l2pXRAy4oihnPfcAbez7',
 'baseUrl': 'https://lh3.googleusercontent.com/lr/AJ-EwvnNBVMKbifgSTnqRPr0qpKpiTE46ONto1IIq3ALLBMQFE14-PEzwTRRwuX0ym35ZIQFavk2HmbyMYtnzElMxoXxQpHOQqot1e-Uh1Y6WzcyPoRnenA1xDwwsnPugsnK0vRdoEPiBMNF25NTnNZ8m7F4Za0Xd-b1FbIYow4BrIFAlKwPfv5g8-tk8CaNoOOTmL5TVoDfJwcOyD7McFdOm4dN-731itNxaYonVF5WVw66-aqQxKRvd-P6HFZ7b_bQQxB9foQLFdOLqVWmF2Jpp5ep801--ekkZF7wSQw-7obcqXLfqi9ieW_OWSjMOh77nkqMwdQ9dhXJ-XgfdDsuzZRrft8338nKsiGyt9EgNT4a26k7A1y9G2phCKFYO7O8Rwhs_uRuX4Lc6c3Tbng_VEt5cTiWO_OiMddGyyWRR4d9gWLTAYeNTDqFHO_0ZhEYjcwbYmBvzgY7Pg1wOxtPj3WtZXXRf5AvpKEOmhHiaIeEh0rwFAbde0E1NBbB7tNm4YOq_YIIxjKnaN4v0OsghB6ah3nVNwVxIszrTCR6DgGCFOCEgJyETLLAmi8aUDDhoyzGqCtpiPZ3FeFozIeimeGbvLTiefjo-39Fiiuc7_vSKFkgOAnDq-gDhRDvwO4SoPm4JrD_4YbTkb_1rmf8Iv26lCplEJJxM4g0_b6MrvE4JEI5uyOf01Rk_Am5v7s7piOdsmAHr7pKVorY3EhU5ezNAgzye9V2Is9cuK2ALQOG17UyH9sxWlHPxtDLKV2Ur8gfem0bqzO2WNjMn_rX_Q27W',
 'mimeType': 'image/jpeg',
 'mediaMetadata': {'creationTime': '2018-12-25T15:28:26Z',
  'width': '2448',
  'height': '3264',
  'photo': {'cameraMake': 'Apple',
   'cameraModel': 'iPhone 6 Plus',
   'focalLength': 4.15,
   'apertureFNumber': 2.2,
   'isoEquivalent': 32}},
 'filename': 'IMG_0924.JPG'}

示例文件:

{'kind': 'drive#file',
 'id': '1XXkAo-AL7PXBXNpS27cGBCsHvHOaCtXBgQ',
 'name': 'IMG_0924.JPG',
 'mimeType': 'image/jpeg',
 'description': '',
 'starred': False,
 'trashed': False,
 'explicitlyTrashed': False,
 'parents': ['jpWRoFkPQ0mg'],
 'spaces': ['photos', 'drive'],
 'version': '2',
 'webContentLink': 'https://drive.google.com/a/bogus.com/uc?id=1XXkAo-AL77cGBCsHvHOaCtXBgQ&export=download',
 'webViewLink': 'https://drive.google.com/a/bogus.com/file/d/1XXkAo-AL77cGBCsHvHOaCtXBgQ/view?usp=drivesdk',
 'iconLink': 'https://drive-thirdparty.googleusercontent.com/16/type/image/jpeg',
 'hasThumbnail': True,
 'thumbnailLink': 'https://lh3.googleusercontent.com/zxSXO-GJkKmVVejNzEYreyx7_wEddrq2VPWsVSCFRdRfiVdI5--oWm00=s220',
 'thumbnailVersion': '1',
 'viewedByMe': False,
 'createdTime': '2018-12-25T15:28:26.000Z',
 'modifiedTime': '2019-01-06T16:56:08.000Z',
 'modifiedByMeTime': '2019-01-06T16:56:08.000Z',
 'modifiedByMe': True,
 'owners': [{'kind': 'drive#user',
   'displayName': 'Reece Hart',
   'photoLink': 'https://lh5.googleusercontent.com/-QYk9j/AAAAAAI/AAAAOFo/PC9sT/s64/photo.jpg',
   'me': True,
   'permissionId': '03329584261458389005',
   'emailAddress': 'reece@bogus.com'}],
 'lastModifyingUser': {'kind': 'drive#user',
  'displayName': 'Reece Hart',
  'photoLink': 'https://lh5.googleusercontent.com/-QYk9i9j/AAAAAAI/AAAAOFo/PC9j/s64/photo.jpg',
  'me': True,
  'permissionId': '03329584261458389005',
  'emailAddress': 'reece@bogus.com'},
 'shared': False,
 'ownedByMe': True,
 'capabilities': {'canAddChildren': False,
  'canChangeCopyRequiresWriterPermission': True,
  'canChangeViewersCanCopyContent': True,
  'canComment': True,
  'canCopy': True,
  'canDelete': True,
  'canDownload': True,
  'canEdit': True,
  'canListChildren': False,
  'canMoveItemIntoTeamDrive': False,
  'canReadRevisions': True,
  'canRemoveChildren': False,
  'canRename': True,
  'canShare': True,
  'canTrash': True,
  'canUntrash': True},
 'viewersCanCopyContent': True,
 'copyRequiresWriterPermission': False,
 'writersCanShare': True,
 'permissions': [{'kind': 'drive#permission',
   'id': '03329584261458389005',
   'type': 'user',
   'emailAddress': 'reece@bogus.com',
   'role': 'owner',
   'displayName': 'Reece Hart',
   'photoLink': 'https://lh5.googleusercontent.com/-QYk9i9/AAAAA/AAAA/PC9jsT/s64/photo.jpg',
   'deleted': False}],
 'permissionIds': ['03329584261'],
 'originalFilename': 'IMG_0924.JPG',
 'fullFileExtension': 'JPG',
 'fileExtension': 'JPG',
 'md5Checksum': '7ffdb3f36ba89bcad4b7e3b40a6ef356',
 'size': '116216',
 'quotaBytesUsed': '0',
 'headRevisionId': '1gSdsharFji-NH3dDz9AitkOycA',
 'imageMediaMetadata': {'width': 1200,
  'height': 1600,
  'rotation': 0,
  'location': {'latitude': 37.72585277777778,
   'longitude': -122.41243611111112,
   'altitude': 1075.620606060606},
  'colorSpace': 'sRGB'},
 'isAppAuthorized': False}

1 个答案:

答案 0 :(得分:0)

Google Photos and Google Drive no longer sync至2019年7月10日开始,因此云端硬盘和照片中的照片之间不再存在任何对应关系,它们是完全独立的实体。

但是您可以import photos from Google Drive to Google Photos