Implement pyotp functionality for YouTube video downloading with 2FA support #346
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.
This PR implements TOTP (Time-based One-Time Password) functionality for use with playwright automation in YouTube video downloading workflows that require 2FA authentication.
Changes Made
Core TOTP Functionality
pyotp
dependency tosetup.cfg
src/ac_training_lab/video_editing/totp_utils.py
with lean, minimal TOTP utilities:generate_totp_code()
- Generate TOTP codes from Base32 secretsverify_totp_code()
- Verify TOTP codes against secretsget_totp_code_from_env()
- Retrieve TOTP codes from environment variablescreate_totp_provisioning_uri()
- Create URIs for authenticator app setupYouTube Integration
src/ac_training_lab/video_editing/yt_utils.py
with TOTP support:get_current_totp_for_youtube()
- Get YouTube-specific TOTP from environmentdownload_youtube_with_totp()
- Enhanced download function with 2FA supportTesting & Documentation
tests/test_totp_utils.py
andtests/test_youtube_totp.py
docs/totp_usage.md
examples/totp_example.py
demonstrating real-world usagevideo-editing
extras group for optional dependenciesUsage Example
Installation
The implementation is lean and minimal as requested, without fake/mock implementations in the core functionality. It's designed specifically for playwright automation workflows requiring YouTube 2FA authentication.
Fixes #345.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.