Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image objects data unpacking failed. Please leave comment... #37

Open
AdamNix opened this issue Mar 20, 2023 · 4 comments
Open

Image objects data unpacking failed. Please leave comment... #37

AdamNix opened this issue Mar 20, 2023 · 4 comments

Comments

@AdamNix
Copy link

AdamNix commented Mar 20, 2023

The error occurs because Google Images itself returns zero images. "Looks like there aren’t any matches for your search."
Everything else works fine, but this has a sys.exit() (Line 251), and even if I remove that, it will still come back with an unpacking error at a different point.
I clumsily tried to manually add new arguments(i.e. a query that Google definitely has images for e.g. Bugs Bunny) at this point(Line 252) but...trying to fix one problem creates three more.

@eamonnkenny
Copy link

eamonnkenny commented Mar 23, 2023

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.

See issue #31 for the full path. Really this is a duplicate of #31

@AdamNix
Copy link
Author

AdamNix commented Mar 23, 2023

Thanks, Eamonn for the reply. I changed line 406 (info = data[25]) to fix a new bug:
hardikvasa#373
And it solved the new bug, but the existing problem I have remains.
I posted your code in line 407 after I hashtagged 406, and I get the same error.

For example: deqrz marvel returns images(it's made up gibberish).
marvunapp deqrz returns no images
"""
Item no.: 1 --> Item name = marvunapp deqrz
Evaluating...
-1
Image objects data unpacking failed. Please leave a comment with the above error at #26
"""

@eamonnkenny
Copy link

The error occurs because Google Images itself returns zero images. "Looks like there aren’t any matches for your search." Everything else works fine, but this has a sys.exit() (Line 251), and even if I remove that, it will still come back with an unpacking error at a different point. I clumsily tried to manually add new arguments(i.e. a query that Google definitely has images for e.g. Bugs Bunny) at this point(Line 252) but...trying to fix one problem creates three more.

@AdamNix I'm not sure what your issue is. I've tried "Bugs Bunny" and it works perfectly for me. What is the exact command line command you are running? And can you show a snippet of the code where you are having the problem?

@AdamNix
Copy link
Author

AdamNix commented Mar 24, 2023

Go to Google Images itself. i.e. the search engine not the Python program.
Type marvunapp deqrz as your search query.
Google Images returns zero results(Google images not Google search)
When I run the same search query in my python program using google_images_download as an import, the python program returns the above errors.
n.b. the code and google-images-download works fine for every other search i.e. ones in which Google images itself does return images.
And I am only looking for 7 images per search.

Then:
I went into google_images_download, the imported program.
Removed line 251.
Added new arguments in the imported code itself with "Bugs Bunny" as a type of go-to default search when original search has zero images. That did not work. Put line 251 back in.
All changes were made after updating line 406 (info = data[25]), and I tried your updated code.

What I was trying to do, in the imported code, was to have a Bugs Bunny default. If Google Images(the search engine) has no images for a search, rather than google-images-download returning an error and stopping the program, the program runs the search again with bugs bunny as the query. So if you have multiple independent searches, the code does not stop on one bad apple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants