Skip to content

Fix Selenium Flickr Photo Dump Max Limit#37

Open
AnaisPerron wants to merge 1 commit intomainfrom
anais/fetch-merge-fix
Open

Fix Selenium Flickr Photo Dump Max Limit#37
AnaisPerron wants to merge 1 commit intomainfrom
anais/fetch-merge-fix

Conversation

@AnaisPerron
Copy link
Collaborator

Downloads all visible photos from a Flickr album using Selenium, handling infinite scroll and pagination. It collects only real photo URLs (live.staticflickr.com), de-duplicates with a seen set, throttles with human-like pauses, and writes images to ../data/labeled/no. Returns the total number of files saved.

Copy link
Collaborator

@kp-automata kp-automata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some feedback! Very cool stuff. Let me know when it's addressed in this PR

filepath = os.path.join(destination, f"image_{idx}.jpg")
with open(filepath, "wb") as f:
f.write(r.content)
print(f"Downloaded: {filepath}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May you change all the print statement to logging?

new_height = driver.execute_script("return document.body.scrollHeight")
if new_height == last_height:

def human_pause(a=1.2, b=2.4):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool :D

def batch_data_downloader_selenium(url=None, max_pages=9):
"""Downloads images from a Flickr album using Selenium."""
url = url or "https://www.flickr.com/photos/esa_events/albums/72157716491073681/"
destination = "../data/labeled/no"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's save it somewhere else. Let's say ../data/flickr_captures
Ideally use the path utils utility function to resolve the data directory

"""
# TODO: Hardcoded url for now, if needed expose this for customization
url = "https://www.flickr.com/photos/esa_events/albums/72157716491073681/"
def batch_data_downloader_selenium(url=None, max_pages=9):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it a class because it has nested functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants