Skip to content

Building AI agents, atomically

Gotta make sure readme links work..

KennyVaneetveldee7ea6c0a3265
diff --git a/atomic-forge/atomic_tools/youtube_transcript_scraper/README.md b/atomic-forge/atomic_tools/youtube_transcript_scraper/README.md
index ba5e226..318b484 100644
--- a/atomic-forge/atomic_tools/youtube_transcript_scraper/README.md
+++ b/atomic-forge/atomic_tools/youtube_transcript_scraper/README.md
@@ -1,28 +1,91 @@
# YouTube Transcript Scraper Tool
## Overview
-The YouTube Transcript Scraper Tool is a Python-based utility designed for fetching and processing transcripts from YouTube videos. It uses the YouTube Transcript API to retrieve transcripts and the Google API to fetch video metadata. This tool is built using the Pydantic library for input validation and leverages the `atomic_agents` framework for consistent tool structure.
+The **YouTube Transcript Scraper Tool** is a tool within the Atomic Agents ecosystem that allows you to fetch the transcript of a YouTube video.
-## Features
-- Fetch transcripts from YouTube videos.
-- Support for language-specific transcript retrieval.
-- Retrieve video metadata (title, channel, publication date).
-- Input validation using Pydantic.
-- Error handling for common transcript fetching issues.
+## Installation
+You can install the tool using any of the following options:
-## Example Usage
+1. Good old fashioned copy/paste: Just like any other tool inside the Atomic Forge, you can copy the code from this repo directly into your own project, provided you already have atomic-agents installed according to the instructions in the main [README](../../../../README.md).
+
+## Configuration
+
+### Obtaining a YouTube API Key
+
+To use this tool, you'll need a YouTube API key. Follow these steps to obtain one:
+
+1. **Access the Google Developers Console**
+ - Visit the [Google Developers Console](https://console.developers.google.com/).
+ - Sign in with your Google account. If you don't have one, you'll need to create it.
+
+2. **Create a New Project**
+ - Click on the project dropdown in the top-left corner and select "New Project."
+ - Enter a project name and click "Create."
+
+3. **Enable the YouTube Data API v3**
+ - In the dashboard, click on "Enable APIs and Services."
+ - Search for "YouTube Data API v3" and select it.
+ - Click the "Enable" button.
+
+4. **Generate Your API Key**
+ - Navigate to "Credentials" in the left sidebar.
+ - Click on "Create Credentials" and select "API Key."
+ - Copy the generated API key and add it to your `.env` file as shown above.
+
+> **Note:** Keep your API key secure and avoid sharing it publicly.
+
+## Usage
+
+Here's an example of how to use the YouTube Transcript Scraper Tool:
```python
from tool.youtube_transcript_scraper import YouTubeTranscriptTool, YouTubeTranscriptToolConfig
-api_key = "your_youtube_api_key"
-transcript_tool = YouTubeTranscriptTool(config=YouTubeTranscriptToolConfig(api_key=api_key))
+# Initialize the tool with your API key
+config = YouTubeTranscriptToolConfig(api_key="your_youtube_api_key")
+transcript_tool = YouTubeTranscriptTool(config=config)
+# Define input data
input_data = YouTubeTranscriptTool.input_schema(
video_url="https://www.youtube.com/watch?v=t1e8gqXLbsU",
language="en"
)
+# Fetch the transcript
result = transcript_tool.run(input_data)
-print(result) # Output: YouTubeTranscriptToolOutputSchema with transcript, duration, and metadata
+print(result)
```
+
+## Input & Output Structure
+
+### Input Schema
+- `video_url` (str): URL of the YouTube video to fetch the transcript for.
+- `language` (Optional[str]): Language code for the transcript (e.g., `'en'` for English).
+
+### Output Schema
+- `transcript` (str): Transcript of the YouTube video.
+- `duration` (float): Duration of the YouTube video.
+- `comments` (List[str]): Comments on the YouTube video.
+- `metadata` (dict): Metadata of the YouTube video.
+
+## Error Handling
+
+The tool includes comprehensive error handling to manage common issues such as:
+- Invalid video URLs.
+- Missing transcripts in the specified language.
+- API rate limits and authentication errors.
+
+## Contributing
+
+Contributions are welcome! To contribute:
+
+1. Fork the repository.
+2. Create a new feature branch.
+3. Commit your changes with clear messages.
+4. Open a pull request detailing your changes.
+
+Please ensure you follow the project's coding standards and include tests for any new features or bug fixes.
+
+## License
+
+This project is licensed under the same license as the main Atomic Agents project. See the [LICENSE](LICENSE) file in the repository root for more details.
diff --git a/atomic-forge/atomic_tools/youtube_transcript_scraper/example.env b/atomic-forge/atomic_tools/youtube_transcript_scraper/example.env
new file mode 100644
index 0000000..fdd25c2
--- /dev/null
+++ b/atomic-forge/atomic_tools/youtube_transcript_scraper/example.env
@@ -0,0 +1 @@
+YOUTUBE_API_KEY=1234567890
diff --git a/atomic-forge/atomic_tools/youtube_transcript_scraper/poetry.lock b/atomic-forge/atomic_tools/youtube_transcript_scraper/poetry.lock
index 27b3532..a19fd5b 100644
--- a/atomic-forge/atomic_tools/youtube_transcript_scraper/poetry.lock
+++ b/atomic-forge/atomic_tools/youtube_transcript_scraper/poetry.lock
@@ -1380,6 +1380,20 @@ pytest = ">=4.6"
[package.extras]
testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"]
+[[package]]
+name = "python-dotenv"
+version = "1.0.1"
+description = "Read key-value pairs from a .env file and set them as environment variables"
+optional = false
+python-versions = ">=3.8"
+files = [
+ {file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"},
+ {file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"},
+]
+
+[package.extras]
+cli = ["click (>=5.0)"]
+
[[package]]
name = "pyyaml"
version = "6.0.2"
@@ -1775,4 +1789,4 @@ requests = "*"
[metadata]
lock-version = "2.0"
python-versions = ">=3.12,<4"
-content-hash = "d2eadb06f3c398deddca236c3246fb1c1fa4e911546599be8f9f866231b29380"
+content-hash = "402613e4bc0971df5a0cdd5e8c5fa391be379a1f9d9917c512b52bd7510356a2"
diff --git a/atomic-forge/atomic_tools/youtube_transcript_scraper/pyproject.toml b/atomic-forge/atomic_tools/youtube_transcript_scraper/pyproject.toml
index 09bd5d2..4f92e3b 100644
--- a/atomic-forge/atomic_tools/youtube_transcript_scraper/pyproject.toml
+++ b/atomic-forge/atomic_tools/youtube_transcript_scraper/pyproject.toml
@@ -15,8 +15,9 @@ youtube-transcript-api = ">=0.6.2,<1"
[tool.poetry.group.dev.dependencies]
coverage = ">=7.6.1,<8.0.0"
-pytest-cov = ">=5.0.0,<6.0.0"
pytest = ">=8.3.3,<9.0.0"
+pytest-cov = ">=5.0.0,<6.0.0"
+python-dotenv = ">=1.0.0,<2.0.0"
rich = ">=13.7.0,<14.0.0"
[build-system]
diff --git a/atomic-forge/atomic_tools/youtube_transcript_scraper/tool/youtube_transcript_scraper.py b/atomic-forge/atomic_tools/youtube_transcript_scraper/tool/youtube_transcript_scraper.py
index cb6e9a5..8a937d4 100644
--- a/atomic-forge/atomic_tools/youtube_transcript_scraper/tool/youtube_transcript_scraper.py
+++ b/atomic-forge/atomic_tools/youtube_transcript_scraper/tool/youtube_transcript_scraper.py
@@ -154,6 +154,9 @@ class YouTubeTranscriptTool(BaseTool):
#################
if __name__ == "__main__":
from rich.console import Console
+ from dotenv import load_dotenv
+
+ load_dotenv()
rich_console = Console()
api_key = os.getenv("YOUTUBE_API_KEY")