New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
categorymembers doesn't return files #97
Comments
Currently there is a categorymembers function that does, I believe, what you are looking for. Or is this something different? |
Sorry, I'm not sure how I missed it. I doesn't seem to work though. I get an empty list as the result. Test case:
Does it work for you? |
Oh, it doesn't work because you only query for This change makes it work:
|
https://www.mediawiki.org/wiki/API:Categorymembers
|
I'm not sure if you want an argument to check for files or not and whether you want to return files as part of pages or as a separate list in the return tuple, but this quick hack works for me:
|
I don't generally have an issue with it being added within the normal pages. My only concern is if someone wants to loop over the pages returned, will they have to know which ones are files to append "file:" or something similar for other languages? What if, we added a boolean parameter to include files in the category members? Therefore if someone like you would like them, you can pull them but if someone else doesn't need them they can leave the default of def categorymembers(category, results=10, subcategories=True, files=False):
cmtype = "page"
if subcategories:
cmtype += "|subcat"
if files:
cmtype += "|file"
# do the remaining work |
UGH! Not sure I like putting it into its own list for files. It does add the "File:" prefix so that should work as just another "link". I think I can get to this in pretty quickly and update all the tests. |
I'd like to iterate through category pages. The API has categorymembers for this. An example query: https://en.wiktionary.org/w/api.php?action=query&list=categorymembers&cmtitle=Category%3ASwahili_lemmas&format=json
Is that something you could add?
The text was updated successfully, but these errors were encountered: