Package: dwimgs
dwimgsdwimgsis a simple Python command line utility to batch download images using a simple text file.INSTALLATIONdwimgsis available onPyPI, so you can simply install it using the following command:pip install dwimgsThis will install all the required packages and add thedwimgsutility to your path allowing you to start using it immediately. To ensure that it was installed successfully, run the following command:dwimgs --versionIf the package was installed successfully, you should get an output that looks like this:dwimgs 1.0.2 © 2021 by Abdelrahman SaidUSAGETo find out how to use the utility, you can simply run:dwimgs -hORdwimgs --helpThis will give you the following output:usage: dwimgs [-h] [-v] [--version] urls_file dest_dir

positional arguments:
  urls_file      A text file that has image URLs on separate lines
  dest_dir       The destination directory where the images will be saved. The
                 directory will be created if it doesn't exist.

optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose  increase the verbosity of the terminal output
  --version      show program's version number and exitAs you can see,dwimgstakes two simplerequiredarguments:A text file with URLs to images on the internet, with each URL placed on a separate line.A folder on your system where the downloaded images will be saved.So, if you have a file calledlinks.txtwith valid URLs to images and you want to save them in a folder calledPictures, all you need to do is run the following command:dwimgs links.txt PicturesThis will look for thelinks.txtfile and thePicturesfolder in the current directory. If it cannot find the file, then it will output an error message that looks like this:ERROR: The URL files provided doesn't exist [/home/abdelrahman/links.txt]However, if thePicturesfolder doesn't exist, it will simply create it.Please note, that the order is important. You have to specify the file first then the folder.FILE NAMESdwimgstries to extract the image's file name from the URL. If it fails, it just generates a simple name and saves the image.Additionally, since it is common to get two different images with the same name,dwimgswill check before downloading an image to make sure that there aren't any other images with the same name. If it finds one, it will just add the date and time of download to the end of the file name to make it unique. This ensure that an image you have previously downloaded won't get overwritten with another image that just happens to have the same name.CHECKING THE DOWNLOADSSince there is no guarantee that all the links you provide will work,dwimgsstores the results of the download process in a file calledresult.jsonthat is saved next to the downloaded images in the folder you specified as a destination.The file contents will look like this:{
    "URLs processed": 2,
    "Downloads succeeded": 1,
    "Downloads failed": 1,
    "Failed downloads": [
        "https://cache.marriott.com/marriottassets/marriott/NYCSW/nycsw-exterior-9397-hor-feat.jpg"
    ],
    "Successful downloads": [
        "https://cdn.cnn.com/cnnnext/dam/assets/171008203711-times-square.jpg"
    ]
}As you can see, it includes the number of the URLs it processed, how many were downloaded successfully and how many failed. More importantly, it includes two lists, one that includes the links for the failed downloads and for the successful downloads. This allows you to open the links for the failed ones and either figure out why they failed or just download them manually.DEVELOPER DOCUMENTATIONIf you wish to download the source code and start experimenting with it, here is what you need to do.Download the source code and navigate to its directorygit clone https://github.com/amsaid1989/bulk-download-images.git
 cd bulk-download-imagesUsing your Python of choice, create a virtual environment in a separate folder (usually calledenv, but you can call it whatever you want)python -m venv envActivate the virtual environment. OnLinuxandMacOS, do the following if you are usingbashas your shell:source env/bin/activateOnWindows, you will need to do the following if you are usingCommand Prompt:env/Scripts/activate.batInstall the required packagespip install -r requirements.txtThat is it. Now, you shoud be able to rundwimgsand modify the code as you like. To make sure everything is working properly, run the following command:python src/dwimgs/run.py --versionIf everything is working properly, you should get the following output:dwimgs 1.0.2 © 2021 by Abdelrahman Said