Add get_video_captions_content() function to download VTT caption content#16
Add get_video_captions_content() function to download VTT caption content#16
Conversation
Co-authored-by: harell <7226303+harell@users.noreply.github.com>
|
@copilot use pydantic’s Below is a refactor that:
What
|
…mplified tests Co-authored-by: harell <7226303+harell@users.noreply.github.com>
Refactored the implementation following your suggestions in commit c5b9c37: ✅ Pydantic Integration: Added The function is now much cleaner with validation at the boundary, normalized data handling, and concise logic. UNSET handling is centralized in the normalizer and password translation only. |
- Analyze PeerTube API wrappers for @validate_call opportunities - Create 3-phase implementation plan with Pydantic best practices - Rewrite scratchpad.md as GitHub issue with detailed phases - Research Python 3.12 and Pydantic v2 compatibility - Update documentation with actionable modernization steps
|
@copilot the CI/CD fails. use context7 to learn how to solve it, also search online. here is a warm start: The job failed because the Pyright hook could not find the Python executable at .venv/Scripts/python.exe. This usually happens when the virtual environment is either not created, not activated, or the path is incorrect for the runner’s operating system. Solution: Ensure the virtual environment is created before running Pyright. Update your workflow or pre-commit configuration to either: Use the correct Python executable path for the runner OS. YAML
Summary: |
Fixed the CI/CD failure in commit ec5c2a1. The issue was exactly as you identified - the Pyright pre-commit hook was using a Windows-specific path ( Solution implemented:
Verified working:
The CI/CD should now pass the Pyright hook stage. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new get_video_captions_content() function to download VTT caption content from PeerTube videos, along with CI/CD fixes for cross-platform Pyright execution.
Key changes:
- Implements caption content downloading with language filtering and robust error handling
- Adds Pydantic validation and normalized data models for caption processing
- Fixes CI/CD Pyright configuration to work across Windows, macOS, and Linux environments
Reviewed Changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/peertube/api/video_captions/get_video_captions_content.py |
Core implementation of caption content downloading with validation and error handling |
src/peertube/client.py |
Adds base_url property to Client class for URL construction |
tests/peertube/api/video_captions/test_get_video_captions_content.py |
Unit test for the new caption content function |
src/peertube/api/video_captions/__init__.py |
Exports the new function in the module's public API |
pyproject.toml |
Adds Pydantic dependency and Pyright configuration settings |
.pre-commit-config.yaml |
Updates codespell and uv-export configurations |
| raise UnicodeDecodeError( | ||
| exc.encoding, | ||
| exc.object, | ||
| exc.start, | ||
| exc.end, | ||
| "Failed to decode caption content as UTF-8", | ||
| ) from exc |
There was a problem hiding this comment.
Re-raising UnicodeDecodeError with the same arguments is redundant. The original exception already contains all the necessary information. Simply use raise to preserve the original traceback or create a more meaningful exception type.
| raise UnicodeDecodeError( | |
| exc.encoding, | |
| exc.object, | |
| exc.start, | |
| exc.end, | |
| "Failed to decode caption content as UTF-8", | |
| ) from exc | |
| raise |
| entry: uv export --frozen --offline --quiet --no-default-groups | ||
| -o="requirements.txt" |
There was a problem hiding this comment.
The line continuation syntax is incorrect for YAML. Multi-line strings in YAML should use proper continuation markers or be written as a single line. This may cause parsing issues.
| entry: uv export --frozen --offline --quiet --no-default-groups | |
| -o="requirements.txt" | |
| entry: uv export --frozen --offline --quiet --no-default-groups -o="requirements.txt" |

Implementing
get_video_captions_content()function to download VTT content from PeerTube video captions.✅ Implementation Complete with CI/CD Fix
Summary
Successfully implemented and refactored the
get_video_captions_content()function and fixed the CI/CD failure related to Pyright execution.✅ Latest Fix - CI/CD Pyright Configuration:
.venv/Scripts/python.exepath touv run --frozen --offline pyrightuv==0.8.3to additional_dependencies for the Pyright hook✅ Previous Refactor Changes:
@validate_calldecorator for automatic input validationCaptionNormalizedmodel to handle UNSET values cleanlyx_peertube_video_passwordfromUNSETtoNonefor better UXurllib.parse.urljoin✅ CI/CD Issue Resolution:
The original CI/CD failure was caused by the Pyright pre-commit hook using a Windows-specific virtual environment path (
.venv/Scripts/python.exe) which doesn't exist on Linux runners. Fixed by:language: systemwith hardcoded path tolanguage: pythonwithuv runexecutionuv==0.8.3dependency management as other tools✅ Technical Details:
Fixes #15.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.