MCPcopy Index your code
hub / github.com/InstaPy/InstaPy / watch_story

Function watch_story

instapy/story_util.py:189–230  ·  view source on GitHub ↗

Load Stories, and watch it until there is no more stores to watch for the related element

(browser, elem, logger, action_type, simulate=False)

Source from the content-addressed store, hash-verified

187
188
189def watch_story(browser, elem, logger, action_type, simulate=False):
190 """
191 Load Stories, and watch it until there is no more stores
192 to watch for the related element
193 """
194
195 # make sure we work with a lower case elem
196 elem = elem.lower()
197
198 if action_type == "tag":
199 story_link = "https://www.instagram.com/explore/tags/{}".format(elem)
200
201 else:
202 story_link = "https://www.instagram.com/{}".format(elem)
203
204 web_address_navigator(browser, story_link)
205 # wait for the page to load
206 time.sleep(randint(2, 6))
207 # order is important here otherwise we are not on the page of the story we want to watch
208 story_data = get_story_data(browser, elem, action_type, logger, simulate)
209
210 if story_data["status"] == "not ok":
211 raise NoSuchElementException
212
213 if story_data["reels_cnt"] == 0:
214 # nothing to watch, there is no stories
215 logger.info(
216 "No stories to watch (either there is none) or we have already watched everything"
217 )
218 return 0
219
220 logger.info(
221 "Watched {} reels from {}: {}".format(
222 story_data["reels_cnt"], action_type, elem.encode("utf-8")
223 )
224 )
225
226 # get the post-story delay time to sleep
227 naply = get_action_delay("story")
228 time.sleep(naply)
229
230 return story_data["reels_cnt"]

Callers 2

story_by_tagsMethod · 0.85
story_by_usersMethod · 0.85

Calls 3

web_address_navigatorFunction · 0.85
get_story_dataFunction · 0.85
get_action_delayFunction · 0.85

Tested by

no test coverage detected