Add Photo.getSafetyLevel() (#173)#174
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #173.
Problem
There is no
flickr.photos.getSafetyLevelendpoint, 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 bysearchwithextras="safety_level") — it just wasn't surfaced conveniently. This PR:Photo.getSafetyLevel()helper that loads the photo if needed and returns the level as anint(0=none,1=safe,2=moderate,3=restricted) — matching the valuessetSafetyLevelaccepts.intconverter forsafety_levelsophoto.safety_levelis a consistent integer however the photo was fetched.Usage
Tests
Adds tests covering the int conversion via
getInfo,getSafetyLevel()triggering a load when the value is unknown, andgetSafetyLevel()avoiding a call when the value is already present. Full suite (285 tests),mypy, andflake8all pass.🤖 Generated with Claude Code