# Install dependencies
poetry install
# Run a bot
poetry run flickr
poetry run inaturalist
poetry run pas
poetry run youtube
# Lint
poetry run ruff check .
# Format code
poetry run ruff format
# Sort imports
poetry run isort .
# Type check
poetry run ty check src/
# Run tests
poetry run pytestwikibots enriches Wikimedia Commons files with structured data (SDC) pulled from external APIs. Each bot targets a specific source (Flickr, iNaturalist, Portable Antiquities Scheme, YouTube).
src/wikibots/lib/claim.py—Claimclass (typed builder for Wikidata claims),WbTime,WikiProperties,WBTIME_PRECISION. All snak/dict logic is private here. Bots never constructWbTimedirectly — passdatetime+ precision to claim methods.src/wikibots/lib/claims.py—ClaimsMixinwith allcreate_*claim methods and hook stubs (hook_creator_claim,hook_creator_target,hook_depicts_claim,hook_source_claim).src/wikibots/lib/bot.py—BaseBot(ClaimsMixin). Handles OAuth2 auth, Redis caching, HTTP sessions, file metadata, Commons/Wikidata API calls, and the main run loop.src/wikibots/lib/wikidata.py— Named constants for all Wikidata property (P-numbers) and entity (Q-numbers) IDs used across bots.src/wikibots/flickr.py,inaturalist.py,pas.py,youtube.py— Each bot overridestreat_page()and implements hooks for service-specific claim qualifiers.
- Bot queries Commons for files that match specific criteria (file type, templates, missing claims)
- Extracts external source IDs (e.g., Flickr photo ID) from file descriptions
- Fetches metadata from external API
- Creates Wikidata claims and updates Commons SDC
- Caches processed IDs in Redis to prevent re-processing
| Variable | Purpose |
|---|---|
PWB_CONSUMER_TOKEN, PWB_CONSUMER_SECRET, PWB_ACCESS_TOKEN, PWB_ACCESS_SECRET |
Wikimedia OAuth credentials |
PWB_USERNAME |
Commons bot username |
TOOL_REDIS_URI |
Redis connection string |
EMAIL |
Bot contact email (used in user-agent) |
FLICKR_API_KEY |
Flickr API key |
YOUTUBE_API_KEY |
YouTube Data API key |
compose.yaml runs the bots with a local Dragonfly (Redis-compatible) instance. Environment variables are injected via the compose file.
Deployed to Wikimedia Toolforge as containerized jobs. Build with toolforge build start -L. The Procfile defines the entry points for each bot.
{{FlickreviewR |status= |author= |sourceurl= |reviewdate= |reviewlicense= |reviewer= |archive= }}
The status parameter determines the review outcome. Only pass means the license is compatible. The template supports aliases (see [[Template:FlickreviewR/status aliases]]) — passed is an alias for pass. Other values: fail/failed, notmatching, error, nosource, notfound, pass-change/passed_changed, public-domain-mark, library-of-congress, powerhouse-museum, bad-author.
redismust stay on<6.0.0— Toolforge runs Redis server 6.0.16, and redis-py 7.x requires Redis 7.2+.flickr_apiv3 (current) usesPermissionDeniedfor private/inaccessible photos —PhotoIsPrivateno longer exists.- pywikibot config is accessed via
pwb.configwherepwbis imported frompywikibot.scripts.wrapper. Importing through the wrapper triggers proper pywikibot initialization — usingpywikibot.configdirectly does not work. The typossibly-missing-submodulewarnings onpwb.configare expected (exit 0).