Metadata-Version: 2.4
Name: vid-mediakit
Version: 0.1.0
Summary: Download, transcribe, and convert videos from YouTube, Loom, Vimeo, and more
License: MIT
Project-URL: Repository, https://github.com/yourusername/mediakit
Keywords: video,download,transcription,conversion,yt-dlp,whisper,ffmpeg
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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: Topic :: Multimedia :: Video
Classifier: Topic :: Multimedia :: Sound/Audio
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: yt-dlp>=2024.1.0
Requires-Dist: openai>=1.0.0
Requires-Dist: python-decouple>=3.8
Requires-Dist: pandas>=2.0.0
Requires-Dist: openpyxl>=3.1.0
Requires-Dist: tqdm>=4.65.0
Requires-Dist: moviepy>=1.0.3
Provides-Extra: server
Requires-Dist: fastapi>=0.110.0; extra == "server"
Requires-Dist: uvicorn[standard]>=0.27.0; extra == "server"
Requires-Dist: aiofiles>=23.0.0; extra == "server"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"

# mediakit

Download, transcribe, and convert videos from YouTube, Loom, Vimeo, and more — as a Python library.

```python
from mediakit import download_video, get_transcription, convert

path  = download_video("https://www.loom.com/share/abc123")
text  = get_transcription(path)            # requires OPENAI_API_KEY
mp3   = convert(path, output_format="mp3", reencode=True)
```

---

## Features

| Module | What it does |
|---|---|
| `download_video()` | Download from YouTube, Vimeo, Loom, Wistia, and any yt-dlp supported site |
| `get_transcription()` / `VideoTranscriber` | Transcribe audio/video via OpenAI Whisper, auto-chunks files > 25 MB |
| `VideoScriptSummarizer` | Summarize a transcript with GPT-4 |
| `convert()` | Convert any video/audio format using ffmpeg (mp4→mp3, mkv→mp4, etc.) |

---

## Requirements

- Python ≥ 3.9
- **ffmpeg** (for conversion and audio extraction) — [install instructions below](#ffmpeg)
- OpenAI API key (for transcription only)

---

## Installation

### From PyPI (once published)

```bash
pip install mediakit
```

### Local / development install

```bash
git clone https://github.com/yourusername/mediakit
cd mediakit
pip install -e .
```

### With FastAPI server support

```bash
pip install "mediakit[server]"
```

---

## Setup

Copy `.env.example` to `.env` and add your OpenAI key:

```bash
cp .env.example .env
# edit .env and set OPENAI_API_KEY=sk-...
```

---

## Usage

### Download a video

```python
from mediakit import download_video

# Basic download → saves to ./downloads/
path = download_video("https://youtu.be/dQw4w9WgXcQ")

# Custom output directory and quality
path = download_video("https://youtu.be/dQw4w9WgXcQ", output_dir="my_videos", ytdlp_format="720p")
```

Supported format presets: `default`, `best`, `worst`, `360p`, `480p`, `720p`, `1080p`, `1440p`, `4k`

---

### Transcribe a video or audio file

```python
from mediakit import get_transcription, VideoTranscriber

# One-liner
text = get_transcription("video.mp4")

# Full control
transcriber = VideoTranscriber()
text = transcriber.transcribe_video("video.mp4")  # handles large files automatically
```

Files larger than 25 MB are automatically split into chunks before sending to Whisper.

---

### Summarize a transcript

```python
from mediakit import VideoScriptSummarizer

summarizer = VideoScriptSummarizer()
summary = summarizer.generate_summary(transcript_text)
```

---

### Convert video/audio formats

```python
from mediakit import convert

# mkv → mp4 (stream-copy, fast, no re-encode)
convert("recording.mkv", output_format="mp4")

# mp4 → mp3 (re-encode audio)
convert("video.mp4", output_format="mp3", reencode=True)

# Explicit output path
convert("video.mp4", output_path="/tmp/audio.wav", reencode=True)

# Overwrite if exists
convert("video.mp4", output_format="mp3", reencode=True, overwrite=True)
```

Supported formats: anything ffmpeg handles — `mp4`, `mp3`, `mkv`, `wav`, `m4a`, `ogg`, `flac`, `opus`, `webm`, etc.

---

### Bulk download from Excel

```bash
python -m video_downloader.excel_bulk urls.xlsx
```

The Excel file needs a column named `url` (or `URL` / `link`). A `filename` column is optional.

---

## ffmpeg

ffmpeg is required for conversion and audio extraction.

```bash
# Ubuntu / Debian
sudo apt install ffmpeg

# macOS
brew install ffmpeg

# Windows
# Download from https://ffmpeg.org/download.html and add to PATH
```

---

## Architecture

```
┌─────────────────────────────────────────────────────┐
│                    mediakit                          │
│  ┌──────────────┐  ┌────────────────┐  ┌──────────┐ │
│  │  downloader  │  │  transcription │  │converter │ │
│  │  (yt-dlp +   │  │  (Whisper API  │  │ (ffmpeg  │ │
│  │   requests)  │  │   + GPT-4)     │  │subprocess│ │
│  └──────────────┘  └────────────────┘  └──────────┘ │
└─────────────────────────────────────────────────────┘
         │                   │                  │
   YouTube/Vimeo         OpenAI API         local ffmpeg
   Loom/Wistia           Whisper + GPT      (system dep)
```

---

## Publishing to PyPI

Here's the full flow to publish your own version:

```
1. Register at https://pypi.org
2. Enable 2FA on your account
3. Generate an API token (Account Settings → API tokens)

4. Build the package:
   pip install build twine
   python -m build          # creates dist/*.whl and dist/*.tar.gz

5. Test on TestPyPI first (optional but recommended):
   twine upload --repository testpypi dist/*
   pip install --index-url https://test.pypi.org/simple/ mediakit

6. Publish to production PyPI:
   twine upload dist/*
   # enter: __token__ as username, your API token as password

7. Anyone can now install it:
   pip install mediakit
```

> **Tip:** Store your token in `~/.pypirc` or as env var `TWINE_PASSWORD` so you don't paste it every time.

---

## Running Tests

```bash
pip install pytest
pytest tests/
```

---

## License

MIT
