subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.38k stars 686 forks source link

[BUG] in _send_private_request UnknownError: Media is unavailable #974

Closed Wathfea closed 2 years ago

Wathfea commented 2 years ago

Hi!

First of all thank you @adw0rd for the great work! During the use of the package I got the following error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/davidperlusz/code/affy/affybot/tags.py", line 494, in run_bot
    followed_count, commenters_followed_count, comments_count, likes_count = self.client.interact_tags(
  File "/Users/davidperlusz/code/affy/affybot/instagram.py", line 86, in interact_tags
    for comment in self.session.media_comments(media_id=media.id):
  File "/Users/davidperlusz/code/affy/.venv/lib/python3.9/site-packages/instagrapi/mixins/comment.py", line 40, in media_comments
    result = self.private_request(
  File "/Users/davidperlusz/code/affy/.venv/lib/python3.9/site-packages/instagrapi/mixins/private.py", line 447, in private_request
    raise e
  File "/Users/davidperlusz/code/affy/.venv/lib/python3.9/site-packages/instagrapi/mixins/private.py", line 434, in private_request
    self._send_private_request(endpoint, **kwargs)
  File "/Users/davidperlusz/code/affy/.venv/lib/python3.9/site-packages/instagrapi/mixins/private.py", line 354, in _send_private_request
    raise UnknownError(**last_json)
instagrapi.exceptions.UnknownError: Media is unavailable

I'am not sure if this is a real bug or not because I encountered this situation once. Maybe the user deleted the media? Is it possible to check this before interaction?

adw0rd commented 2 years ago

The user may have deleted the post, or you have entered the wrong ID, or you have been banned by the user, or the user has a private profile