1

I have used the following script which brings back about 90 albums with URLs. BUT, I then have to page down a few and repeat and this brings back a few more. With 800 odd albums this takes a long while. Does any know how to get back all the albums at once?

Executed on the page https://photos.google.com/albums, this script returns a string that can be copy-pasted to a Google Sheet, creating a table of names and URLs.

var links = document.getElementsByTagName('A');
var s = '';
for (var i = 0; i < links.length; i++) {
  let link = links[i];
  if (/\b\d+ items\b/.test(link.innerText)) {
    let divs = link.getElementsByTagName('DIV');
    for (var j = 0; j < divs.length; j++) {
      let div = divs[j];
      let text = div.innerText;
      if (text != "" && div.childElementCount == 0 && ! /\b\d+ items\b/.test(text)) {
        s = s + text + '\t' + link.href + '\n';
        break;
      }
    }
  }
}
s;

3 Answers 3

0

Two ways to do this.

  1. Google Takeout will generate an HTML inside the takeout archives which have the album URL.
  2. (Recommended) Use rclone's Google Photos wrapper to programmatically fetch this info. https://rclone.org/googlephotos/#albums
2
  • Could you add a bit more guidance on the use of rclone. I successfully configured my Google Photos access but I cannot find a way to list all albums with their URLs. The main function to list albums is "lsd" but it only shows the name, not the URL.
    – jmbouffard
    Sep 21, 2023 at 15:28
  • @jmbouffard, would you mind posting this on rclone forums? rclone's devs etc are verrrry responsive and open to feedback if you'd like to expose the URL. If the API provides it, i'm sure they'd be willing to expose it in rclone's commands Dec 24, 2023 at 6:03
0

The best option that I found to list all of my Google Albums was with the albums.list method from the Google Photos API located here:

https://developers.google.com/photos/library/reference/rest/v1/albums/list

The API method can be called right from the web page and will return a JSON string listing your albums. The main limitation is that the API will only return a maximum of 50 albums at a time but the "nextPageToken" value returned lets you call the method multiple times to get the complete set of albums.

Ideally, one could use Powershell or Python (or other) to automate the API calls and get the full list of albums in one script.

Once I had all the JSON lists from the multiple calls, I integrated them into a unique JSON "albums" in a simple text editor and I used PowerShell to script the parsing of the JSON to a .CSV file that I could use in LibreOffice Calc (or Excel). The parsing of the JSON file for PowerShell is provided here:

$t = Get-Content -Encoding UTF8 -Raw Albums_API_clean.json | ConvertFrom-Json
$i = 0
echo "title;mediaItemsCount;productUrl" > Albums_API_clean.csv
while($i -ne $t.albums.Count) {
  echo $t.albums[$i].title
  echo ($t.albums[$i].title + ";" + $t.albums[$i].mediaItemsCount + ";" + t.albums[$i].productUrl) >> Albums_API_clean.csv
  $i++
}

What this solution does not provide is the listing of the shared URL for each of the albums. In my case all of my albums are shared albums so I would like to be able to replicate the exact same process listed here but with the shared URL instead. I did not find a way to do this from the Google Photos API unfortunately.

0

Did you see this page? List library contents, albums, and media items:

Listing shared albums

You can retrieve a list of all albums that the user has shared or that have been shared with a user. This is similar to the Sharing tab in the Google Photos app.

Shared albums that the user has added to their Google Photos library are also returned in the listing albums call. Make the following call to list shared albums through the Library API:

GET https://photoslibrary.googleapis.com/v1/sharedAlbums

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.