InstaPy / instapy-quickstart

💨 Simply get InstaPy up and running in minutes.
GNU General Public License v3.0
765 stars 796 forks source link

No idea please help #251

Open sector13ghost opened 2 years ago

sector13ghost commented 2 years ago

image line 1980 image line 619 image Then all this and more i dont have a clue what is wrong im no expert ^^

Error occurs after clicking on a photo

mikestan commented 2 years ago

Having the same issue here within the past week or so - whenever the first image gets clicked the session ends and the following traceback occurs:

Traceback (most recent call last): File "/home/ubuntu/quickstart.py", line 60, in session.like_by_tags(my_hashtags, amount=20, media=None, interact=True) File "/home/ubuntu/.local/lib/python3.9/site-packages/instapy/instapy.py", line 1980, in like_by_tags inappropriate, user_name, is_video, reason, scope = check_link( File "/home/ubuntu/.local/lib/python3.9/site-packages/instapy/like_util.py", line 619, in check_link media = post_page[0]["shortcode_media"] KeyError: 0

Running instapy 0.6.16 headless on Ubuntu / RPi B+...

omertacs commented 2 years ago

I'm having the same issue. Session dies on the first image.

dabudeveloper commented 2 years ago

Same issue here, still happens.

uvzz commented 2 years ago

simple fix (please note that I ignored the owner_comments whatever it is):

in like_util.py line 619 remove these lines:

    media = post_page[0]["shortcode_media"]
    is_video = media["is_video"]
    user_name = media["owner"]["username"]
    image_text = media["caption"]

    owner_comments = browser.execute_script(
        """
        latest_comments = window._sharedData.entry_data.PostPage[
        0].media.comments.nodes;
        if (latest_comments === undefined) {
            latest_comments = Array();
            owner_comments = latest_comments
                .filter(item => item.user.username == arguments[0])
                .map(item => item.text)
                .reduce((item, total) => item + '\\n' + total, '');
            return owner_comments;}
        else {
            return null;}
    """,
        user_name,
    )

if owner_comments == "":
    owner_comments = None

and add this instead:

    '''
    original code:

    media = post_page[0]["shortcode_media"]
    is_video = media["is_video"]
    user_name = media["owner"]["username"]
    image_text = media["caption"]
    '''

    # fixed by uvzz
    media = post_page["items"][0]
    is_video = media["is_unified_video"]
    user_name = media["user"]["username"]
    image_text = media["caption"]["text"]

    '''
   commenting this out:

    owner_comments = browser.execute_script(
        """
        latest_comments = window._sharedData.entry_data.PostPage[
        0].media.comments.nodes;
        if (latest_comments === undefined) {
            latest_comments = Array();
            owner_comments = latest_comments
                .filter(item => item.user.username == arguments[0])
                .map(item => item.text)
                .reduce((item, total) => item + '\\n' + total, '');
            return owner_comments;}
        else {
            return null;}
    """,
        user_name,
    )

if owner_comments == "":
    owner_comments = None
'''

# added this line instead 
owner_comments = None
sector13ghost commented 2 years ago

It is now liking 1 photo and then I am getting more errors:

File "C:\python\Insta\instabot.py", line 12, in session.like_by_tags(['cats','funnypets'], amount = 10) File "C:\Users\X\AppData\Local\Programs\Python\Python310\lib\site-packages\instapy\instapy.py", line 2059, in like_by_tags success = process_comments( File "C:\Users\X\AppData\Local\Programs\Python\Python310\lib\site-packages\instapy\comment_util.py", line 445, in process_comments commented_image, message = verify_commented_image(browser, link, owner, logger) File "C:\Users\X\AppData\Local\Programs\Python\Python310\lib\site-packages\instapy\comment_util.py", line 366, in verify_commented_image data = getMediaData("edge_media_to_parent_comment", browser) File "C:\Users\X\AppData\Local\Programs\Python\Python310\lib\site-packages\instapy\util.py", line 523, in getMediaData data = additional_data["graphql"]["shortcode_media"] KeyError: 'graphql'

Any known fixes to this?

Chessy11 commented 2 years ago

https://github.com/InstaPy/InstaPy/pull/6467

Check this one .