jarrodnorwell / InstaPy2

Instagram automation tool for farming comments, follows and likes, written in Python
GNU General Public License v3.0
49 stars 9 forks source link

AttributeError: 'InstaPy2' object has no attribute '_InstaPy2__medias_tag'. Did you mean: '_InstaPy2Base__medias_tag'? #5

Closed voxoff79 closed 1 year ago

voxoff79 commented 1 year ago

Hi @official-antique i'm getting this error can you help?

Traceback (most recent call last): File "/instaPy2/script.py", line 7, in session.like(amount=10, iterable=['python'], type=LikeType.Tags) File "/usr/local/lib/python3.11/site-packages/instapy2/instapy2.py", line 239, in like medias = self.medias_tag(amount=amount, tag=tag, randomize_media=randomize_media, skip_top=skip_top) ^^^^^^^^^^^^^^^^^ AttributeError: 'InstaPy2' object has no attribute '_InstaPy2medias_tag'. Did you mean: '_InstaPy2Base__medias_tag'?

thanks for your work!

jarrodnorwell commented 1 year ago

Hey @voxoff79,

This should be fixed in the latest GitHub and PyPI versions (0.0.26).

voxoff79 commented 1 year ago

thanks @official-antique, i manage to get it work but now only works the first time when i try to run the script again:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/public.py", line 130, in _send_public_request response.raise_for_status() File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://www.instagram.com/explore/tags/xxxx/?__a=1&__d=dis

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/hashtag.py", line 418, in hashtag_medias_recent medias = self.hashtag_medias_recent_a1(name, amount) File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/hashtag.py", line 381, in hashtag_medias_recent_a1 return self.hashtag_medias_a1(name, amount, tab_key="edge_hashtag_to_media") File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/hashtag.py", line 220, in hashtag_mediasa1 medias, = self.hashtag_medias_a1_chunk(name, amount, tab_key) File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/hashtag.py", line 164, in hashtag_medias_a1_chunk data = self.public_a1_request( File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/public.py", line 173, in public_a1_request response = self.public_request( File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/public.py", line 91, in public_request raise e File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/public.py", line 74, in public_request return self._send_public_request(url, **kwargs) File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/public.py", line 163, in _send_public_request raise ClientError(e, response=e.response) instagrapi.exceptions.ClientError: 401 Client Error: Unauthorized for url: https://www.instagram.com/explore/tags/xxx/?__a=1&__d=dis

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 302, in _send_private_request response.raise_for_status() File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://i.instagram.com/api/v1/tags/oportobyfoot/sections/

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/xxx/Desktop/instaPy2/script.py", line 7, in session.like(amount=10, iterable=['xxx'], type=LikeType.Tags) File "/usr/local/lib/python3.10/site-packages/instapy2/instapy2.py", line 221, in like medias = self.medias_tag(amount=amount, tag=tag, randomize_media=randomize_media, skip_top=skip_top) File "/usr/local/lib/python3.10/site-packages/instapy2/instapy2_base.py", line 44, in medias_tag medias += [media for media in self.session.hashtag_medias_recent(name=tag, amount=amount) if not any(username in media.user.username for username in self.configuration.people.users_to_skip)] File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/hashtag.py", line 420, in hashtag_medias_recent medias = self.hashtag_medias_recent_v1(name, amount) File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/hashtag.py", line 399, in hashtag_medias_recent_v1 return self.hashtag_medias_v1(name, amount, tab_key="recent") File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/hashtag.py", line 302, in hashtag_mediasv1 medias, = self.hashtag_medias_v1_chunk(name, amount, tab_key) File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/hashtag.py", line 259, in hashtag_medias_v1_chunk result = self.private_request( File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 451, in private_request raise e File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 438, in private_request self._send_private_request(endpoint, kwargs) File "/usr/local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 327, in _send_private_request raise LoginRequired(response=e.response, last_json) instagrapi.exceptions.LoginRequired: login_required

thnks in advance

jarrodnorwell commented 1 year ago

@voxoff79 login_required usually means you'll have to delete the settings.json and relogin, it seems to be a bug with authentication I've also found with creating a post.

I'll probably have to add a function to do or check that.

voxoff79 commented 1 year ago

yes, if i delete the settings.json file it works again but i need to re enter the verification code etc. Thanks.

jarrodnorwell commented 1 year ago

That should only be needed once, once you have the new .json file you just need the username and password.

voxoff79 commented 1 year ago

Yes but as you say "you'll have to delete the settings.json and relogin".

When i do that it works the first time (when the json file doesn't exists) then later when i try again to run the script it appears the error message instagrapi.exceptions.LoginRequired: login_required but in the beginning of the error message says [INFO]: Successfully logged in as: xxx

So it only works when the json files doesn't exists.

I hope this helps!

thnks