Metadata-Version: 2.4
Name: yt-cm
Version: 0.1.0
Summary: YouTube Cookie Manager - Validate and renew YouTube cookies
Project-URL: Homepage, https://github.com/daedalus/yt-cm
Project-URL: Repository, https://github.com/daedalus/yt-cm
Project-URL: Issues, https://github.com/daedalus/yt-cm/issues
Author-email: Dario Clavijo <clavijodario@gmail.com>
License: MIT
License-File: LICENSE
Requires-Python: >=3.11
Provides-Extra: all
Requires-Dist: hatch; extra == 'all'
Requires-Dist: hypothesis; extra == 'all'
Requires-Dist: mypy; extra == 'all'
Requires-Dist: pytest; extra == 'all'
Requires-Dist: pytest-cov; extra == 'all'
Requires-Dist: pytest-mock; extra == 'all'
Requires-Dist: ruff; extra == 'all'
Provides-Extra: dev
Requires-Dist: hatch; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: lint
Requires-Dist: mypy; extra == 'lint'
Requires-Dist: ruff; extra == 'lint'
Provides-Extra: test
Requires-Dist: hypothesis; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest-mock; extra == 'test'
Description-Content-Type: text/markdown

# yt-cm — YouTube Cookie Manager

[![PyPI](https://img.shields.io/pypi/v/yt-cm.svg)](https://pypi.org/project/yt-cm/)
[![Python](https://img.shields.io/pypi/pyversions/yt-cm.svg)](https://pypi.org/project/yt-cm/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

A CLI tool for managing YouTube authentication cookies in Netscape format. Validates cookie authenticity, refreshes sessions, and can run as a daemon to continuously keep sessions active.

## Install

```bash
pip install yt-cm
```

Or install from source:

```bash
git clone https://github.com/daedalus/yt-cm.git
cd yt-cm
pip install -e .
```

## Usage

### CLI Commands

```bash
# Validate a cookie
yt-cm cookies.txt validate

# Renew session and show expiration info
yt-cm cookies.txt renew

# Check authentication cookie status
yt-cm cookies.txt auth-info

# Export cookies to new file
yt-cm cookies.txt export -o new_cookies.txt

# Run as daemon (background)
yt-cm cookies.txt daemon --interval 3600

# Run in foreground
yt-cm cookies.txt daemon --interval 60 --foreground

# Stop daemon
yt-cm cookies.txt stop

# Check daemon status
yt-cm cookies.txt status
```

### Python API

```python
from yt_cm import YouTubeCookieManager

manager = YouTubeCookieManager("cookies.txt")

# Validate cookie
result = manager.validate()
print(result["valid"])  # True or False

# Renew session
result = manager.renew_session()
print(result["renewed"])  # True or False
print(result["cookie_expiry"])  # Expiration info

# Check auth cookies
result = manager.get_auth_info()
print(result["all_present"])  # All required cookies present
print(result["missing_cookies"])  # List of missing cookies

# Export cookies
content = manager.export_netscape()
```

## Cookie File Format

yt-cm uses the Netscape cookie format exported by browser extensions like "EditThisCookie" or "Cookie Quick Manager".

Example:
```
# Netscape HTTP Cookie File
.youtube.com	TRUE	/	TRUE	1809975208	SID	test_value
.youtube.com	TRUE	/	TRUE	1809975208	__Secure-3PSID	test_value
```

## Development

```bash
git clone https://github.com/daedalus/yt-cm.git
cd yt-cm
pip install -e ".[test]"

# Run tests
pytest

# Format code
ruff format src/ tests/

# Lint code
ruff check src/ tests/

# Type check
mypy src/

# Install pre-commit hooks
pre-commit install
```

## Architecture

The project follows a layered architecture:

- `yt_cm.core` - Domain logic (YouTubeCookieManager)
- `yt_cm.services` - Business logic (CookieDaemon)
- `yt_cm.cli` - Command-line interface
