CLI tool for downloading files from MediaWiki sites
Project description
wikiget
Something like wget for downloading a file from MediaWiki sites (like Wikipedia or Wikimedia Commons) using only the file name or the URL of its description page.
Requires Python 2.7 or 3.5+. Install with pip install --user wikiget
.
Usage
wikiget [-h] [-V] [-q | -v] [-f] [-a] [--site SITE] [-o OUTPUT] FILE
If FILE
is in the form File:Example.jpg
or Example.jpg
, it will be fetched
from the default site, which is "en.wikipedia.org". If it's the fully-qualified
URL of a file description page, like https://commons.wikimedia.org/wiki/File:Example.jpg
,
the file is fetched from the specified site, in this case "commons.wikimedia.org".
Full URLs may contain characters your shell interprets differently, so you can
either escape those characters with a backslash \
or surround the entire URL
with single '
or double "
quotes.
The site can also be specified with the --site
flag, though this will not have
any effect if the full URL is given.
More detailed information, such as the site used and full URL of the file, can be
displayed with -v
or --verbose
. Use -vv
to display even more detail. -q
can
be used to silence warnings.
By default, the program won't overwrite existing files with the same name as the
target, but this can be forced with -f
or --force
. Additionally, the file can
be downloaded to a different name with -o
.
Files can be batch downloaded with the -a
or --batch
flag. In this mode, FILE
will be treated as an input file containing multiple files to download, one filename
or URL per line. If an error is encountered, execution stops immediately and the
offending filename is printed.
Examples
wikiget File:Example.jpg
wikiget --site commons.wikimedia.org File:Example.jpg
wikiget https://en.wikipedia.org/wiki/File:Example.jpg -o test.jpg
Future plans
- batch download by (Commons) category or user uploads
- download from any MediaWiki-powered site, not just Wikimedia projects
- maybe: download Wikipedia articles, in plain text, wikitext, or other formats
Contributing
It's recommended that you use a virtual environment manager like venv or virtualenv) to install dependencies:
git clone https://github.com/clpo13/wikiget.git # if you plan on submitting pull requests, fork the repo instead
cd wikiget
# Python 2 or 3
pip install --user virtualenv
virtualenv venv
# Python 3
python3 -m venv venv
To activate the virtual environment, use one of the following commands:
source venv/bin/activate # Linux and macOS; activate.csh and activate.fish are also available
.\venv\Scripts\activate # Windows (Command Prompt or PowerShell)
Then run pip install -e .
to invoke an
"editable" install,
meaning any changes made to the source will be reflected immediately in the
executable script. Unit tests can be run with python setup.py test
.
License
Copyright (C) 2018, 2019 Cody Logan
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program (see LICENSE). If not, see https://www.gnu.org/licenses/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for wikiget-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 148fd8e47c32408a0c67e654b9ffd65cf7c0b7c33c455595d7d93b7f98907cf2 |
|
MD5 | acb344e769e8b432c719b84ba69ebbef |
|
BLAKE2b-256 | 4740954f154afde52fa5b75127f65f4802e3be15e63784bb246aa75f38c37995 |