upload.py is a Pywikibot script used to upload images to a wiki.
- python upload.py [Global-arguments] [-keep] [-filename:targetFilename] [-ignorewarn] [-noverify] [-chunked:64m] [-summary:SummaryOfTheUpload] [URL-or-filename [description-text]]
|-keep||Keep the filename as is|
|-recursive||A recursive search in folders ?|
|-noverify||Do not ask for verification of the upload description if one is given|
|-summary||Summary of the upload|
|-noverify||Not proofread the description|
|-ignorewarn||Upload even if another file would be overwritten or another mistake would be risked|
|-chunked||Upload the file in chunks (more overhead, but restartable) ; If no value is specified the file will be uploaded as whole ; regex : ^-chunked(?::(\d+(?:\.\d+)?)[ \t]*(k|ki|m|mi)?b?)?$|
|-always||Save without confirmation ; Enable keepFilename and disable verifyDescription|
If any other arguments are given, the first is the URL or filename to upload, and the rest is a proposed description to go with the upload. If none of these are given, the user is asked for the file or URL to upload. The bot will then upload the image to the wiki.
The script will ask for the location of an image, if not given as a parameter, and for a description.
If the -filename argument is given, then it is used as the name of the image on the wiki; otherwise it is based on the filename or url of the input file.
If -keep is not specified, then the target filename undergoes some further checking, and the user is asked for confirmation. The / character is forbidden, and the filename extension (after the dot) must be one of these: gif, jpg, jpeg, mid, midi, ogg, png, svg, xcf, djvu. If the check is failed, then the user is prompted for a new filename.
If an image with the target filename already exists, the description will not be overwritten with the supplied description text. Instead, the description text will be added as a comment.
Spaces in the filename will automatically be converted to underscores, since mediawiki doesn't allow spaces. The encoding of the filename will also be converted to the encoding used on the target site (typically unicode). The script also attempts to convert the description to the wiki's target encoding, or, as a last resort, will convert characters to html entities.
Error detection is based on both the http status and the contents of the response, which is assumed to be in English; error detection may fail if the bot's account has been set not to show an English interface.
Example of output if no file name is given:
C:\Users\t\Desktop\pywikipedia>upload.py No input filename given File or URL where image is now: C:\Users\t\Desktop\Dead7.jpg Reading file C:\Users\t\Desktop\Dead7.jpg The filename on the target wiki will default to: Dead7.jpg Enter a better name, or press enter to accept: The suggested description is: Do you want to change this description? ([y]es, [N]o) n Uploading file to dead:en via API.... Upload successful. C:\Users\t\Desktop\pywikipedia>
Global arguments available
These options will override the configuration in user-config.py settings.
||Read the bot's configuration data from directory given by PATH, instead of from the default directory.|
||Set the language of the wiki you want to work on, overriding the configuration in user-config.py. xx should be the language code.|
||Set the family of the wiki you want to work on, e.g. wikipedia, wiktionary, wikitravel, ... This will override the configuration in user-config.py.|
||Log in as user 'xyz' instead of the default username.|
||Immediately return control to the terminal and redirect stdout and stderr to file xyz. (only use for bots that require no input from stdin).|
||Show the help text.|
||Enable the log file, using the default filename 'script_name-bot.log' Logs will be stored in the logs subdirectory.|
||Enable the log file, using 'xyz' as the filename.|
||Disable the log file (if it is enabled by default).|
||Sets a new maxlag parameter to a number of seconds. Defer bot edits during periods of database server lag. Default is set by config.py|
||Set the minimum time (in seconds) the bot will wait between saving pages.|
||Enable the log file and include extensive debugging data for component "item" (for all components if the second form is used).|
||Have the bot provide additional console output that may be useful in debugging.|
||Toggles the cosmetic_changes setting made in config.py or user-config.py to its inverse and overrules it. All other settings and restrictions are untouched.|
||Disables writing to the server. Useful for testing and debugging of new code (if given, doesn't do any real changes, but only shows what would have been changed).|
||You may use all given numeric config variables as option and modify it with command line.|