google-images-download icon indicating copy to clipboard operation
google-images-download copied to clipboard

JSON output of Google API changed again I think

Open eamonnkenny opened this issue 2 years ago • 21 comments

Hi Joe,

I think they changed the google API again. Getting None errors returned from any attempted download. I presume we've to dig into their output again to find a fix.

eamonnkenny avatar Dec 14 '22 13:12 eamonnkenny

the error is arising inside the format_object function because the try except returns an exception which is None. Might be a good idea to not just print(e) but instead do something like print( "Error in format_object:", e )

eamonnkenny avatar Dec 14 '22 13:12 eamonnkenny

Found the fix Joe, turns out that if you change info = data[11] to info = data[22] it will all start working again.

eamonnkenny avatar Dec 14 '22 13:12 eamonnkenny

Works for me as well - Thanks

greg-oz avatar Dec 14 '22 22:12 greg-oz

Future readers, for branch "patch-1" commit e91e6a38ad654877f59edc7894822f5319d75df1, the line to edit is file: google_images_download/google_images_download.py method: format_object line: 407 And works on Google Image Search for Tuesday, December 27, 2022 11:31:19 AM I changed "info = data[11]" to "info = data[22]" and had success :)

Charlweed avatar Dec 27 '22 19:12 Charlweed

its stop again, is there any solution so i can run it again?

websonder avatar Jan 08 '23 07:01 websonder

on Jan. 9, 2023 I changed "info = data[11]" to "info = data[23]" and had success.

DenimPauel avatar Jan 08 '23 16:01 DenimPauel

Thanks Its working

websonder avatar Jan 08 '23 16:01 websonder

January 17, 2023 03:03:44 AM

"info = data[11]" to "info = data[22]"

doesn't work. It worked until last week as I remember.

Error message starts with 'bool' object is not subscriptable

And just read the answer from @DenimPauel "info = data[11]" to "info = data[23]" works! Thanks to @DenimPauel

gwonhong avatar Jan 16 '23 18:01 gwonhong

January 17, 2023 03:03:44 AM

"info = data[11]" to "info = data[22]"

doesn't work. It worked until last week as I remember.

Error message starts with 'bool' object is not subscriptable

And just read the answer from @DenimPauel "info = data[11]" to "info = data[23]" works! Thanks to @DenimPauel

Yes, info = data[23] works

16th January 2023

gipinze avatar Jan 16 '23 20:01 gipinze

Is the command line now superslow? I ran the following and its taking an age to run:

googleimagesdownload -l 10 -r labeled-for-reuse -k pepper -f jpg

eamonnkenny avatar Jan 26 '23 14:01 eamonnkenny

Thanks all for sharing this solution!

Until now (2023/02/11), changing info = data[11] to info = data[23] still works for me 👍

Mr-Philo avatar Feb 11 '23 02:02 Mr-Philo

