MCPcopy
hub / github.com/InstaPy/InstaPy / like_by_locations

Method like_by_locations

instapy/instapy.py:1479–1704  ·  view source on GitHub ↗

Likes (default) 50 images per given locations

(
        self,
        locations: list = None,
        amount: int = 50,
        media: str = None,
        skip_top_posts: bool = True,
        randomize: bool = False,
    )

Source from the content-addressed store, hash-verified

1477 self.simulation = {"enabled": True, "percentage": percentage}
1478
1479 def like_by_locations(
1480 self,
1481 locations: list = None,
1482 amount: int = 50,
1483 media: str = None,
1484 skip_top_posts: bool = True,
1485 randomize: bool = False,
1486 ):
1487 """Likes (default) 50 images per given locations"""
1488 if self.aborting:
1489 return self
1490
1491 liked_img = 0
1492 already_liked = 0
1493 inap_img = 0
1494 commented = 0
1495 followed = 0
1496 not_valid_users = 0
1497
1498 locations = locations or []
1499 self.quotient_breach = False
1500
1501 if randomize is True:
1502 random.shuffle(locations)
1503
1504 for index, location in enumerate(locations):
1505 if self.quotient_breach:
1506 break
1507
1508 self.logger.info("Location [{}/{}]".format(index + 1, len(locations)))
1509 self.logger.info("--> {}".format(location.encode("utf-8")))
1510
1511 try:
1512 links = get_links_for_location(
1513 self.browser, location, amount, self.logger, media, skip_top_posts
1514 )
1515 except NoSuchElementException as exc:
1516 self.logger.warning(
1517 "Error occurred while getting images from location: {} "
1518 "~maybe too few images exist\n\t{}\n".format(
1519 location, str(exc).encode("utf-8")
1520 )
1521 )
1522 continue
1523
1524 for i, link in enumerate(links):
1525 if self.jumps["consequent"]["likes"] >= self.jumps["limit"]["likes"]:
1526 self.logger.warning(
1527 "--> Like quotient reached its peak!\t~leaving "
1528 "Like-By-Locations activity\n"
1529 )
1530 self.quotient_breach = True
1531 # reset jump counter after a breach report
1532 self.jumps["consequent"]["likes"] = 0
1533 break
1534
1535 self.logger.info("Like# [{}/{}]".format(i + 1, len(links)))
1536 self.logger.info(link)

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected