Fetches the number of links specified by amount and returns a list of links
(
browser,
username,
person,
amount,
logger,
logfolder,
randomize=False,
media=None,
taggedImages=False,
)
| 427 | |
| 428 | |
| 429 | def get_links_for_username( |
| 430 | browser, |
| 431 | username, |
| 432 | person, |
| 433 | amount, |
| 434 | logger, |
| 435 | logfolder, |
| 436 | randomize=False, |
| 437 | media=None, |
| 438 | taggedImages=False, |
| 439 | ): |
| 440 | """ |
| 441 | Fetches the number of links specified by amount and returns a list of links |
| 442 | """ |
| 443 | |
| 444 | if media is None: |
| 445 | # All known media types |
| 446 | media = MEDIA_ALL_TYPES |
| 447 | elif media == MEDIA_PHOTO: |
| 448 | # Include posts with multiple images in it |
| 449 | media = [MEDIA_PHOTO, MEDIA_CAROUSEL] |
| 450 | else: |
| 451 | # Make it an array to use it in the following part |
| 452 | media = [media] |
| 453 | |
| 454 | logger.info("Getting {} image list...".format(person)) |
| 455 | |
| 456 | user_link = "https://www.instagram.com/{}/".format(person) |
| 457 | if taggedImages: |
| 458 | user_link = user_link + "tagged/" |
| 459 | |
| 460 | # if private user, we can get links only if we following |
| 461 | following_status, _ = get_following_status( |
| 462 | browser, "profile", username, person, None, logger, logfolder |
| 463 | ) |
| 464 | |
| 465 | # Check URL of the webpage, if it already is user's profile page, |
| 466 | # then do not navigate to it again |
| 467 | web_address_navigator(browser, user_link) |
| 468 | |
| 469 | if not is_page_available(browser, logger): |
| 470 | logger.error( |
| 471 | "Instagram error: The link you followed may be broken, or the " |
| 472 | "page may have been removed..." |
| 473 | ) |
| 474 | return False |
| 475 | |
| 476 | # if following_status is None: |
| 477 | # browser.wait_for_valid_connection(browser, username, logger) |
| 478 | |
| 479 | # if following_status == 'Follow': |
| 480 | # browser.wait_for_valid_authorization(browser, username, logger) |
| 481 | |
| 482 | is_private = is_private_profile(browser, logger, following_status == "Following") |
| 483 | |
| 484 | if ( |
| 485 | is_private is None |
| 486 | or (is_private is True and following_status not in ["Following", True]) |
no test coverage detected