xob0t / Google-Photos-Toolkit

Userscript to filter, search, organize, or delete your Google Photos library
MIT License
78 stars 3 forks source link

Adding photos to shared albums does not work for me #11

Closed oryjkov closed 2 weeks ago

oryjkov commented 3 weeks ago

I realized that adding to shared albums is not working at the moment. I believe the problem is in function addItemsToAlbum which is using an rpcid that differs from what google photos UI uses when adding photo to shared albums.

google photos uses rpcid = 'laUYf' when adding to shared albums and rpcid = 'E1Cajb' when adding to non-shared albums.

The following code works for me to add photos to shared albums (request parameters are also different) .

  async addItemsToSharedAlbum(productIdList, albumId = null, albumName = null) {
    // supply album ID for adding to an existing album, or a name for a new one
    const rpcid = 'laUYf';
    let requestData = null;

    if (albumName) requestData = [productIdList, null, albumName];
    else if (albumId) requestData = [albumId, [2, null, productIdList.map(id => [[id]]), null, null, null, [1]]];

    try {
      const response = await this.makeApiRequest(rpcid, requestData);
      return response;
    } catch (error) {
      console.error('Error in addItemsToSharedAlbum:', error);
      throw error;
    }
  }