Open branislav-remen opened 2 months ago
Source of the problem is in this function:
async getAllItems(apiMethod, ...args) {
const items = [];
let nextPageId = null;
do {
if (!this.core.isProcessRunning) return;
const page = await apiMethod.call(this.api, ...args, nextPageId);
if (!page?.items) {
log('No items found!', 'error');
return [];
}
items.push(...page.items);
log(`Found ${page.items.length} items`);
nextPageId = page.nextPageId;
} while (nextPageId);
return items;
}
For some (for me unknown) reason page
contains nextPageId
. But the next api call returns null.
I've placed this piece of code right after API call to quickfix it.
if (page === null) {
nextPageId = null;
break;
}
Not having this issue, although, I don't have that many albums. You can try it on another GP account.
That seems like a GP bug. GP lists items in pages, if a page has a nextPageId, then the next page exists and has items. In that case the page has the nextPageId, but when script reads the next page, it unexpectedly has no items, so it fails and returns 0 items.
Can be worked around with returning found items it case of an error.
return [];
-> return items;
But that may introduce a scenario, when if something goes wrong (say, while reading the library), script prints an error, then just continues to process the incomplete data.
It'd be good to ask a user what to do, maybe an alert asking if it should ignore the error.
@branislav-remen i've added an "ignore errors" checkbox, do you still have this error, can you test if that fixes it? Its in the advanced settings https://github.com/xob0t/Google-Photos-Toolkit/raw/ignore-errors/google_photos_toolkit.user.js
I've had the same issue as @branislav-remen. After attempting a quick fix about 80% of the albums load. Like you say, the request includes a next page ID but doesn't include any results for some reason. I suspect this page would have had the left over 20% albums.
I have about 50 albums.
Looks like it depends on the page size and album count. By default albums page size is 100, same as used by GP itself. On my main GP account I have 53 albums, no issues getting them all with page size 100. If I change page size to 10, It gets all of them, but the last page will have nextPageId even though it should not. Setting page size to 9, and it all works fine as it was. Creating an empty album so the total is 54 and setting page size to 10 also works. Having 54 albums and setting page to 4 gets all but 1 of them, then errors on the empty page.
I'll remove if (!page?.items)
check in the next update, meanwhile, try creating an empty album or two, maybe it'll fix it for you.
Hello,
IS:
SHOULD:
Notes: Yesterday it worked. List of albums was visible. I've created 2-3 albums using GPT. Today I removed these albums and refershed list of the Albums. No Albums are visible now. I don't see errors in console. Network calls ends with OK code (Responses make no sense to me). I've tried to clear storage/cookies, reload userscript/browser, log-in/out. Could you try to reproduce it? Thank you.
LOG: