MCPcopy
hub / github.com/InstaPy/InstaPy / get_source_link

Function get_source_link

instapy/clarifai_util.py:112–138  ·  view source on GitHub ↗

Checks to see if a post is an image. If so, returns list with image source URL. If a NoSuchElement exception occurs, checks post for video and returns the source URLs for both the video and the video's keyframe.

(browser)

Source from the content-addressed store, hash-verified

110
111
112def get_source_link(browser):
113 """Checks to see if a post is an image. If so, returns list with image
114 source URL.
115 If a NoSuchElement exception occurs, checks post for video and returns
116 the source URLs
117 for both the video and the video's keyframe."""
118 source = []
119
120 try:
121 source.append(
122 browser.find_element(
123 By.XPATH, read_xpath(get_source_link.__name__, "image")
124 ).get_attribute("src")
125 )
126 except NoSuchElementException:
127 source.append(
128 browser.find_element(
129 By.XPATH, read_xpath(get_source_link.__name__, "video")
130 ).get_attribute("src")
131 )
132 source.append(
133 browser.find_element(
134 By.XPATH, read_xpath(get_source_link.__name__, "image_alt")
135 ).get_attribute("src")
136 )
137
138 return source
139
140
141def get_clarifai_response(clarifai_api, clarifai_model, source_link, check_video):

Callers 1

check_imageFunction · 0.85

Calls 1

read_xpathFunction · 0.85

Tested by

no test coverage detected