Skip to content

This is a Python Package called `imagedownloader`. It downloads images from urls

License

Notifications You must be signed in to change notification settings

mm-mazhar/imagedownloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Downloader

Python PyPI - Wheel PyPI - Downloads PyPI - License Read the Docs

PyPI text text

This is a Python Package called imagedownloader that defines three methods: fromList(), fromCsv(), and zipFolder(). The class is designed to download images from either a list of URLs or a CSV file containing multiple URLs, and then save them to a specified folder location. Additionally, it provides functionality to zip the folder where the downloaded images are saved.

The fromList() method takes a list of URLs and a folder path as arguments. If the specified folder does not exist, the method creates it. Then, it loops through the list of URLs, sends a request to download the image, and saves the image to the folder using the last part of the URL as the filename. If any errors occur during the process, the method prints an error message.

The fromCsv() method takes a CSV file path and a folder path as arguments. If the specified folder does not exist, the method creates it. Then, it reads the CSV file using the csv.reader() function and loops through each row. For each row, it extracts the URL, sends a request to download the image, and saves the image to the folder using the last part of the URL as the filename. If any errors occur during the process, the method prints an error message.

The zipFolder() method takes a folder path and an output path as arguments. It creates a new zip file at the output path and loops through each file in the specified folder using the os.walk() function. For each file, it adds the file to the zip file with the same filename. If any errors occur during the process, the method prints an error message.

The class also provides two dunder methods, str() and repr(), which return a string representation of the class instance.

Installation

Pytubev3 requires an installation of Python 3.7 or greater, as well as pip. (Pip is typically bundled with Python installations)

To install from PyPI with pip:

python -m pip install imgdownloader

Examples

CSV File Should have all the urls in the first column as follows


from imagedownloader import ImageDownloader

if __name__ == "__main__":
    
    image_urls = [
    'https://cdn.pixabay.com/photo/2017/08/30/01/05/milky-way-2695569_960_720.jpg',
    ]
    
    save_path = "./images"
    csv_path = "./test.csv"
    output_path = "./images.zip"
    folder_path = "./images"
    
    imgDownloader = ImageDownloader()
    imgDownloader.fromList(image_urls, save_path)
    imgDownloader.fromCsv(csv_path, save_path)
    imgDownloader.zipFolder(folder_path, output_path)

Development/Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add Some Feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.
  6. Email me at mazqoty.01@gmail.com because I do not check those messages often.

History

  • 1.0.3

About

This is a Python Package called `imagedownloader`. It downloads images from urls

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages