ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.72k stars 1.47k forks source link

[BUG] upload photos - Not yet logged in starting: PRE-LOGIN FLOW! #1317

Closed iraj-jelo closed 4 years ago

iraj-jelo commented 4 years ago

Example file

photos/upload_photos.py

Describe the bug

I get PRE-LOGIN FLOW.

Log

2020-02-23 06:58:42,032 - INFO - Instabot version: 0.109.0 Started
2020-02-23 06:58:42,033 - DEBUG - Bot imported from /usr/local/lib/python3.6/dist-packages/instabot/bot/bot.py
Which account do you want to use? (Type number)
1: ceram_gostar_iranian
0: add another account.
-1: delete all accounts.
1
2020-02-23 06:58:44,643 - INFO - Not yet logged in starting: PRE-LOGIN FLOW!
2020-02-23 06:58:47,593 - DEBUG - POST to endpoint: accounts/contact_point_prefill/ returned response: <Response [200]>
Traceback (most recent call last):
  File "upload_photos.py", line 24, in <module>
    bot.login(username=args.u, password=args.p, proxy=args.proxy, ask_for_code=True)
  File "/usr/local/lib/python3.6/dist-packages/instabot/bot/bot.py", line 443, in login
    if self.api.login(**args) is False:
  File "/usr/local/lib/python3.6/dist-packages/instabot/api/api.py", line 258, in login
    self.pre_login_flow()
  File "/usr/local/lib/python3.6/dist-packages/instabot/api/api.py", line 174, in pre_login_flow
    return pre_login_flow(self)
  File "/usr/local/lib/python3.6/dist-packages/instabot/api/api_login.py", line 107, in pre_login_flow
    self.sync_device_features()
  File "/usr/local/lib/python3.6/dist-packages/instabot/api/api.py", line 153, in sync_device_features
    return sync_device_features(self, login)
  File "/usr/local/lib/python3.6/dist-packages/instabot/api/api_login.py", line 23, in sync_device_features
    data["_uid"] = self.user_id
  File "/usr/local/lib/python3.6/dist-packages/instabot/api/api.py", line 607, in user_id
    return self.cookie_dict["ds_user_id"]
KeyError: 'ds_user_id'

To Reproduce

Steps to reproduce the behavior:

  1. Run 'python upload_photos.py -photo pics/01.jpg -caption test'

Version

Python version (python 3.6): OS: Linux

duplicate-issues[bot] commented 4 years ago

Hey @iraj-jelo,

We did a quick check and this issue looks very darn similar to

This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:

If not, the maintainers will get to this issue shortly.

Cheers, Your Friendly Neighborhood ProBot

valnuro commented 4 years ago

I have this issue too. It's working on version 0.108.0 and older.

bruvv commented 4 years ago

Can you try and remove everything redownload and restart?

valnuro commented 4 years ago

Not working for myself sorry. I tried many things but didn't manage to make it works. I tried on Fedora and CentOS but also using the Dockerfile. But installing version 0.108.0 works if anybody with this issue still wants to use it. pip uninstall instabot pip install instabot==0.108.0

nizarganteng commented 4 years ago

Not working for myself sorry. I tried many things but didn't manage to make it works. I tried on Fedora and CentOS but also using the Dockerfile. But installing version 0.108.0 works if anybody with this issue still wants to use it. pip uninstall instabot pip install instabot==0.108.0

yeah im not working to...

bruvv commented 4 years ago

I am not home and on my phone but please try the dev branch and report back: https://github.com/instagrambot/instabot/tree/development

valnuro commented 4 years ago

Thanks but couldn't make it works sorry. Shouldn't you call sync_device_features(login=True) with login parameter as True during pre login flow as it was before ? Anyway I still got errors after this but I'm pretty new to this bot and Instagram API, that's just an idea.

No need to hurry since it works with older version.

retroworks-main commented 4 years ago

Same problem with new update

bruvv commented 4 years ago

Just updated and test should be working now please test the development branch: https://github.com/instagrambot/instabot/commit/acce113e54f461fe20faa6b38f1be43040db2ee2

Carnivalio commented 4 years ago

Hi @bruvv, after trying the dev branch several times, I got this error message instead now

