fix(deps): declare youtube-transcript-api in pyproject.toml [youtube] extra#22745
Closed
wesleysimplicio wants to merge 1 commit into
Closed
Conversation
… extra
skills/media/youtube-content/scripts/fetch_transcript.py and
optional-skills/productivity/memento-flashcards/scripts/youtube_quiz.py
both import youtube-transcript-api at runtime, but the package was not
listed in pyproject.toml. A fresh `uv sync` therefore omits it, and
both skills fail on first invocation with:
ModuleNotFoundError: No module named 'youtube_transcript_api'
Add a new [youtube] optional-dependency group with
youtube-transcript-api>=1.2.0 (the v1.x API surface the scripts already
use) and include it in [all] so standard installs pick it up.
Regression tests: TestPyprojectDeclaresYoutubeExtra verifies the extra
is present in pyproject.toml and included in [all].
Closes NousResearch#22243
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a missing optional dependency for YouTube transcript fetching and protects against regressions by introducing targeted tests.
Changes:
- Add a new
youtubeoptional-dependency group declaringyoutube-transcript-api. - Include
hermes-agent[youtube]in the[all]optional-dependencies group. - Add regression tests for transcript utilities plus checks that
pyproject.tomldeclares the extra correctly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pyproject.toml | Declares the youtube extra and includes it in [all] to prevent missing runtime dependency installs. |
| tests/skills/test_fetch_transcript.py | Adds regression tests for URL parsing/timestamp formatting, missing-dependency behavior, and pyproject extra declarations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+50
| import sys | ||
| from pathlib import Path | ||
| from unittest import mock | ||
|
|
||
| import pytest | ||
|
|
||
| SCRIPTS_DIR = Path(__file__).resolve().parents[2] / "skills" / "media" / "youtube-content" / "scripts" | ||
| sys.path.insert(0, str(SCRIPTS_DIR)) | ||
|
|
||
| import fetch_transcript | ||
|
|
||
|
|
||
| class TestExtractVideoId: | ||
| def test_standard_watch_url(self): | ||
| assert fetch_transcript.extract_video_id("https://www.youtube.com/watch?v=dQw4w9WgXcQ") == "dQw4w9WgXcQ" | ||
|
|
||
| def test_short_url(self): | ||
| assert fetch_transcript.extract_video_id("https://youtu.be/dQw4w9WgXcQ") == "dQw4w9WgXcQ" | ||
|
|
||
| def test_bare_video_id(self): | ||
| assert fetch_transcript.extract_video_id("dQw4w9WgXcQ") == "dQw4w9WgXcQ" | ||
|
|
||
| def test_shorts_url(self): | ||
| assert fetch_transcript.extract_video_id("https://www.youtube.com/shorts/dQw4w9WgXcQ") == "dQw4w9WgXcQ" | ||
|
|
||
| def test_embed_url(self): | ||
| assert fetch_transcript.extract_video_id("https://www.youtube.com/embed/dQw4w9WgXcQ") == "dQw4w9WgXcQ" | ||
|
|
||
| def test_with_extra_params(self): | ||
| assert fetch_transcript.extract_video_id("https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=42") == "dQw4w9WgXcQ" | ||
|
|
||
|
|
||
| class TestFormatTimestamp: | ||
| def test_seconds_only(self): | ||
| assert fetch_transcript.format_timestamp(90) == "1:30" | ||
|
|
||
| def test_with_hours(self): | ||
| assert fetch_transcript.format_timestamp(3661) == "1:01:01" | ||
|
|
||
| def test_zero(self): | ||
| assert fetch_transcript.format_timestamp(0) == "0:00" | ||
|
|
||
| def test_minutes_only(self): | ||
| assert fetch_transcript.format_timestamp(600) == "10:00" | ||
|
|
||
|
|
||
| class TestFetchTranscriptImportError: | ||
| def test_missing_dep_exits_with_message(self, capsys): |
Comment on lines
+86
to
+87
| all_deps = " ".join(data["project"]["optional-dependencies"].get("all", [])) | ||
| assert "youtube" in all_deps, "[all] extra does not include hermes-agent[youtube]" |
| # optional-skills/productivity/memento-flashcards (youtube_quiz.py). | ||
| # Without this declaration uv sync omits the package and both skills fail | ||
| # at first invocation with ModuleNotFoundError (issue #22243). | ||
| "youtube-transcript-api>=1.2.0", |
Contributor
|
Merged via salvage PR #22797. salvage cherry-picked your commit; authorship preserved. Thanks for the contribution! |
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.
Summary
skills/media/youtube-contentandoptional-skills/productivity/memento-flashcardsboth importyoutube-transcript-apiat runtimepyproject.toml—uv syncomits it, both skills fail withModuleNotFoundErroron first invocationyoutube = ["youtube-transcript-api>=1.2.0"]optional-dependency grouphermes-agent[youtube]in[all]so standard installs get it automaticallyChanges
pyproject.toml: new[youtube]extra, added to[all]tests/skills/test_fetch_transcript.py: new regression tests coveringextract_video_id(),format_timestamp(), ImportError fallback behavior, and pyproject.toml declarationStash-verify
Tests
TestPyprojectDeclaresYoutubeExtra::test_youtube_extra_declared_in_pyprojectandtest_youtube_extra_included_in_allconfirmed to fail onupstream/mainwithout this change and pass with it.Closes #22243