MCPcopy
hub / github.com/InstaPy/InstaPy / join_pods

Method join_pods

instapy/instapy.py:5908–6024  ·  view source on GitHub ↗

Join pods

(self, topic: str = "general", engagement_mode: str = "normal")

Source from the content-addressed store, hash-verified

5906 return self
5907
5908 def join_pods(self, topic: str = "general", engagement_mode: str = "normal"):
5909 """Join pods"""
5910 if topic not in self.allowed_pod_topics:
5911 self.logger.error(
5912 "You have entered an invalid topic for pods, allowed topics are : {}. Exiting...".format(
5913 self.allowed_pod_topics
5914 )
5915 )
5916 return self
5917
5918 if engagement_mode not in self.allowed_pod_engagement_modes:
5919 self.logger.error(
5920 "You have entered an invalid engagement_mode for pods, allowed engagement_modes are : {}. Exiting...".format(
5921 self.allowed_pod_engagement_modes
5922 )
5923 )
5924 return self
5925
5926 if self.comments is not None and len(self.comments) < 10:
5927 self.logger.error(
5928 "You have too few comments, please set at least 10 distinct comments to avoid looking suspicious."
5929 )
5930 return self
5931
5932 user_link = "https://www.instagram.com/{}/".format(self.username)
5933 web_address_navigator(self.browser, user_link)
5934 try:
5935 pod_posts = get_recent_posts_from_pods(topic, self.logger)
5936 self.logger.info("Downloaded pod_posts : {}".format(pod_posts))
5937
5938 sleep(2)
5939 post_link_elems = self.browser.find_elements(
5940 By.XPATH, "//a[contains(@href, '/p/')]"
5941 )
5942 post_links = []
5943 post_link = None
5944
5945 for post_link_elem in post_link_elems:
5946 try:
5947 post_link = post_link_elem.get_attribute("href")
5948 post_links.append(post_link)
5949 except Exception as e:
5950 self.logger.error(
5951 "Can not get href for {} - {}".format(post_link, e)
5952 )
5953 continue
5954
5955 post_links = list(set(post_links))
5956 my_recent_post_ids = []
5957 for post_link in post_links:
5958 try:
5959 web_address_navigator(self.browser, post_link)
5960 sleep(2)
5961 time_element = self.browser.find_element(By.XPATH, "//div/a/time")
5962 post_datetime_str = time_element.get_attribute("datetime")
5963 post_datetime = datetime.strptime(
5964 post_datetime_str, "%Y-%m-%dT%H:%M:%S.%fZ"
5965 )

Callers

nothing calls this directly

Calls 7

engage_with_postsMethod · 0.95
web_address_navigatorFunction · 0.85
sleepFunction · 0.85
share_my_post_with_podsFunction · 0.85
group_postsFunction · 0.85

Tested by

no test coverage detected