|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Flickr Download is a command-line utility for downloading photos from Flickr. It supports downloading individual photos, photosets, or all photos from a user, with OAuth authentication for private/restricted content. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Install dependencies |
| 13 | +poetry install --with dev,extras |
| 14 | + |
| 15 | +# Run tests |
| 16 | +poetry run pytest -v |
| 17 | + |
| 18 | +# Run tests with coverage |
| 19 | +poetry run coverage run -m pytest |
| 20 | +poetry run coverage html -d coverage |
| 21 | + |
| 22 | +# Code quality checks (also run via pre-commit) |
| 23 | +poetry run flake8 flickr_download tests |
| 24 | +poetry run black --check flickr_download tests |
| 25 | +poetry run mypy flickr_download |
| 26 | + |
| 27 | +# Run all pre-commit hooks |
| 28 | +poetry run pre-commit run --all-files |
| 29 | + |
| 30 | +# Run the CLI |
| 31 | +poetry run flickr_download [args] |
| 32 | +``` |
| 33 | + |
| 34 | +## Architecture |
| 35 | + |
| 36 | +### Main Package (`flickr_download/`) |
| 37 | + |
| 38 | +- **flick_download.py** - Main entry point with CLI argument parsing, core download functions (`download_set`, `download_list`, `download_photo`, `download_user`, `download_user_photos`), and OAuth handling |
| 39 | +- **filename_handlers.py** - Strategy pattern implementation for file naming (title, id, title_and_id, id_and_title, title_increment) |
| 40 | +- **utils.py** - Utility functions for caching (pickle-based), file/path sanitization, JSON serialization, and file metadata handling |
| 41 | +- **logging_utils.py** - `APIKeysRedacter` formatter that redacts API keys and OAuth tokens from logs |
| 42 | + |
| 43 | +### Key Patterns |
| 44 | + |
| 45 | +- **OAuth Flow**: Interactive browser-based authentication with token persistence to `~/.flickr_token` |
| 46 | +- **Configuration**: Both CLI arguments and YAML config file (`~/.flickr_download`) supported |
| 47 | +- **Caching**: Pickle-based API response caching with configurable timeout |
| 48 | +- **Metadata**: SQLite database for tracking downloads and enabling resumable operations |
| 49 | + |
| 50 | +## Code Quality Standards |
| 51 | + |
| 52 | +- **Black**: 100-char line length |
| 53 | +- **MyPy**: Strict mode enabled - full type annotations required |
| 54 | +- **Flake8**: 100-char line length |
| 55 | +- Python 3.9-3.12 supported |
0 commit comments