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

TypeError: 'NoneType' object is not subscriptable

Open rafarios opened this issue 2 years ago • 5 comments

Hi. Using 2.8.0, It was working properly yesterday, buy today I receive this error. Can you review it?

Traceback (most recent call last): File "/usr/local/bin/googleimagesdownload", line 11, in load_entry_point('google-images-download==2.8.0', 'console_scripts', 'googleimagesdownload')() File "/usr/local/lib/python3.7/dist-packages/google_images_download-2.8.0-py3.7.egg/google_images_download/google_images_download.py", line 1134, in main File "/usr/local/lib/python3.7/dist-packages/google_images_download-2.8.0-py3.7.egg/google_images_download/google_images_download.py", line 952, in download File "/usr/local/lib/python3.7/dist-packages/google_images_download-2.8.0-py3.7.egg/google_images_download/google_images_download.py", line 1087, in download_executor File "/usr/local/lib/python3.7/dist-packages/google_images_download-2.8.0-py3.7.egg/google_images_download/google_images_download.py", line 888, in _get_all_items TypeError: 'NoneType' object is not subscriptable

rafarios avatar Sep 25 '21 08:09 rafarios

Hi @rafarios,

Have you the same issue with the Joeclinton1 version which is more up to date ?

You can install it with

git clone https://github.com/Joeclinton1/google-images-download.git
cd google-images-download && python setup.py install

NicolasGrosjean avatar Sep 25 '21 13:09 NicolasGrosjean

'183836587' is no longer included in 'image_object'. In my case, I commented out line 391 of google_images_download.py and now I can run it.

def format_object(self, object):
        data = object[1]
        main = data[3]
        info = data[9]
        if info is None:
            info = data[11]
        formatted_object = {}
        try:
            formatted_object['image_height'] = main[2]
            formatted_object['image_width'] = main[1]
            formatted_object['image_link'] = main[0]
            formatted_object['image_format'] = main[0][-1 * (len(main[0]) - main[0].rfind(".") - 1):]
            formatted_object['image_description'] = info['2003'][3]
            # formatted_object['image_host'] = info['183836587'][0]
            formatted_object['image_source'] = info['2003'][2]
            formatted_object['image_thumbnail_url'] = data[2][0]
        except Exception as e:
            print(e)
            return None
            
        return formatted_object

is0356xi avatar Sep 26 '21 08:09 is0356xi

Thanks @is0356xi

Now it works!

rafarios avatar Sep 26 '21 09:09 rafarios

I implemented a fix in the most recent commit by changing the location of image_host. Should work now :)

Joeclinton1 avatar Sep 26 '21 14:09 Joeclinton1

I cannot get it to work:

Item no.: 1 --> Item name = Polar bears Evaluating... Starting Download... 'NoneType' object is not subscriptable Traceback (most recent call last): File "/cygdrive/d/dev/git/pythonaf/testGDI.py", line 6, in paths = response.download(arguments) #passing the arguments to the function File "/usr/lib/python3.9/site-packages/google_images_download-2.8.0-py3.9.egg/google_images_download/google_images_download.py", line 970, in download File "/usr/lib/python3.9/site-packages/google_images_download-2.8.0-py3.9.egg/google_images_download/google_images_download.py", line 1118, in download_executor File "/usr/lib/python3.9/site-packages/google_images_download-2.8.0-py3.9.egg/google_images_download/google_images_download.py", line 906, in _get_all_items TypeError: 'NoneType' object is not subscriptable

testGDI.py is:

from google_images_download import google_images_download #importing the library

response = google_images_download.googleimagesdownload() #class instantiation

arguments = {"keywords":"Polar bears,baloons,Beaches","limit":20,"print_urls":True} #creating list of arguments paths = response.download(arguments) #passing the arguments to the function

moisty70 avatar Oct 19 '23 10:10 moisty70