MCPcopy
hub / github.com/InstaPy/InstaPy / like_by_users

Method like_by_users

instapy/instapy.py:2163–2415  ·  view source on GitHub ↗

Likes some amounts of images for each usernames

(
        self,
        usernames: list,
        amount: int = 10,
        randomize: bool = False,
        media: str = None,
    )

Source from the content-addressed store, hash-verified

2161 return self
2162
2163 def like_by_users(
2164 self,
2165 usernames: list,
2166 amount: int = 10,
2167 randomize: bool = False,
2168 media: str = None,
2169 ):
2170 """Likes some amounts of images for each usernames"""
2171 if self.aborting:
2172 return self
2173
2174 if not isinstance(usernames, list):
2175 usernames = [usernames]
2176
2177 # standalone means this feature is started by the user
2178 standalone = (
2179 True if "like_by_users" not in self.internal_usage.keys() else False
2180 )
2181 # skip validation in case of it is already accomplished
2182 users_validated = (
2183 True
2184 if not standalone and not self.internal_usage["like_by_users"]["validate"]
2185 else False
2186 )
2187
2188 username = None
2189 liked_img = 0
2190 total_liked_img = 0
2191 already_liked = 0
2192 inap_img = 0
2193 commented = 0
2194 followed = 0
2195 not_valid_users = 0
2196
2197 usernames = usernames or []
2198 self.quotient_breach = False
2199
2200 for index, username in enumerate(usernames):
2201 if self.quotient_breach:
2202 break
2203
2204 self.logger.info("Username [{}/{}]".format(index + 1, len(usernames)))
2205 self.logger.info("--> {}".format(username.encode("utf-8")))
2206
2207 following = random.randint(0, 100) <= self.follow_percentage
2208
2209 if not users_validated:
2210 validation, details = self.validate_user_call(username)
2211 if not validation:
2212 self.logger.info("--> Not a valid user: {}".format(details))
2213 not_valid_users += 1
2214 continue
2215
2216 try:
2217 links = get_links_for_username(
2218 self.browser,
2219 self.username,
2220 username,

Callers 2

like_by_tagsMethod · 0.95

Calls 10

validate_user_callMethod · 0.95
query_clarifaiMethod · 0.95
get_links_for_usernameFunction · 0.85
follow_restrictionFunction · 0.85
follow_userFunction · 0.85
sleepFunction · 0.85
check_linkFunction · 0.85
verify_likingFunction · 0.85
like_imageFunction · 0.85
process_commentsFunction · 0.85

Tested by

no test coverage detected