This project is a FastAPI-based application that provides functionality for processing YouTube video transcripts, generating stories from those transcripts, and managing content using various APIs. The system integrates with YouTube for video data, OpenAI for text generation and Firebase for data storage.
- YouTube video transcript extraction and processing
- Automatic content categorization using AI
- Story generation from video transcripts
- Semantic search capabilities
- Content management with categories
- Multiple API integrations (YouTube, OpenAI, Firebase)
- Python 3.8+
- Firebase account and project
- OpenAI API access
- YouTube API access
First, clone the repository and create a virtual environment:
git clone <repository-url>
cd blackprince001-scripter-tool-system
pip install uv
uv venv
source .venv/bin/activate # activating the environment will be different on windows
uv pip install -r requirements.txt
Create a .env
file in the root directory with the following variables:
FIREBASE_CONFIG_FILE=path/to/your/firebase-config.json
OPENAI_API_KEY=your_openai_api_key
YOUTUBE_API_KEY=your_youtube_api_key
- Go to the Firebase Console
- Create a new project
- Navigate to Project Settings > Service Accounts
- Generate a new private key
- Save the JSON file as
firebase-config.json
in your project - Update the
FIREBASE_CONFIG_FILE
path in your.env
- Visit OpenAI's platform
- Create an account or sign in
- Navigate to API keys
- Generate a new API key
- Add it to your
.env
file asOPENAI_API_KEY
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the YouTube Data API v3
- Create credentials (API key)
- Add it to your
.env
file asYOUTUBE_API_KEY
Start the FastAPI server:
uvicorn main:app --reload --host 0.0.0.0 --port 8000
The API will be available at http://localhost:8000
POST /transcripts/process
Process a YouTube video and extract its transcript.
Parameters:
url
: YouTube video URLcategory
: (optional) Category for the transcriptauto_categorize
: (optional) Enable AI category generation
POST /generate/story
Generate stories from categorized transcripts.
Parameters:
category_weights
: List of categories and their weightsvariations_count
: Number of story variations to generatestyle
: Story style (casual/professional/creative)length
: Desired story length
GET /categories/
Retrieve all available categories.
blackprince001-scripter-tool-system/
├── app/
│ ├── core/ # Core functionality and API clients
│ ├── models/ # Data models
│ ├── router/ # API routes
│ ├── schemas/ # Pydantic schemas
│ └── utils/ # Utility functions
├── tests/ # Test files
└── main.py # Application entry point
The application includes custom error handling for various scenarios:
- Invalid YouTube URLs
- Missing transcripts
- API failures
- Database errors
All errors return structured responses with:
error_code
: Specific error identifiermessage
: Human-readable error messagedetails
: Additional error information
Run the test suite using pytest:
pytest
The application uses the following Firestore collections:
transcripts
: Main collection for all transcriptstranscripts_{category}
: Category-specific transcript collectionscategories
: Available content categoriesstories
: Generated stories
- Use the provided models and schemas for data validation
- Follow the existing error handling patterns
- Add tests for new functionality
- Update documentation for API changes
- API keys are managed through environment variables
- CORS is configured for specific origins
- Firebase security rules should be properly configured
- Rate limiting should be implemented for production use
The application implements several optimization techniques:
- LRU caching for frequently accessed data
- Efficient transcript processing
- Optimized database queries
- Semantic search capabilities
Common issues and solutions:
-
Firebase Connection Issues
- Verify Firebase configuration file path
- Check Firebase project permissions
- Ensure proper network connectivity
-
YouTube API Errors
- Verify API key validity
- Check daily quota limits
- Ensure video URLs are properly formatted
-
OpenAI API Issues
- Verify API key
- Check rate limits
- Monitor token usage
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a pull request
[Add License Information]