commonsdownloader package¶
commonsdownloader package.
commonsdownloader¶
Download files from Wikimedia Commons.
-
class
commonsdownloader.commonsdownloader.
Folder
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)¶ Bases:
argparse.Action
An argparse action for directories.
-
commonsdownloader.commonsdownloader.
download_files_if_not_in_manifest
(files_iterator, output_path)¶ Download the given files to the given path, unless in manifest.
-
commonsdownloader.commonsdownloader.
download_from_category
(category_name, output_path, width)¶ Download files of a given category.
-
commonsdownloader.commonsdownloader.
download_from_file_list
(file_list, output_path)¶ Download files from a given textfile list.
-
commonsdownloader.commonsdownloader.
download_from_files
(files, output_path, width)¶ Download files from a given file list.
-
commonsdownloader.commonsdownloader.
get_category_files_from_api
(category_name)¶ Yield the file names of a category by querying the MediaWiki API.
-
commonsdownloader.commonsdownloader.
get_files_from_arguments
(files, width)¶ Yield the file names and chosen width.
-
commonsdownloader.commonsdownloader.
get_files_from_textfile
(textfile_handler)¶ Yield the file names and widths by parsing a text file handler.
-
commonsdownloader.commonsdownloader.
get_local_manifest_path
(output_path)¶ Return the path to the local downloading manifest.
-
commonsdownloader.commonsdownloader.
is_file_in_manifest
(file_name, width, manifest)¶ Whether the given file, in its given width, is in manifest.
-
commonsdownloader.commonsdownloader.
main
()¶ Main method, entry point of the script.
-
commonsdownloader.commonsdownloader.
read_local_manifest
(output_path)¶ Return the contents of the local manifest, as a dictionary.
-
commonsdownloader.commonsdownloader.
write_file_to_manifest
(file_name, width, manifest_fh)¶ Write the given file in manifest.
thumbnaildownload¶
Download files from Wikimedia Commons.
-
exception
commonsdownloader.thumbnaildownload.
CouldNotWriteFileOnDiskException
¶ Bases:
commonsdownloader.thumbnaildownload.DownloadException
Exception raised when the file could not be written on disk.
-
exception
commonsdownloader.thumbnaildownload.
DownloadException
¶ Bases:
exceptions.Exception
Base class for exceptions in this module.
-
exception
commonsdownloader.thumbnaildownload.
FileDoesNotExistException
¶ Bases:
commonsdownloader.thumbnaildownload.DownloadException
Exception raised when a requested file does not exist.
-
exception
commonsdownloader.thumbnaildownload.
RequestedWidthBiggerThanSourceException
¶ Bases:
commonsdownloader.thumbnaildownload.DownloadException
Exception raised when the requested width is bigger than source file.
-
commonsdownloader.thumbnaildownload.
clean_extension
(extension)¶ Return a cleaned-up extension - only applies for JPEG.
-
commonsdownloader.thumbnaildownload.
clean_up_filename
(file_name)¶ Return the cleaned-up file title.
-
commonsdownloader.thumbnaildownload.
download_file
(image_name, output_path, width=100)¶ Download a given Wikimedia Commons file.
-
commonsdownloader.thumbnaildownload.
get_exception_based_on_api_message
(message, image_name='')¶ Return the exception matching the given API error message.
-
commonsdownloader.thumbnaildownload.
get_full_size_file
(image_name)¶ Return the file contents of given file at full size.
-
commonsdownloader.thumbnaildownload.
get_thumbnail_of_file
(image_name, width)¶ Return the file contents of the thumbnail of the given file.
-
commonsdownloader.thumbnaildownload.
make_full_size_url
(image_name)¶ Return the URL to the full size of the file.
-
commonsdownloader.thumbnaildownload.
make_thumb_url
(image_name, width)¶ Return the URL to the thumbnail of the file, at the given width.
-
commonsdownloader.thumbnaildownload.
make_thumbnail_name
(image_name, extension)¶ Return name of the downloaded thumbnail, based on the extension.