Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-photos-album-image-url-fetch

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-photos-album-image-url-fetch

extract public image url from google photos shared album url

  • 3.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

google-photos-album-image-url-fetch

Node CI FOSSA Status

GooglePhotosAlbum.fetchImageUrls

extract public image url from shared album url

You can also use AbortSignal to cancel Request by pass to 2nd argument.

import * as GooglePhotosAlbum from '../src/index';
const main = async () => {
  const re = await GooglePhotosAlbum.fetchImageUrls('https://photos.app.goo.gl/QCXy6XaKX5x1AynH8');
  console.log(JSON.stringify(re, null, 2));
};
main().catch(er => console.error(er));

output example(see "Notice: Currently, there are two format of url" section)

[
  {
    "uid": "AF1QipO4_Y5pseqWDPSlY7AAo0wmg76xW4gX0kOz8-p_",
    "url": "https://lh3.googleusercontent.com/Pt3C6874cqkfeuIVL0XZ-UCsC6zLzeQmxq7T9-sDiPhyAgvJiKl_SCrvrMMkpuWuZ1TFkU65ilaZJrCbePRYo1q1qGTYvFV6J8gbYfZhhxQuXm2zXx6QDQkj0K-uBBUzozw7YLYQ5g",
    "width": 640,
    "height": 480,
    "imageUpdateDate": 1317552314000,
    "albumAddDate": 1564229558506
  },
  {
    "uid": "AF1QipNcKcm3bkXUXl3tNYFNTlBDZfKUqvvV3JJi8MVJ",
    "url": "https://lh3.googleusercontent.com/Sl8wPPURFbFINwqgcEywOnpUk8sksgGKJI25Wtl885abhMoGHrxZh_qEe26bQmfv1OAG4ZX8qkz1svnLSJJZjh317TuU4cTk1vN04MbucjU8mlX7uDy0CPxVe8gggL-ftx6VgqWYxA",
    "width": 4000,
    "height": 3000,
    "imageUpdateDate": 1535348376000,
    "albumAddDate": 1565370026893
  },
  {
    "uid": "AF1QipNxMqbkMWKWOYGGwFwE4X9vOoGsn-L8BlwArcOQ",
    "url": "https://lh3.googleusercontent.com/i9DN1Lz7ft-oo-_Ubrprm8m4XyrI0sDpd5QFBlsNCV2FrWR2KYE95zLgPYSWcqdodGkCMEv7QZOIvRgfRqjlYLrfHQmGlQosTlvfYV8LcpyllenyOpJcgY-qRFN1wTjfZ-yQ-mzqjw",
    "width": 128,
    "height": 128,
    "imageUpdateDate": 1542123494000,
    "albumAddDate": 1565369489286
  },
  {
    "uid": "AF1QipNJ-9aWE3ufONJlqwUezKHj6u-fzMnT5_6XHppY",
    "url": "https://lh3.googleusercontent.com/ivJw0PWcKAIhffUa-1UMK75EMX7LQJ9CEwogzCpdZaFMw9_QcxKkWTiw74we5_0gW3dbFh2CRF60kngwc2tqtdy0r54VeEcSi-l77Jabr8QPP8IGUW3gfT6lFzR6RD8K0lpTFbT0Tw",
    "width": 2560,
    "height": 1920,
    "imageUpdateDate": 1561102312000,
    "albumAddDate": 1565372213085
  },
  {
    "uid": "AF1QipPPgtqCsxCboAH8XkEJeUOFsL0FT1PakyZwkODX",
    "url": "https://lh3.googleusercontent.com/W8s1YRbVDCzZB1MBkp9civLlO-nW5VODxaSkov4RAxI-rKxUaQou1vaTr1x1Upd_fv1jAEw-g8wACiQcKtJ2ZqlBtIYP-vHkr16Zl3BRU9K_1JsfTQ0ws5LDBptBHFlPAdwUh5NBCg",
    "width": 1920,
    "height": 835,
    "imageUpdateDate": 1564142679000,
    "albumAddDate": 1564149961764
  }
]

Unlike the base URLs which can get via google photos api, url is not temporally.

imageUpdateDate and albumAddDate are Unix epoch time.

By default the url retrieve a small version of the image, to retrieve it to a specific dimension just append to the url =wXXX-hXXX where XXX are the dimensions

Fetching all pictures in full dimensions would be:

let pics = await GooglePhotosAlbum.fetchImageUrls(albums[i]);
pics.forEach(pic => {
  fetch(`${pic.url}=w${pic.width}-h${pic.height}`);
});

GooglePhotosAlbum.extractAppended

When you use this library with Google Photos API, you will want to call GooglePhotosAlbum.fetchImageUrls multiple times to get the differences.

To extract new Image info created via batchCreate of Google Photos API,
you can use GooglePhotosAlbum.extractAppended.

import * as GooglePhotosAlbum from '../src/index';
const main = async () => {
  const before = await GooglePhotosAlbum.fetchImageUrls('https://photos.app.goo.gl/QCXy6XaKX5x1AynH8');
  // call batchCreate API
  const after = await GooglePhotosAlbum.fetchImageUrls('https://photos.app.goo.gl/QCXy6XaKX5x1AynH8');
  const appended = GooglePhotosAlbum.extractAppended(before, after);
  console.log(JSON.stringify(appended, null, 2));
};
main().catch(er => console.error(er));

url is really valid forever?

To prove url is not temporally, we create a cron job on Travis CI. That is proving that url is not temporally while the badge is green.

Build Status

The Hydrangea macrophylla flower picture shown below is also proving that.

![format-1](https://lh3.googleusercontent.com/ivJw0PWcKAIhffUa-1UMK75EMX7LQJ9CEwogzCpdZaFMw9_QcxKkWTiw74we5_0gW3dbFh2CRF60kngwc2tqtdy0r54VeEcSi-l77Jabr8QPP8IGUW3gfT6lFzR6RD8K0lpTFbT0Tw)

![format-2](https://lh3.googleusercontent.com/pw/AL9nZEVCkd_5McMGTASxXDATcHabzpXxroM4D7A3qfk13tF0_IiixjIrVWf_HyPak8LPhrOJ_5t8911M4btRzYMnkrWKdFFGBLFG4Ksyes2WLO-RlHqPZu8)

format-1

format-2

Notice: There are multiple url formats

As far as I detected via CI shown above, there are multiple formats of url like below:

I cannot find the way to specify the format. See #19, #23.

License

FOSSA Status

Keywords

FAQs

Package last updated on 14 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc