MCPcopy
hub / github.com/InstaPy/InstaPy / unfollow_user

Function unfollow_user

instapy/unfollow_util.py:1293–1410  ·  view source on GitHub ↗

Unfollow a user either from the profile or post page or dialog box

(
    browser,
    track,
    username,
    person,
    person_id,
    button,
    relationship_data,
    logger,
    logfolder,
)

Source from the content-addressed store, hash-verified

1291
1292
1293def unfollow_user(
1294 browser,
1295 track,
1296 username,
1297 person,
1298 person_id,
1299 button,
1300 relationship_data,
1301 logger,
1302 logfolder,
1303):
1304 """Unfollow a user either from the profile or post page or dialog box"""
1305 # list of available tracks to unfollow in: ["profile", "post dialog]
1306 # check action availability
1307 if quota_supervisor("unfollows") == "jump":
1308 return False, "jumped"
1309
1310 if track in ["profile", "post"]:
1311 # Method of unfollowing from a user's profile page or post page
1312 if track == "profile":
1313 user_link = "https://www.instagram.com/{}/".format(person)
1314 web_address_navigator(browser, user_link)
1315
1316 # find out CURRENT follow status
1317 following_status, follow_button = get_following_status(
1318 browser, track, username, person, person_id, logger, logfolder
1319 )
1320
1321 if following_status in ["Following", "Requested"]:
1322 click_element(browser, follow_button) # click to unfollow
1323 sleep(4) # TODO: use explicit wait here
1324 confirm_unfollow(browser)
1325 unfollow_state, msg = verify_action(
1326 browser,
1327 "unfollow",
1328 track,
1329 username,
1330 person,
1331 person_id,
1332 logger,
1333 logfolder,
1334 )
1335 if unfollow_state is not True:
1336 return False, msg
1337
1338 elif following_status in ["Follow", "Follow Back"]:
1339 logger.info(
1340 "--> Already unfollowed '{}'! or a private user that "
1341 "rejected your req".format(person)
1342 )
1343 post_unfollow_cleanup(
1344 ["successful", "uncertain"],
1345 username,
1346 person,
1347 relationship_data,
1348 person_id,
1349 logger,
1350 logfolder,

Callers 7

unfollowFunction · 0.85
follow_user_followersMethod · 0.85
follow_user_followingMethod · 0.85

Calls 13

quota_supervisorFunction · 0.90
web_address_navigatorFunction · 0.85
get_following_statusFunction · 0.85
click_elementFunction · 0.85
sleepFunction · 0.85
confirm_unfollowFunction · 0.85
verify_actionFunction · 0.85
post_unfollow_cleanupFunction · 0.85
emergency_exitFunction · 0.85
EventClass · 0.85
update_activityFunction · 0.85
get_action_delayFunction · 0.85

Tested by

no test coverage detected