Works here too! This should be updated to the main git tho :(

spacewalkingninja avatar Mar 05 '23 02:03 spacewalkingninja

Bumping again today (March 22), anyone else affected?

trevorgribble avatar Mar 22 '23 22:03 trevorgribble

change from "info = data[9]" to "info = data[25]" on line 405 or 407 in google_images_download.py.

or ... How about this? https://github.com/Joeclinton1/google-images-download/pull/33/commits/bb22871df27188302c73fdf8aa8faf1df9ae0839 this could search data[xx] maybe in the feature too.

Mar. 23, 2023.

DenimPauel avatar Mar 23 '23 00:03 DenimPauel

So, we are at the previous bug again... 3rd time fixing it. This now is a better fix, and would have fixed the code 3 times without having to definte which item gives the correct value of info:

    if info is None:
        # EK
        #info = data[11]
        for item in data:
           if type( item ) == dict:
               info = item

basically what I'm doing is looking at all values of data and seeing which one is the dictionary. When we find it this is what info is set to. It works. And it would have worked for data[22] which occurred about 6 months ago. This then changed to data[23] and now the issue is that info = data[25]. We should just use my new fix. At least if there is one available directory the code can find the value of info itself.

eamonnkenny avatar Mar 23 '23 16:03 eamonnkenny

@eamonnkenny great call, working smooth again, thank you very much.

trevorgribble avatar Mar 23 '23 18:03 trevorgribble

Hi MrClean,

I think that it was rolled back to a really old version. You will need to implement my fix as described in issue #31 to replace lines 406 and 407 which currently are wrong:

    if info is None:
        info = data[11]

in google_image_download.py. My fix in issue #31 should just work. I'm not an editor of the code, so I can't fix the git repository.

Best Regards, Eamonn Kenny

On Thu, Nov 16, 2023 at 1:17 PM mrclean789 @.***> wrote:

None of the fixes seem to be working anymore. Any solutions?

— Reply to this email directly, view it on GitHub https://github.com/Joeclinton1/google-images-download/issues/31#issuecomment-1814421543, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY5SUTF73U7DRCX26RKKSLYEYG75AVCNFSM6AAAAAAS6PDXRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJUGQZDCNJUGM . You are receiving this because you were mentioned.Message ID: @.***>

eamonnkenny avatar Nov 16 '23 13:11 eamonnkenny

Thank you Eamonn, yes it works now. I'm actually running this again on a new machine and found out I had to install certificates :D

mrclean789 avatar Nov 16 '23 13:11 mrclean789

hi this is my config

Format the object in readable format

def format_object(self, object):
    data = object[1]
    main = data[3]
    info = data[25]
    if info is None:
        info = data[11]
    formatted_object = {}
    try:

i am getting error, could you please help me to solve this Item no.: 575 --> Item name = Anyk Napja 2023 Evaluating... -1 Image objects data unpacking failed. Please leave a comment with the above error at https://github.com/Joeclinton1/google-images-download/pull/26 Traceback (most recent call last): File "/home/usethis/script1.py", line 1380, in main() File "/home/usethis/script1.py", line 1367, in main paths, errors = response.download(arguments) # wrapping response in a variable just for consistency File "/home/usethis/script1.py", line 1007, in download paths, errors = self.download_executor(arguments) File "/home/usethis/script1.py", line 1143, in download_executor images, tabs = self.download_page(url) # download page TypeError: cannot unpack non-iterable NoneType object

websonder avatar Dec 25 '23 07:12 websonder

I have

 def format_object(self, object):
        data = object[1]
        main = data[3]
        info = data[25]
        if info is None:
            for item in data:
                if type( item ) == dict:
                    info = item
        formatted_object = {}
...

And sadly I get: Image objects data unpacking failed. Please leave a comment with the above error at ....

rotaugenlaubfrosch avatar Apr 06 '24 12:04 rotaugenlaubfrosch

I have

 def format_object(self, object):
        data = object[1]
        main = data[3]
        info = data[25]
        if info is None:
            for item in data:
                if type( item ) == dict:
                    info = item
        formatted_object = {}
...

And sadly I get: Image objects data unpacking failed. Please leave a comment with the above error at ....

Receiving same output, did some digging and it appears the issue is upstream from this format_object function.

Specifically, in the _extract_data_pack function:

def _extract_data_pack(self, page) function, 
           start_line = page.find("AF_initDataCallback({key: \\'ds:1\\'") - 10

is returning -11 (meaning that page.find is returning -1, so we are not finding the desired term. Everything from then on is basically coming up with no data.

So it's seems that the respData returned from:


                req = urllib.request.Request(url, headers=headers)
                resp = urllib.request.urlopen(req)
                respData = str(resp.read())

Has changed quite a bit that the _extract_data_pack function is no longer functional.

trevorgribble avatar Apr 07 '24 14:04 trevorgribble

please let me know if someone found any solution for this, i really need this

websonder avatar Oct 16 '24 20:10 websonder