Metadata-Version: 2.4
Name: clearcaption
Version: 0.2.1
Summary: YouTube transcripts that work from cloud servers (AWS, GCP, Colab): drop-in fallback for youtube-transcript-api, with timestamped translation.
Author-email: ClearCaption <21karrat@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://apify.com/clearcaption/youtube-transcript-translate
Project-URL: Repository, https://github.com/Andrii2203/clearcaption-youtube-transcript
Keywords: youtube,transcript,subtitles,captions,youtube-transcript-api,srt,vtt,translation,apify
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Multimedia :: Video
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.20
Dynamic: license-file

# ClearCaption: YouTube transcripts that work from the cloud

`youtube-transcript-api` works on your laptop, then fails on AWS, GCP, Colab, Vercel or Render with
`RequestBlocked`, `IpBlocked`, `TranscriptsDisabled` (when captions clearly exist) or `429 Too Many Requests`.
YouTube blocks cloud IP ranges, and translated captions (`transcript.translate('de')`) return 429 from almost any IP.

ClearCaption is a drop-in fallback: the same output (`[{"text", "start", "duration"}]`), but the request runs on
Apify's rotating proxies, so it works from any server. It can also translate: it fetches the original track and translates it.

**Free:** ~1,000 videos/month with a free Apify account ($5 monthly credit, no credit card).

```bash
pip install clearcaption
export APIFY_TOKEN=your_token   # free account: https://console.apify.com/sign-up
```

```python
from clearcaption import fetch, fetch_many

fetch("dQw4w9WgXcQ")                        # [{'text': ..., 'start': 18.64, 'duration': 3.24}, ...]
fetch("dQw4w9WgXcQ", translate_to="de")     # translated
fetch_many(["https://youtu.be/dQw4w9WgXcQ", "https://www.youtube.com/@channel"])  # videos, channels, playlists
```

### Keep youtube-transcript-api and fall back only when blocked

```python
from youtube_transcript_api import YouTubeTranscriptApi
from youtube_transcript_api._errors import RequestBlocked, IpBlocked
from clearcaption import fetch

def transcript(video_id):
    try:
        return YouTubeTranscriptApi().fetch(video_id).to_raw_data()
    except (RequestBlocked, IpBlocked):
        return fetch(video_id)
```

### Other ways to call it
- **REST / any language:** `POST https://api.apify.com/v2/acts/clearcaption~youtube-transcript-translate/run-sync-get-dataset-items?token=...` with `{"videos": ["dQw4w9WgXcQ"]}`.
- **AI agents (Claude, Cursor, n8n) via MCP:** add `https://mcp.apify.com?tools=clearcaption/youtube-transcript-translate` as an MCP server (header `Authorization: Bearer <APIFY_TOKEN>`, or sign in to Apify on first connection).
- **No code:** [Apify Store page](https://apify.com/clearcaption/youtube-transcript-translate): paste URLs, download JSON / CSV / SRT / VTT.

### Price
$0.005 per video with captions. Videos without captions cost $0. Translation costs $0.005 per started 10 minutes of video, and is free when YouTube already has a track in that language.
Pay per use on Apify, no subscription. The free Apify plan includes monthly credit.

### Compared with
| | youtube-transcript-api + residential proxy | Hosted subscription APIs | ClearCaption |
|---|---|---|---|
| Works from cloud | yes, if you run proxy rotation | yes | yes |
| Translated captions | 429 on `tlang` | varies | yes |
| Channels / playlists / search | no | some | yes |
| Billing | proxy plan | monthly plan | per video, $0 without captions |

MIT license. Issues and PRs welcome.

## Command line

```bash
clearcaption dQw4w9WgXcQ                 # plain text
clearcaption dQw4w9WgXcQ --to de --srt   # German SRT, timestamps kept
clearcaption https://www.youtube.com/@freecodecamp --json
```

## Other ways to use it
- **JavaScript / TypeScript:** `npm i clearcaption` ([clearcaption-js](https://github.com/Andrii2203/clearcaption-js))
- **n8n:** community node `n8n-nodes-clearcaption` ([repo](https://github.com/Andrii2203/n8n-nodes-clearcaption))
