hermanho / MMM-GooglePhotos

Display your photos on MagicMirror from Google Photos.
MIT License
162 stars 62 forks source link

GPhotos module doesnt download Albums with more than one page fetch #187

Closed lerasmo closed 3 months ago

lerasmo commented 3 months ago

I was using the MMM, The module works fine when is less than 50 photos in the album, but with larger albums I get this error:

[09.03.2024 23:01.08.389] [INFO] Albums: my_album [09.03.2024 23:01.10.244] [ERROR] Trace: [GPHOTOS:CORE] request fail with URL mediaItems:search at GPhotos.logTrace (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:128:13) at GPhotos.request (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:169:12) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async getImage (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:249:24) at async Class.getImageList (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:326:20) at async Class.scanJob (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:230:23) [09.03.2024 23:01.10.246] [ERROR] Trace: [GPHOTOS:CORE] params null at GPhotos.logTrace (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:128:13) at GPhotos.request (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:170:12) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async getImage (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:249:24) at async Class.getImageList (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:326:20) at async Class.scanJob (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:230:23) [09.03.2024 23:01.10.248] [ERROR] Trace: [GPHOTOS:CORE] data {"albumId":"ABVpo..an ID...siB","pageSize":50,"pageToken":"CpgBCkR0eXB.....a Long Token.....aGM"} at GPhotos.logTrace (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:128:13) at GPhotos.request (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:171:12) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async getImage (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:249:24) at async Class.getImageList (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:326:20) at async Class.scanJob (/home/orangepi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:230:23) [09.03.2024 23:01.10.250] [ERROR] [GPHOTOS:CORE] response.data: {"error":{"code":400,"message":"**When using a page token, you must use the same parameters as the previous request**.","status":"INVALID_ARGUMENT"}}

I think is about: When using a page token, you must use the same parameters as the previous with the token change in every album page (nextPageToken) of GPhotos.js, but my APIs skills aren't enough to fix the issue. Thanks

lerasmo commented 3 months ago

ok, changing the page size in:

GPhotos.js:241 const getImage = async (pageSize = 100, pageToken = "") => {

to pageSize = 50

fixed the issue