Manuál:Pywikibot/flickrripper.py

From mediawiki.org
This page is a translated version of the page Manual:Pywikibot/flickrripper.py and the translation is 12% complete.

flickrripper is a Pywikibot script for easy upload of large numbers of images from Flickr to Wikimedia Commons.

It is currently in pre-alpha state.

This tool was requested by some on Commons:Batch uploading/Flickr images by user.

Instalace

Flickrripper is part of Pywikibot. You first need to install pywikibot. At Using the python pywikibot you can find a manual on how to install pywikibot.

GIT or nightly install is recommended.

Once pywikibot is installed, three more Python packages may need to be installed.

Jednoduchá instalace

To install the extra packages with 'Easy install', please install the latest version of setuptools which may be downloaded from http://pypi.python.org/pypi/setuptools.

Python Image Library

Python Image Library (PIL) is used to show the image.

You can install it by running the command at a command prompt:

$ easy_install PIL

nebo

$ pip install --user pillow
Flickrapi kit

The Python Flickrapi kit is used to communicate with the Flickr api.

You can install it by running the command at a command prompt:

$ pip install --user "flickrapi>=1.4.5,<2"
TkInter
You can install this library [1] with your usual package manager; don't forget the python-imaging-tk package.

pip

All of the extra packages may be installed at once using pip, using whatever permissions you have, with:

$ pip install --user "flickrapi>=1.4.5,<2" pillow

Flickr authentication

Flickr API key

You need a valid Flickr API key to run this program. You can apply for a key here. Apply for a Non-Commercial API Key.

Configuration

Edit user-config.py with your favorite text editor, and add the following in it.

# Using the Flickr api
flickr = {
    'api_key': 'YOUR_API_KEY',  # Provide your key!
    'api_secret': 'YOUR_API_SECRET', # Provide your secret!
    'review': False,  # Do we use automatically make our uploads reviewed? (True or False)
    'reviewer': 'REVIEWER_NAME', # If so, under what reviewer name?
    }
  • api_key : Provide your Flickr API key.
  • review : If you want to mark all images as review automatically. Use "True" only if you have a reviewer or sysop flag on Commons!
  • reviewer : Add your username here if you want to mark images as reviewed by you.

Now you'll be requested to login on your first run of the script, to confirm the application.

The text login doesn't work (needs JavaScript), preventing logging in using a terminal (such as Tool Labs).

It is better to run flickrripper.py on your home computer so that the confirmation form is opened in your standard browser.

Použití

To run Flickrripper you have to browse to the Pywikibot folder. Then type the following:

$ python pwb.py flickrripper

with some of the various following options; the necessary ones are bolded.

Notes:

  • the script never uploads duplicate files (identified with their hash);
  • unless the files you're uploading all have title, description etc., edit the script to add a "prefix" to the filenames: look for the getFilename line, replace "Flickr" with your filename prefix in project='Flickr' (can be e.g. the name of the category you're using).

Options to tell what images to work on:

  • One of the following:
    1. -group_id - The id of the Flickr group to work on. Works on all images in a group.
    2. -photoset_id - The id of the Flickr set to work on. Works on all images in a set.
    3. -user_id - The id of the user to work. Works on all images uploaded by a user. Username is not an id! For example, id for user The Library of Congress is 8623220@N02 (you can find it here).
  • One or both of:
    1. -start_id - Start at the photo with this id (useful for resuming uploads). Use this in combination with -group_id/-photoset_id/-user_id.
    2. -end_id - Stop at the photo with this id (useful if you just want to do a part of the upload and later resume with -start_id).

Options to tell how to work on each image:

  1. -tags - Filter out a certain tag (only one at the moment, will be changed to support multiple tags).
  2. -flickrreview - Mark as flickrreviewed, this overrides the settings in your user-config.py.
  3. -reviewer - Set the reviewer for flickrreview, this overrides the settings in your user-config.py.
  4. -override - Remove the licensing part and replace it with something custom. Can be used for transferring copyrighted photo's for which you have OTRS permission. Use with care!
  5. -removecategories - Don't add categories from automatic suggestions.
  6. -addcategory - Manually add a category, which you will be asked for after launching and will not be shown in the description in the confirmation dialog. Does not yet support multiple categories, but you can pass multiple as if they were one only, like this: FirstCategory]][[Category:SecondCategory.
  7. -autonomous - For autonomous uploading without showing of each image. Use with care!

Syntax:

$ python pwb.py flickrripper -user_id:8623220@N02 -removecategories -addcategory

Troubleshooting

Traceback (most recent call last):
  File "flickrripper.py", line 41, in <module>
    from PIL import Image, ImageTk    # see: http://www.pythonware.com/products/pil/
ImportError: No module named PIL