Skip to content

Commit b8f436b

Browse files
committed
updatecategory now only iter on images (namespace 6)
It fixes #9 by only listing page from namespace 6 Reorder/renamed some of the global variables of this module.
1 parent 1c588e6 commit b8f436b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mediacollectiondb/updatedb.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
COMMONS_SITE_URL = 'commons.wikimedia.org'
1313
COMMONS_PROTOCOL = 'https'
14-
COMMONS_DEFAULT_CATEGORY = 'Images supported by Wikimedia France - Lutz'
15-
14+
COMMONS_FILE_NAMESPACE = 6
1615
COMMONS_QI_CATEGORY = 'Category:Quality images'
1716
COMMONS_FP_CATEGORY = 'Category:Featured pictures on Wikimedia Commons'
1817
COMMONS_VI_CATEGORY = 'Category:Valued images sorted by promotion date'
1918

19+
COMMONS_DEFAULT_CATEGORY = 'Images supported by Wikimedia France - Lutz'
2020
DEFAULT_DB_FILE = 'category.db'
2121

2222

@@ -28,7 +28,9 @@ def updatecategory(mediadatabase, category):
2828
category (str): category to update
2929
"""
3030
site = mwclient.Site((COMMONS_PROTOCOL, COMMONS_SITE_URL))
31-
images = [img for img in site.Categories[category]]
31+
# search page in category and keeps only images
32+
images = [img for img in site.Categories[category]
33+
if img.namespace == COMMONS_FILE_NAMESPACE]
3234
logging.debug("%d images in category %s", len(images), category)
3335
for img in images:
3436
image = make_media(img)

0 commit comments

Comments
 (0)