Git Product home page Git Product logo

wikiimage's Introduction

WikiImage

This is a simple plugin which allows you to grab images stored in Wikipedia (or better WikiCommons). It does not do scraping but uses a subset of the MediaWiki API.

Requirements

  • open-uri
  • nokogiri
  • cgi

Install

./script/plugin install git://github.com/fuxowitsch/WikiImage.git

Example

images=WikiImage.new("Douglas Adams").getImages

This will return an array of hashes with the following keys:

:url            Link to the image
:size           Size of the image in bytes
:descriptionurl Link to the description page on Wikipedia 
:width          Width in Pixels
:height         Height in Pixels
:user           The user who uploaded the image and probably owns it (copyright holder might be different)
:timestamp      Last modified
:comment        Wikipedia comment info in wiki text

images=WikiImage.new("Douglas Adams").getImages(:globalusage).first

This returns the global usage on all WikiPedia pages for the first image found:

:title          The page title
:url            The wiki url
:wiki           The wikipedia domain (e.g. de.wikipedia.org)

You can also access the imagelist as represented in Wikipedia:

list = WikiImage.new("Fred Flintstone").imagelist

If you did use getImages on both properties you can access the stockpile which gives you a hash on all data:

obj=WikiImage.new("Fred Astaire")
obj.getImages(:imageinfo)
obj.getImages(:globalusage)
everything=obj.stockpile

everything will then contain - well everything ;)

Note!

Always show a link to the license (:descriptionurl) and name the Author (:user)

Tests

Assuming you have rspec installed you can run the tests within the plugin directory by invoking rake.

ToDo

  • Filter images only. Currently also other media content is returned
  • Get more description content from the actual wiki page
  • Ideas?

Copyright (c) 2010 Bernhard Fuchs, released under the MIT license

wikiimage's People

Contributors

masa8 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.