InstaLooter icon indicating copy to clipboard operation
InstaLooter copied to clipboard

CRITICAL 'graphql' is output, then the script dies

Open haltefest opened this issue 5 years ago • 11 comments

Environment: Instalooter 2.4.0, Windows , Python 3.7.3

Test: instaLooter user

That outputs CRITICAL 'graphql' (including quotes) and does not seem to do much else. Some (1-2) pictures are downloaded though. IG user name does not matter, the error is reproducible with any user.

The issue came up after upgrading to 2.4.0.

Traceback (most recent call last):
  File "C:\Users\X\AppData\Roaming\Python\Python37\site-packages\instalooter\cli\__init__.py", line 173, in main dlpbar_cls=None if args['--quiet'] else TqdmProgressBar)
  File "C:\Users\X\AppData\Roaming\Python\Python37\site-packages\instalooter\looters.py", line 467, in download new_only, condition)
  File "C:\Users\X\AppData\Roaming\Python\Python37\site-packages\instalooter\looters.py", line 616, in _fill_media_queue media = self.get_post_info(media['shortcode'])
  File "C:\Users\X\AppData\Roaming\Python\Python37\site-packages\instalooter\looters.py", line 349, in get_post_info return data['entry_data']['PostPage'][0]['graphql']['shortcode_media']

I understand that there is no 'graphql' key available in data['entry_data']['PostPage'][0] at some point, though the program expects it to be there.

Any help or hints for debugging (I do have basic knowledge of Python) is much appreciated.

haltefest avatar Oct 27 '19 17:10 haltefest

same error using instaloader...

nagualcode avatar Oct 27 '19 23:10 nagualcode

I looked into the code. The exception is thrown in the method get_post_info called by _fill_media_queue.

If we rewrite get_post_info like that:

    def get_post_info(self, code):

        url = "https://www.instagram.com/p/{}/".format(code)
        with self.session.get(url) as res:
            data = get_shared_data(res.text)
            
            if 'graphql' in data['entry_data']['PostPage'][0]:
                return data['entry_data']['PostPage'][0]['graphql']['shortcode_media']
            else:
                return None

and also add a check for None in _fill_media_queue, like that:

        for media in six.moves.filter(_condition, medias_iter):

            # Check if the whole post info is required
            if self.namegen.needs_extended(media) or media["__typename"] != "GraphImage":
                media = self.get_post_info(media['shortcode'])
                
                if media is None:
                    continue

then the script continues smoothly and downloads all posts containing a single image. Videos and posts containing multiple entries are not downloaded.

As I have no idea why this particular dictionary slot was empty in the first place, this is a very coarse hack. I would not recommend using it, of course. Also, it does not really solve the problem

I am sorry if I used Java terminology somewhere. I am not used to Python that much )

haltefest avatar Oct 28 '19 08:10 haltefest

Strange, from this kind of error I'd suppose it'd affect everybody, which is obviously not the case. By the way, can I do something to help working on it?

haltefest avatar Nov 20 '19 16:11 haltefest

This has been happening to me for as long as it has been happening to you, I just keep silently checking the issue for a fix.

I use the CLI and this is an example of the error I get.

2019-11-22 00:31:55 user-pc instalooter.cli[3670] NOTICE Starting download of `zucc`
0it [00:00, ?it/s]
2019-11-22 00:31:58 user-pc instalooter.cli[3670] CRITICAL 'graphql'
2019-11-22 00:31:58 user-pc instalooter.cli[3670] NOTICE Terminating 64 remaining workers...

douglasrizzo avatar Nov 22 '19 03:11 douglasrizzo

Until this bug is fixed, I've found that logging in and out of instalooter temporarily fixes the issue; that is, simply execute instalooter logout followed by either the corresponding instalooter login command or a different instalooter command in which you provide the username and password.

kuchenmitsahne avatar Nov 27 '19 18:11 kuchenmitsahne

Unfortunately this workaround did not work for me :(

St2mZ avatar Nov 28 '19 05:11 St2mZ

@kuchenmitsahne Does not work for me, regrettably. @althonos Can I do something to help you fixing this issue?

haltefest avatar Nov 28 '19 07:11 haltefest

@haltefest @kuchenmitsahne for me it worked, but I have to log out and then log in again to get it to work. Also, you have to log out every time before using it again.

This works:

instalooter logout
instalooter user zucc zucc -u myuser -p 'mypassword'
instalooter logout
instalooter user zucc2 zucc2 -u myuser -p 'mypassword'

These don't work:

instalooter logout
instalooter login
instalooter user zucc zucc
instalooter logout
instalooter user zucc zucc -u myuser -p 'mypassword'
instalooter user zucc2 zucc2 -u myuser -p 'mypassword'

douglasrizzo avatar Nov 28 '19 18:11 douglasrizzo

@douglasrizzo thanks, now I understand how to use it and it actually works.

St2mZ avatar Nov 28 '19 20:11 St2mZ

I have created pull request #273 with fix for this issue

St2mZ avatar Dec 06 '19 12:12 St2mZ

I've got quite the same error

Alepod avatar Mar 23 '22 21:03 Alepod