Metadata-Version: 2.4
Name: llm-getyoutubetranscript
Version: 0.1.0
Summary: YouTube transcripts for LLM: load any YouTube transcript as a fragment or tool with the GetYouTubeTranscript API
Author: TubeAgentKit
License-Expression: MIT
Project-URL: Homepage, https://getyoutubetranscript.com
Project-URL: Documentation, https://getyoutubetranscript.com/docs
Project-URL: Repository, https://github.com/tubeagentkit/llm-getyoutubetranscript
Project-URL: Issues, https://github.com/tubeagentkit/llm-getyoutubetranscript/issues
Project-URL: Changelog, https://github.com/tubeagentkit/llm-getyoutubetranscript/releases
Project-URL: Get an API key, https://getyoutubetranscript.com/dashboard
Keywords: llm,youtube,youtube-transcript,transcript,captions,subtitles,youtube-captions,fragments,llm-plugin,ai,summarize
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: llm>=0.26
Requires-Dist: getyoutubetranscript>=0.3.0
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# llm-getyoutubetranscript

[![PyPI](https://img.shields.io/pypi/v/llm-getyoutubetranscript.svg)](https://pypi.org/project/llm-getyoutubetranscript/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/tubeagentkit/llm-getyoutubetranscript/blob/main/LICENSE)

YouTube transcripts for [LLM](https://llm.datasette.io/). Pull the YouTube transcript of any video into a prompt, let a model fetch transcripts on its own, or print one from the command line. It uses the [GetYouTubeTranscript](https://getyoutubetranscript.com) API, so there are no proxies, cookies or headless browsers to set up.

```bash
llm -f yt:https://youtu.be/5e37ZT3SQbk "summarize this video in five bullet points"
```

## Installation

Install this plugin in the same environment as LLM:

```bash
llm install llm-getyoutubetranscript
```

## Set up your API key

1. Create a free key at [getyoutubetranscript.com/dashboard](https://getyoutubetranscript.com/dashboard). New accounts get 100 credits and no card is needed.
2. Store it in LLM's key store:

   ```bash
   llm keys set getyoutubetranscript
   ```

   Or export it as an environment variable (a key in the key store wins over the variable):

   ```bash
   export GETYOUTUBETRANSCRIPT_API_KEY=sk_live_...
   ```

Each transcript costs 1 credit. Failed and rate-limited requests are never charged.

## Fragments

Use the `yt:` [fragment](https://llm.datasette.io/en/stable/fragments.html) prefix with a video URL or an 11-character video ID:

```bash
llm -f yt:dQw4w9WgXcQ "summarize this"
llm -f 'yt:https://www.youtube.com/watch?v=dQw4w9WgXcQ' "what are the main arguments?"
llm -f yt:https://youtu.be/dQw4w9WgXcQ "write a blog post from this"
```

Quote the whole argument if the URL contains `?` or `&`, so your shell leaves it alone.

The fragment starts with the video title, channel and URL, followed by the transcript, so the model knows what it is reading.

### Timestamps

`yt-timed:` puts a `[m:ss]` timestamp (`[h:mm:ss]` past an hour) on every caption line. Use it when you want answers that point to moments in the video:

```bash
llm -f yt-timed:dQw4w9WgXcQ "list the key moments with their timestamps"
```

### Other languages

Add `@` and a caption language code to the end of the argument:

```bash
llm -f yt:dQw4w9WgXcQ@es "resume este video"
llm -f yt-timed:https://youtu.be/dQw4w9WgXcQ@pt-BR "resuma os pontos principais"
```

Without a language the API default (English) is used.

### Combine videos and other fragments

Fragments stack, so you can compare videos or mix a transcript with other context:

```bash
llm -f yt:VIDEO_ONE -f yt:VIDEO_TWO "how do these two talks disagree?"
llm -f yt:dQw4w9WgXcQ -f ./notes.md "does the talk cover everything in my notes?"
```

LLM stores each fragment by content hash in its log database, so follow-up prompts in a conversation (`llm -c "and the third point?"`) do not fetch the transcript again.

See all registered loaders with `llm fragments loaders`.

If another installed plugin also registers `yt:` (for example `llm-youtube-transcript`), LLM keeps both and renames one prefix to `yt_1:`. Run `llm fragments loaders` to see which prefix points to which plugin.

## Tool

The plugin registers a `youtube_transcript` [tool](https://llm.datasette.io/en/stable/tools.html), so a model can decide for itself when to fetch a transcript:

```bash
llm -T youtube_transcript "Summarize https://youtu.be/dQw4w9WgXcQ in three sentences" --td
```

```bash
llm chat -T youtube_transcript
```

The tool takes `video` (URL or ID), an optional `language` and an optional `timestamps` flag. Use a model that supports tool calling.

## Command

`llm youtube-transcript` prints a transcript to stdout. It is handy for piping into other tools or saving subtitle files:

```bash
llm youtube-transcript dQw4w9WgXcQ                      # plain text
llm youtube-transcript dQw4w9WgXcQ --format timed       # [m:ss] lines
llm youtube-transcript dQw4w9WgXcQ --format srt > video.srt
llm youtube-transcript dQw4w9WgXcQ -l es --format vtt > video.es.vtt
llm youtube-transcript dQw4w9WgXcQ --format json
```

Formats: `text`, `timed`, `srt`, `vtt`, `json`.

## Errors

Problems come back as one clear line, not a traceback. For example an unknown video, a missing or invalid key, or an account out of credits:

```
Error: Could not load fragment yt:aaaaaaaaaaa: This video is unavailable, private, or has been removed.
```

## Related

- [getyoutubetranscript](https://pypi.org/project/getyoutubetranscript/), the Python SDK this plugin is built on
- [API docs](https://getyoutubetranscript.com/docs)

## Development

```bash
git clone https://github.com/tubeagentkit/llm-getyoutubetranscript
cd llm-getyoutubetranscript
python -m venv venv
source venv/bin/activate
pip install -e '.[test]'
python -m pytest
```

## License

MIT
