althonos / InstaLooter

Another API-less Instagram pictures and videos downloader.
GNU General Public License v3.0
2k stars 259 forks source link

I am getting "graphql Error" while fetching metaData of videos posts using instalooter 2.4.4. #353

Open Waqas1o1 opened 2 years ago

Waqas1o1 commented 2 years ago

I can't say for sure why this error is coming but it seems like it accounts problem. I am trying to run the following script from python 3.10.0

obj = HashtagLooter(tag, dump_only=True)
 obj.download_videos(f'downloads/{tag}', media_count=10, new_only=self.appendNewOnly) 

Then the Error Rised

Traceback (most recent call last): File "C:\Users\Muhamad Waqas\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner
self.run() File "F:\TECHNOVETIVE\Automation Media\Backend\instagrame\utils.py", line 66, in run obj.download_videos( File "F:\TECHNOVETIVE\Automation Media\Backend\env\lib\site-packages\instalooter\looters.py", line 395, in download_videos return self.download( File "F:\TECHNOVETIVE\Automation Media\Backend\env\lib\site-packages\instalooter\looters.py", line 469, in download
medias_queued = self._fill_media_queue( File "F:\TECHNOVETIVE\Automation Media\Backend\env\lib\site-packages\instalooter\looters.py", line 620, in _fill_media_queue media = self.get_post_info(media['shortcode']) File "F:\TECHNOVETIVE\Automation Media\Backend\env\lib\site-packages\instalooter\looters.py", line 350, in get_post_info if 'graphql' in data['entry_data']['PostPage'][0]:
KeyError: 'PostPage'

richieadler commented 2 years ago

Same here, and also for pictures.

ghost commented 2 years ago

Getting graphql errors here too.

2022-01-26 08:27:51 $user instalooter.cli[6048] NOTICE Starting download of `xxxx`
2022-01-26 08:27:55 $user instalooter.cli[6048] CRITICAL 'graphql'
FilipJanitor commented 2 years ago

It seems like instagram now loads "PostPage" contents dynamically so a simple request to https://www.instagram.com/p/XXXXXX/ will not contain the required data

Lxand3r commented 2 years ago

It seems like instagram now loads "PostPage" contents dynamically so a simple request to https://www.instagram.com/p/XXXXXX/ will not contain the required data

yeah do you think that there is any way to work around that

zambetti commented 2 years ago

I'm also getting those with the comment scraping function, have been for a little over a week

    info = looter.get_post_info(media['shortcode'])
  File "/Library/Python/3.8/site-packages/instalooter/looters.py", line 355, in get_post_info
    return data['graphql']['shortcode_media']
KeyError: 'graphql'

This is correct. If you comment out the offending line (looters.py line 355) and print data, you can see that the data structure returned from instagram has changed (no more 'graphql' or 'shortcode_media'). This sloppy hack (below) prints the new data structure and got it kinda unstuck by mapping the new 'media_type' to the old '__typename', but it failed elsewhere later on.

#return data['graphql']['shortcode_media']
print(data)
result = dict();
result['shortcode'] = data['items'][0]['code']
result['id'] = data['items'][0]['pk']
result['__typename'] = "GraphSidecar"
if data['items'][0]['media_type'] == 1:
    result['__typename'] = "GraphImage"
if data['items'][0]['media_type'] == 2:
    result['__typename'] = "GraphVideo"
return result

It seems this application needs to be significantly re-written to be adapted to the new Instagram API, and it was not written in a modular way that abstracted the API to make it easily swappable.

FilipJanitor commented 2 years ago

It seems to be working again... But only temporarily - after a while the lazyloading kicked in again

Ajit021 commented 2 years ago

Hey Anyone what the go through of the issue I am facing the issues

cyphunk commented 2 years ago

same issue. Implementing the work around from @zambettl results in:

KeyError: 'edge_sidecar_to_children'

gree303 commented 2 years ago

debian 9 python 3.5 same issue