2020-02-27 17:35:58,409 - INFO - Not yet logged in starting: PRE-LOGIN FLOW!
2020-02-27 17:35:59,721 - DEBUG - POST to endpoint: accounts/contact_point_prefill/ returned response: <Response [200]>
2020-02-27 17:36:01,023 - DEBUG - POST to endpoint: qe/sync/ returned response: <Response [200]>
2020-02-27 17:36:03,359 - DEBUG - POST to endpoint: launcher/sync/ returned response: <Response [200]>
2020-02-27 17:36:03,360 - CRITICAL - Not logged in!
Traceback (most recent call last):
  File "C:\Wrapper.py", line 102, in <module>
    execute_upload(db_path, export_path, ex_caption_path, leading_name, config_path, cookie_path, log_path)
  File "C:\Wrapper.py", line 53, in execute_upload
    insta_bot.login(username=username, password=password, use_cookie=True, cookie_fname=cookie_path)
  File "\instabot\bot\bot.py", line 443, in login
    if self.api.login(**args) is False:
  File "\instabot\api\api.py", line 265, in login
    self.pre_login_flow()
  File "\instabot\api\api.py", line 181, in pre_login_flow
    return pre_login_flow(self)
  File "\instabot\api\api_login.py", line 113, in pre_login_flow
    self.get_prefill_candidates()
  File "\instabot\api\api.py", line 169, in get_prefill_candidates
    return get_prefill_candidates(self)
  File "\instabot\api\api_login.py", line 62, in get_prefill_candidates
    return self.send_request("accounts/get_prefill_candidates/", data)
  File "\instabot\api\api.py", line 486, in send_request
    raise Exception(msg)
Exception: Not logged in!

EDIT:

Fixed with changing return self.send_request("accounts/get_prefill_candidates/", data) To return self.send_request("accounts/get_prefill_candidates/", data, True) on api_login.py line 62

Don't know if it's the right approach

EDIT 2:

Now it can't save cookies

2020-02-27 18:00:16,328 - DEBUG - POST to endpoint: notifications/badge/ returned response: <Response [200]>
2020-02-27 18:00:18,860 - DEBUG - POST to endpoint: qp/batch_fetch/ returned response: <Response [200]>
Traceback (most recent call last):
  File "C:\Wrapper.py", line 98, in <module>
    execute_upload(db_path, export_path, ex_caption_path, leading_name, config_path, cookie_path, log_path)
  File "C:\Wrapper.py", line 49, in execute_upload
    insta_bot.login(username=username, password=password, use_cookie=True, cookie_fname=cookie_path, ask_for_code=True)
  File "\instabot\bot\bot.py", line 443, in login
    if self.api.login(**args) is False:
  File "\instabot\api\api.py", line 296, in login
    self.login_flow(True)
  File "\instabot\api\api.py", line 184, in login_flow
    return login_flow(self, just_logged_in, app_refresh_interval)
  File "\instabot\api\api_login.py", line 281, in login_flow
    self.save_uuid_and_cookie()
  File "\instabot\api\api.py", line 202, in save_uuid_and_cookie
    return save_uuid_and_cookie(self)
  File "\instabot\api\api_login.py", line 407, in save_uuid_and_cookie
    "last_experiments": self.last_experiments,
AttributeError: 'API' object has no attribute 'last_experiments'

I think it should be calling sync_user_features() somewhere before saving the cookies

retroworks-main commented 4 years ago

With development version, and @Carnivalio fix working, but got another error after trying to start like/follow/etc actions

2020-02-27 14:03:17,214 - ERROR - 'ds_user_id'
Traceback (most recent call last):
  File "multi_script_CLI.py", line 662, in <module>
    menu()
  File "multi_script_CLI.py", line 239, in menu
    menu_unfollow()
  File "multi_script_CLI.py", line 513, in menu_unfollow
    bot.unfollow_non_followers()
  File "C:\Program Files\Python38\lib\site-packages\instabot\bot\bot.py", line 850, in unfollow_non_followers
    return unfollow_non_followers(self, n_to_unfollows)
  File "C:\Program Files\Python38\lib\site-packages\instabot\bot\bot_unfollow.py", line 118, in unfollow_non_followers
    non_followers = set(self.following) - set(self.followers) - self.friends_file.set
  File "C:\Program Files\Python38\lib\site-packages\instabot\bot\bot.py", line 328, in following
    self._following = self.get_user_following(self.user_id)
  File "C:\Program Files\Python38\lib\site-packages\instabot\bot\bot.py", line 285, in user_id
    return self.api.user_id
  File "C:\Program Files\Python38\lib\site-packages\instabot\api\api.py", line 630, in user_id
    return self.cookie_dict["ds_user_id"]
KeyError: 'ds_user_id'
bruvv commented 4 years ago

https://github.com/instagrambot/instabot/commit/986a0d4131e82b4e0d932ae3aad7468c7b197bd2 Got it fixed now the login.

nizarganteng commented 4 years ago

Still

bruvv commented 4 years ago

Remove all your json and settings files.