By Simon Kågedal Reimer <simon@kagedal.org>
A python library to help with appropriate crediting when using content from Wikimedia Commons.
The Wikimedia Commons aims to make available public domain and freely licensed educational media files for everyone. It's a beautiful thing.
Its rules allow for uploaded files to give only two restrictions of redistribution: copyleft requirements and attribution requirements. When reusing content outside the Wikimedia projects, you have to be careful to respect these requirements. This can get quite hairy because of the free form, wild growing nature of a wiki.
The usecommons library aims to give a simple solution for correctly attributing Wikimedia Commons content.
from usecommons import Commons commons = Commons() print(commons.get("Fuji apple.jpg").attribution())
That's it! That's currently pretty much the whole API. It will print
out HTML; if you'd rather get pure text, give the
argument use_html = False
to the attribution
function.
$base_url = 'http://helgo.net/cgi-bin/simon/usecommons/webapi.py?file='; echo(file_get_contents($base_url + 'E_is_for_egg.ogg'));
Note: this URL and API will most likely change.
Alternatively, to save a network access, you can install it as an executable and catch the standard output. Here is a Ruby example:html = %x[python -m usecommons "Fuji_apple.jpg"] puts html
I know. You want more flexibility. The raw metadata fields to format the way you want. The first aim of this project was, however, to provide a really simple solution to a common problem.
As a next step, I might make a more flexible API. There is however already such a tool available as a web API, Magnus Manske's Commons API, giving you access to all the metadata you might need as XML. There is currently some problems with the generated XML.