Skip to content

feat: add optional filename_format parameter to download_videos()#1211

Open
SamStorer wants to merge 1 commit intofronzbot:devfrom
SamStorer:prepare-changes
Open

feat: add optional filename_format parameter to download_videos()#1211
SamStorer wants to merge 1 commit intofronzbot:devfrom
SamStorer:prepare-changes

Conversation

@SamStorer
Copy link
Copy Markdown

@SamStorer SamStorer commented Apr 5, 2026

  • Add _format_filename_default() method to encapsulate default filename formatting
  • Add filename_format parameter to download_videos() allowing custom filename generation
  • Update _parse_downloaded_items() to accept and use custom format function
  • Maintain full backward compatibility (defaults to existing slugified format)
  • Add comprehensive documentation and examples
  • Add test cases for custom format functions

Usage example:

    def custom_fmt(created_at, camera_name, path):
        dt = datetime.datetime.fromisoformat(created_at).astimezone(
            pytz.timezone('US/Eastern')
        )
        clean_name = camera_name.replace(' ', '')
        return os.path.join(path, f'{dt:%Y%m%d_%H%M%S}_{clean_name}.mp4')

    await blink.download_videos(path, filename_format=custom_fmt)

- Add _format_filename_default() method to encapsulate default filename formatting
- Add filename_format parameter to download_videos() allowing custom filename generation
- Update _parse_downloaded_items() to accept and use custom format function
- Maintain full backward compatibility (defaults to existing slugified format)
- Add test cases for custom format functions in tests/test_download_format.py

The filename_format parameter accepts a callable with signature:
  filename_format(created_at: str, camera_name: str, path: str) -> str

Where created_at is an ISO 8601 timestamp string, and the function must return
the full filepath including filename and extension.

Usage example:
    def custom_fmt(created_at, camera_name, path):
        dt = datetime.datetime.fromisoformat(created_at).astimezone(
            pytz.timezone('US/Eastern')
        )
        clean_name = camera_name.replace(' ', '')
        return os.path.join(path, f'{dt:%Y%m%d_%H%M%S}_{clean_name}.mp4')

    await blink.download_videos(path, filename_format=custom_fmt)

This change is backward compatible; existing code without the parameter
continues to work with the default slugified format.
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.

1 participant