-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c879f2
commit 4db9ee8
Showing
7 changed files
with
329 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from ensta.Guest import Guest | ||
from ensta.Host import Host | ||
from ensta.Authentication import NewSessionID | ||
from .lib import Exceptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
from ensta.containers import PostUser | ||
from dataclasses import dataclass, field | ||
from ensta import Host | ||
from ensta.lib.Commons import refresh_csrf_token | ||
from json import JSONDecodeError | ||
|
||
|
||
@dataclass(frozen=False) | ||
class Post: | ||
_instance: type[Host] | None = None | ||
share_url: str = "" | ||
taken_at: int = 0 | ||
unique_key: str = "" | ||
media_type: int = 0 | ||
code: str = "" | ||
caption_is_edited: bool = False | ||
original_media_has_visual_reply_media: bool = False | ||
like_and_view_counts_disabled: bool = False | ||
can_viewer_save: bool = False | ||
profile_grid_control_enabled: bool = False | ||
is_comments_gif_composer_enabled: bool = False | ||
comment_threading_enabled: bool = False | ||
comment_count: int = 0 | ||
has_liked: bool = False | ||
user: PostUser = field(default_factory=PostUser) | ||
can_viewer_reshare: bool = False | ||
like_count: int = 0 | ||
top_likers: list[str] = field(default_factory=list) | ||
caption_text: str = "" | ||
is_caption_covered: bool = False | ||
caption_created_at: int = 0 | ||
caption_share_enabled: bool = False | ||
caption_did_report_as_spam: bool = False | ||
is_paid_partnership: bool = False | ||
show_shop_entrypoint: bool = False | ||
deleted_reason: int = 0 | ||
integrity_review_decision: str = "" | ||
ig_media_sharing_disabled: bool = False | ||
has_shared_to_fb: int = 0 | ||
is_unified_video: bool = False | ||
should_request_ads: bool = False | ||
is_visual_reply_commenter_notice_enabled: bool = False | ||
commerciality_status: str = "" | ||
explore_hide_comments: bool = False | ||
has_delayed_metadata: bool = False | ||
location_latitude: float = 0 | ||
location_longitude: float = 0 | ||
|
||
def _like_action(self, action: str = "like") -> bool: | ||
if self.unique_key == "": return False | ||
|
||
refresh_csrf_token(self._instance) | ||
request_headers = { | ||
"accept": "*/*", | ||
"accept-language": "en-US,en;q=0.9", | ||
"content-type": "application/x-www-form-urlencoded", | ||
"sec-ch-prefers-color-scheme": self._instance.preferred_color_scheme, | ||
"sec-ch-ua": "\"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"114\", \"Google Chrome\";v=\"114\"", | ||
"sec-ch-ua-full-version-list": "\"Not.A/Brand\";v=\"8.0.0.0\", \"Chromium\";v=\"114.0.5735.110\", \"Google Chrome\";v=\"114.0.5735.110\"", | ||
"sec-ch-ua-mobile": "?0", | ||
"sec-ch-ua-platform": "\"Windows\"", | ||
"sec-ch-ua-platform-version": "\"15.0.0\"", | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin", | ||
"viewport-width": "1475", | ||
"x-asbd-id": "129477", | ||
"x-csrftoken": self._instance.csrf_token, | ||
"x-ig-app-id": self._instance.insta_app_id, | ||
"x-ig-www-claim": self._instance.x_ig_www_claim, | ||
"x-instagram-ajax": "1007670408", | ||
"x-requested-with": "XMLHttpRequest", | ||
"Referer": f"https://www.instagram.com/p/{self.code}/", | ||
"Referrer-Policy": "strict-origin-when-cross-origin" | ||
} | ||
|
||
try: | ||
http_response = self._instance.request_session.post(f"https://www.instagram.com/api/v1/web/likes/{self.unique_key}/{action}/", headers=request_headers) | ||
response_json = http_response.json() | ||
|
||
if "status" in response_json: | ||
return response_json["status"] == "ok" | ||
else: | ||
return False | ||
except JSONDecodeError: | ||
return False | ||
|
||
def like(self) -> bool: | ||
return self._like_action("like") | ||
|
||
def unlike(self) -> bool: | ||
return self._like_action("unlike") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from dataclasses import dataclass, field | ||
|
||
|
||
@dataclass(frozen=False) | ||
class PostUser: | ||
has_anonymous_profile_picture: bool = False | ||
fbid_v2: str = "" | ||
transparency_product_enabled: bool = False | ||
is_favorite: bool = False | ||
is_unpublished: bool = False | ||
uid: str = "" | ||
username: str = "" | ||
full_name: str = "" | ||
is_private: bool = False | ||
is_verified: bool = False | ||
profile_picture_id: str = "" | ||
profile_picture_url: str = "" | ||
account_badges: list = field(default_factory=list) | ||
feed_post_reshare_disabled: bool = False | ||
show_account_transparency_details: bool = False | ||
third_party_downloads_enabled: int = 0 | ||
latest_reel_media: int = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,15 +6,15 @@ | |
setup( | ||
name="ensta", | ||
packages=["ensta", "ensta.lib", "ensta.containers"], | ||
version="2.5", | ||
version="2.6", | ||
license="MIT", | ||
description="🔥 Fastest & Simplest Python Package For Instagram Automation", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
author="Deepak Soni", | ||
author_email="[email protected]", | ||
url="https://github.com/diezo/ensta", | ||
download_url="https://github.com/diezo/ensta/archive/refs/tags/v2.5.tar.gz", | ||
download_url="https://github.com/diezo/ensta/archive/refs/tags/v2.6.tar.gz", | ||
keywords=["instagram-client", "instagram", "api-wrapper", "instagram-scraper", "instagram-api", "instagram-sdk", "instagram-photos", "instagram-api-python", "instabot", "instagram-stories", "instagram-bot", "instapy", "instagram-downloader", "instagram-account", "instagram-crawler", "instagram-private-api", "igtv", "instagram-automation", "reels", "instagram-feed"], | ||
install_requires=["requests", "selenium"], | ||
classifiers=[ | ||
|