Skip to content

Add Photo.getSafetyLevel() (#173)#174

Merged
beaufour merged 1 commit into
masterfrom
add-get-safety-level
Jul 1, 2026
Merged

Add Photo.getSafetyLevel() (#173)#174
beaufour merged 1 commit into
masterfrom
add-get-safety-level

Conversation

@beaufour

@beaufour beaufour commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Closes #173.

Problem

There is no flickr.photos.getSafetyLevel endpoint, so it wasn't obvious how to read a photo's safety level (e.g. to find photos with a given tag, check the level, and fix it if wrong).

Solution

The safety level is returned by flickr.photos.getInfo (and by search with extras="safety_level") — it just wasn't surfaced conveniently. This PR:

  • Adds a Photo.getSafetyLevel() helper that loads the photo if needed and returns the level as an int (0=none, 1=safe, 2=moderate, 3=restricted) — matching the values setSafetyLevel accepts.
  • Registers an int converter for safety_level so photo.safety_level is a consistent integer however the photo was fetched.

Usage

# Efficient bulk check via search extras (no per-photo call)
for p in flickr_api.Photo.search(tags="mytag", extras="safety_level"):
    if p.getSafetyLevel() != 3:
        p.setSafetyLevel(safety_level=3)

Tests

Adds tests covering the int conversion via getInfo, getSafetyLevel() triggering a load when the value is unknown, and getSafetyLevel() avoiding a call when the value is already present. Full suite (285 tests), mypy, and flake8 all pass.

🤖 Generated with Claude Code

Flickr has no flickr.photos.getSafetyLevel endpoint, but the safety level
is returned by flickr.photos.getInfo (and by search with
extras="safety_level"). Expose it conveniently:

- Add a Photo.getSafetyLevel() helper that loads the photo if needed and
  returns the level as an int (0=none, 1=safe, 2=moderate, 3=restricted),
  matching the values setSafetyLevel accepts.
- Register an int converter for safety_level so photo.safety_level is a
  consistent integer however the photo was fetched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@beaufour beaufour merged commit 7b65c3f into master Jul 1, 2026
5 checks passed
@beaufour beaufour deleted the add-get-safety-level branch July 1, 2026 10:35
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.

get SafetyLevel for individual photo

1 participant