diff --git a/src/index.mjs b/src/index.mjs index 66093e1..c848962 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -49,8 +49,8 @@ if (!process.env.MW_USERNAME || !process.env.MW_PASSWORD) { const mw = new MediaWikiClient('https://ffxiv.consolegameswiki.com/mediawiki'); await mw.login(process.env.MW_USERNAME, process.env.MW_PASSWORD); -// Get pages in the "Missing EDB ID" category -const itemPagesWithoutEDBIDs = await mw.listCategoryPages('Category:Missing EDB ID', +process.env.LIMIT || 500); +// Get pages in the "Missing EDB ID" category from the main article namespace +const itemPagesWithoutEDBIDs = await mw.listCategoryPages('Category:Missing EDB ID', [0], +process.env.LIMIT || 500); console.log('Processing', itemPagesWithoutEDBIDs.length, 'item pages from [[Category:Missing EDB ID]]\n'); for (const {title} of itemPagesWithoutEDBIDs) { diff --git a/src/mediawiki.mjs b/src/mediawiki.mjs index c13d74f..8128878 100644 --- a/src/mediawiki.mjs +++ b/src/mediawiki.mjs @@ -165,16 +165,23 @@ export class MediaWikiClient { /** * Gets the list of wiki pages that belong to the given category. * @param {string} name Category name including the `Category:` namespace. + * @param {number[] | '*'} namespaces Integer namespace ID(s) or the string + * `'*'`. If namespace IDs are provided, only pages in those namespaces will + * be returned. * @param {string} limit Maximum number of items to return. Must be 500 or * less. I'm lazy and not supporting API paging so deal with it. * @returns {Promise<{pageid: number; title: string}[]>} */ - async listCategoryPages (name, limit = 50) { + async listCategoryPages (name, namespaces = '*', limit = 50) { + if (Array.isArray(namespaces)) { + namespaces = namespaces.join('|'); + } const body = await this.fetchApiGet({ action: 'query', list: 'categorymembers', cmtitle: name, cmlimit: limit, + cmnamespace: namespaces, }); return body.query.categorymembers; }