problem with bot are best reported at https://wiki.openstreetmap.org/wiki/User_talk:Mateusz_Konieczny I am currently experimenting with Codeberg with some of my minor projects so it is possible that I may miss notifications here
 
 
Go to file
Mateusz Konieczny 109be057bf suspend until files are grouped 2022-12-29 21:17:33 +01:00
images_for_readme_and_documentation document sponsorship 2022-12-18 18:22:58 +01:00
single_shot_scripts_likely_to_be_reused_in_future export code to a separate library 2022-09-11 13:56:48 +02:00
.gitignore add code to find matching quality images on Wikimedia Commons 2022-08-16 10:15:42 +02:00
LICENSE.MD initial commit 2022-01-07 09:58:51 +01:00
README.MD encourage to open an issue 2022-12-29 21:17:33 +01:00
complain_about_missing_attribution_where_license_requires_it.py rename scripts for better structure 2022-12-29 21:17:33 +01:00
complain_about_missing_file_source_or_license.py suspend until files are grouped 2022-12-29 21:17:33 +01:00
edit_add_clear_attribution_for_self_templates.py ignore some garbage data 2022-11-21 20:38:09 +01:00
edit_blank_file_listing_pages_polluting_maintenance_categories.py add TODO 2022-09-23 12:09:18 +02:00
edit_note_files_used_in_osm_database.py fix more chaos caused by library extraction 2022-09-24 21:16:37 +02:00
edit_remove_double_categorization_of_JOSM_imagery.py export code to a separate library 2022-09-11 13:56:48 +02:00
edit_replace_file.py split function 2022-12-18 18:23:53 +01:00
edit_wikimedia_common_duplicates.py fix more chaos caused by library extraction 2022-09-24 21:16:37 +02:00
find_quality_image_on_wikimedia_commons.py whitespace tweak 2022-11-14 14:43:23 +01:00
list_files_where_license_warnings_expired.py list one more license template 2022-11-21 20:39:09 +01:00
list_pages_with_easy_to_recover_licenses.py one more variant 2022-12-26 18:28:40 +01:00
list_time_travelling_odbl.py more understendable log message 2022-09-10 14:03:44 +02:00
null_edit.py export code to a separate library 2022-09-11 13:56:48 +02:00
password_data.py allow using specified login data 2022-03-25 09:23:41 +01:00
requirements.txt extract code to a separate library 2022-09-05 14:03:03 +02:00
run.sh rename scripts for better structure 2022-12-29 21:17:33 +01:00
shared.py make easier to rerun test in a full isolation 2022-12-18 18:20:44 +01:00
wiki_category_and_template_structure.py new copyright templates 2022-12-29 21:17:33 +01:00

README.MD

Purpose

This scripts were created to handle files at OpenStreetMap Wiki that were without proper licensing or with a mising source including running a simple bot.

It should be relatively easy to adapt it to other Mediawiki sites, but it was not tested.

Pull requests making easier to configure it for use with wikis other that OSM Wiki are welcome, as long as code is not getting much worse and more complicated.

This Mediawiki script can

Setup

Obtain code

Clone repository.

git clone https://github.com/matkoniecz/mediawiki_file_copyright_handler_bot.git
cd mediawiki_file_copyright_handler_bot

Dependencies

pip3 install -r requirements.txt

To install on specific Python version:

python3.9 -m pip install -r requirements.txt

Create config file with passwords

secret.json with content like

{
	"api_password": {
        "comment": "use https://wiki.openstreetmap.org/wiki/Special:BotPasswords - giving your standard username and password may work for now but can break at any time",
		"username": "User account@User account:_test",
		"password": "m3mfgy8j6bvwker29i2rsjk0r3y5060"
	}
}

use https://wiki.openstreetmap.org/wiki/Special:BotPasswords to obtain password

Adapt to Wiki

If not used at OSM Wiki you will need to add some configuration - pull requests are welcomed!

Base API url

Likely base api url needs to be passed - right now it defaults to OSM Wiki.

After base api url is defined and passed around defaulting to OSM Wiki likely should be removed.

It is fine to rewrite script so it will require API as a parameter.

Templates

Templates are likely to be different - so it would be necessary to also specify them somehow in config.

Alternatives

Architecture

Why not pywikibot?

Pywikibot has some weird, arcane architecture - and extra complexity on top of quite simple API is not actually useful.

Especially as I consider rewriting it in JS and making available as a web page.

Why pywikibot is bad? For example it requires creation of user-config.py file with some arcane config for start.

I admit that

family='osm'
mylang='en'
usernames['osm']['en'] = 'Actual username'

is not terribly complex once magic and poorly documented syntax is figured out. But having an extra poorly defined and unnecessary config file somewhere in location decided by library is just asking for problems and bugs.

Using pywikibot requires more learning about pywikibot internals than about Mediawiki API. This is not useful, especially as pywikibot in practice (in my experience) has much worse documentation and is less clear and harder to debug than direct API calls.

In this case it seems simpler to reinvent and document wheel using well documented component over trying to reconstruct pywikibot documentation from complex source code, stackoverflow questions and discussions scattered elsewhere.

Pywikibot also required passing some magic values (for example 6 for file namespace index)

Thanks

Thanks to people from Wikimedia Hackathon telegram channel for pointing me in right direction when dealing with Wikimedia API!

Especially to Bohdan Melnychuk.

Sponsors

Development of this tool was partially sponsored by NL.net foundation as part of the NGI0 Discovered fund (project 2021-06-056 - done as part of StreetComplete development and improving related ecosystem). Thanks for help!

nlnet