You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

tldw

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tldw

A Python package to summarize YouTube videos using the OpenAI API.

1.0.1
Source
pipPyPI
Maintainers
1

TLDW (Too Long; Didn't Watch)

PyPI version Python 3.8+ License: MIT Test

A Python package that instantly summarizes YouTube videos using AI. Get the key points from any video without watching it!

✨ Features

  • 🎥 YouTube Video Summarization: Extract transcripts and generate concise summaries
  • 🤖 OpenAI GPT Integration: Powered by GPT-4o-mini for high-quality summaries
  • 🎨 Beautiful CLI Output: Colorized terminal output with ASCII art
  • 🔄 Streaming Response: Real-time summary generation
  • 🐍 Simple Python API: Easy to integrate into your projects

🚀 Quick Start

Prerequisites

Installation

Install from PyPI:

pip install tldw

From source:

git clone git@github.com:DavidZirinsky/tl-dw.git
cd tl-dw/
python3 -m pip install .

Usage

from tldw import tldw
import os

# Initialize with your OpenAI API key
summary = tldw(os.environ.get('OPENAI_API_KEY'))

# Summarize a YouTube video
summary.summarize('https://www.youtube.com/watch?v=LCEmiRjPEtQ')

📝 Example Output

  ________    ____ _       __
 /_  __/ /   / __ \ |     / /
  / / / /   / / / / | /| / /
 / / / /___/ /_/ /| |/ |/ /
/_/ /_____/_____/ |__/|__/


Summarizing video: https://www.youtube.com/watch?v=LCEmiRjPEtQ

--- Summary ---

In his talk, Andre Carpathy, former director of AI at Tesla, discusses the evolving
nature of software in the era of AI, particularly emphasizing the transition from
traditional coding (Software 1.0) to an AI-driven paradigm (Software 2.0 and 3.0).
He categorizes Software 1.0 as conventional code that directly instructs computers,
while Software 2.0 encompasses neural networks where the focus is on tuning data
sets instead of writing explicit code. He introduces Software 3.0, which involves
large language models (LLMs) that can be prompted in natural language, making
programming more accessible to non-coders.

[...continued summary...]

--- End of Summary ---

❓ Troubleshooting

Common Issues

"OpenAI API key is required" Error

  • Make sure your OpenAI API key is set in the environment variable OPENAI_API_KEY
  • Verify your API key is valid and has sufficient credits

"Invalid YouTube URL provided" Error

  • Ensure the URL is a valid YouTube video URL
  • Supported formats: https://www.youtube.com/watch?v=VIDEO_ID or https://youtu.be/VIDEO_ID

"Failed to get transcript" Error

  • The video may not have English captions/transcripts available
  • Some videos may have restricted access to transcripts
  • Try with a different video that has confirmed English captions

API Rate Limiting

  • If you encounter rate limiting, wait a few moments before trying again
  • Consider upgrading your OpenAI API plan for higher rate limits

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  • Fork the repository
  • Create your feature branch (git checkout -b feature/AmazingFeature)
  • Commit your changes (git commit -m 'Add some AmazingFeature')
  • Push to the branch (git push origin feature/AmazingFeature)
  • Open a Pull Request

🛠️ Development Setup

  • Install Dependencies:

    pip install -e .
    
  • Then Run This With:

    python3 src/tldw/tldw.py
    

🧪 Running Tests

To run the tests:

Locally:

pytest

You can also run tests in the Docker container, mimicking a PyPI wheel distribution installation.

docker compose down && docker compose up -d --build && docker logs tests -f

🤝 Pre-commit Hooks

This project uses pre-commit hooks to ensure code quality and consistency before commits.

  • Install pre-commit: If you don't have pre-commit installed globally, you can install it into your virtual environment:

    pip install pre-commit
    
  • Install the Git hooks: Navigate to the root of the repository and run:

    pre-commit install
    

    This command sets up the hooks in your .git/ directory.

  • Run hooks manually (optional): To run all configured hooks against all files, without making a commit:

    pre-commit run --all-files
    

Now, every time you try to commit, the pre-commit hooks will automatically run. If any hook fails, the commit will be aborted, allowing you to fix the issues before committing.

📦 Packaging for PyPI and Test PyPi

For PyPI:

Build and Upload:

pip install build twine
python3 -m build
python3 -m twine upload  dist/*

For Test PyPi:

Build and Upload:

pip install build twine
python3 -m build
python3 -m twine upload --repository testpypi dist/*

Test PyPi Installation:

pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
tldw==1.0.3

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts