arrrlo / Google-Images-Search

[PYTHON] Search for image using Google Custom Search API and resize & crop afterwards
MIT License
176 stars 34 forks source link

fix custom name bug for multiple files #155

Closed Hussainity closed 1 year ago

Hussainity commented 1 year ago

This patch fixes a bug where due to misaligned functions, the custom name parameter, a string, always became False (not even None!) after the first page, even when a custom name was given.

_get_data()'s output does not match the input format of search(), and thus, search read self._cache_discovery's value ( a boolean, default False) into it's local custom_image_name variable.

arrrlo commented 1 year ago

Hi @Hussainity

Ok, I see where the problem is and you got the point. But your solution is incomplete. You're missing a few things.

_get_data() is used in _search_images() as well:

self._search_images(*self._get_data())

_set_data() is called in search() so custom_image_name should be set/avoided there:

if not self._search_again:
    self._set_data(
        search_params, path_to_dir, width, height, cache_discovery
    )
arrrlo commented 1 year ago

Sorry, I see now you did all good. Merging this.