Skip to content

Commit

Permalink
Merge pull request #4 from KTS-o7/codeUpdate
Browse files Browse the repository at this point in the history
Code update
  • Loading branch information
KTS-o7 authored Feb 16, 2024
2 parents 6c28876 + 45b00d0 commit f94e751
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 4 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Better Bing Image Downloader

## Table of Contents

- [Disclaimer](#disclaimer)
- [Installation](#installation)
- [Usage](#usage)
- [Requirements](#requirements)
- [License](#license)
- [Contact](#contact)

### Disclaimer<br />

This program lets you download tons of images from Bing.
Expand All @@ -19,7 +28,7 @@ pip install .

or

```sh
```bash
pip install better-bing-image-downloader
```

Expand All @@ -34,7 +43,6 @@ from better_bing_image_downloader import download
download.download(query_string, limit=100, output_dir='dataset', adult_filter_off=True, force_replace=False, timeout=60, verbose=True)
```

`-h` : Gives a verbose help on what to do<br/>
`query_string` : String to be searched.<br />
`limit` : (optional, default is 100) Number of images to download.<br />
`output_dir` : (optional, default is 'dataset') Name of output dir.<br />
Expand All @@ -44,3 +52,11 @@ download.download(query_string, limit=100, output_dir='dataset', adult_filter_o
`filter` : (optional, default is "") filter, choose from [line, photo, clipart, gif, transparent]<br />
`verbose` : (optional, default is True) Enable downloaded message.<br />
`bad-sites` : (optional, defualt is empty list) Can limit the query to not access the bad sites.<br/>

### License

This project is licensed under the terms of the MIT license.

### Contact

If you have any questions or feedback, please contact us at [email](mailto:shentharkrishnatejaswi@gmail.com).
58 changes: 58 additions & 0 deletions better_bing_image_downloader/bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,64 @@


class Bing:
"""_summary_
A class to download images from Bing.
_description_
This class is used to download images from Bing. It uses the Bing Image Search API to get the links of the images and then downloads the images from the links. The class can be used to download images based on a query, with a limit on the number of images to be downloaded. The images can be filtered based on the type of image (photo, clipart, line drawing, animated gif, transparent) and the adult content can be filtered as well. The images are saved in the specified output directory. The class also has the option to be verbose, which will print the progress of the download.
_parameters_
query : str
The query to be used to search for images.
limit : int
The number of images to be downloaded.
output_dir : str
The directory where the images are to be saved.
adult : str
The adult content filter. Can be "off" or "on".
timeout : int
The time in seconds to wait for the request to Bing to be completed.
filter : str
The type of image to be filtered. Can be "line", "photo", "clipart", "gif", "transparent".
verbose : bool
Whether to print the progress of the download.
_methods_
get_filter(shorthand)
Returns the filter string based on the shorthand.
============
shorthand : str
The shorthand for the filter. Can be "line", "photo", "clipart", "gif", "transparent".
============
return : str
The filter string based on the shorthand.
save_image(link, file_path)
Saves the image from the link to the file path.
============
link : str
The link of the image to be saved.
file_path : str
The file path where the image is to be saved.
============
return : None
download_image(link)
Downloads the image from the link.
============
link : str
The link of the image to be downloaded.
============
return : None
run()
Runs the download of the images.
============
return : None
"""
def __init__(self, query, limit, output_dir, adult, timeout, filter='', verbose=True,badsites=[]):
self.download_count = 0
self.query = query
Expand Down
3 changes: 2 additions & 1 deletion better_bing_image_downloader/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def download(query, limit=100, output_dir='dataset', adult_filter_off=True,
force_replace (bool): Whether to replace existing files.
timeout (int): The timeout for the image download.
filter (str): The filter to apply to the search results.
verbose (bool): Whether to print detailed output.
verbose (bool): Whether to print detailed output._summary_
badsites (list): List of bad sites to be excluded.
"""
# engine = 'bing'
if adult_filter_off:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="better_bing_image_downloader",
version="1.0.1",
version="1.0.2",
author="Krishnatejaswi S",
author_email="shentharkrishnatejaswi@gmail.com",
description="This package is built on top of bing-image-downloader by gaurav singh",
Expand Down

0 comments on commit f94e751

Please sign in to comment.