Skip to content

Commit

Permalink
Offset downloading from #116
Browse files Browse the repository at this point in the history
thanks to @leberknecht for the feature
  • Loading branch information
Vasa committed Aug 18, 2018
1 parent eff8aa8 commit a7d7d1b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ Arguments
| | | |
| | | This argument does not take any value. Just add '--no_numbering' or '-nn' in your query. |
+-------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+
| offset | of | When you specify this argument, it will skip the offset number of links before it starts downloading images |
| | | |
| | | If this argument is not specified, the script will start downloading form the first link until the limit is reached |
| | | |
| | | This argument takes integer. Make sure the value of this argument is less than the value of limit |
+-------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+
| help | h | show the help message regarding the usage of the above arguments |
+-------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+

Expand Down
7 changes: 6 additions & 1 deletion google_images_download/google_images_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"exact_size", "aspect_ratio", "type", "time", "time_range", "delay", "url", "single_image",
"output_directory", "image_directory", "no_directory", "proxy", "similar_images", "specific_site",
"print_urls", "print_size", "print_paths", "metadata", "extract_metadata", "socket_timeout",
"thumbnail", "language", "prefix", "chromedriver", "related_images", "safe_search", "no_numbering"]
"thumbnail", "language", "prefix", "chromedriver", "related_images", "safe_search", "no_numbering",
"offset"]


def user_input():
Expand Down Expand Up @@ -108,6 +109,7 @@ def user_input():
parser.add_argument('-ri', '--related_images', default=False, help="Downloads images that are similar to the keyword provided", action="store_true")
parser.add_argument('-sa', '--safe_search', default=False, help="Turns on the safe search filter while searching for images", action="store_true")
parser.add_argument('-nn', '--no_numbering', default=False, help="Allows you to exclude the default numbering of images", action="store_true")
parser.add_argument('-of', '--offset', help="Where to start in the fetched links", type=str, required=False)

args = parser.parse_args()
arguments = vars(args)
Expand Down Expand Up @@ -697,6 +699,9 @@ def _get_all_items(self,page,main_directory,dir_name,limit,arguments):
break
elif object == "":
page = page[end_content:]
elif arguments['offset'] and count < int(arguments['offset']):
count += 1
page = page[end_content:]
else:
#format the item for readability
object = self.format_object(object)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from codecs import open
from os import path

__version__ = '2.3.0'
__version__ = '2.4.0'

here = path.abspath(path.dirname(__file__))

Expand Down

0 comments on commit a7d7d1b

Please sign in to comment.