Metadata-Version: 2.4
Name: iq-yt
Version: 1.0.3
Summary: YouTube data extraction without YouTube Data API v3 — by BabiesIQ
Author-email: BabiesIQ <babiesiq@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/BabiesIQ/iq-yt
Project-URL: Repository, https://github.com/BabiesIQ/iq-yt
Project-URL: Bug Tracker, https://github.com/BabiesIQ/iq-yt/issues
Project-URL: Telegram, https://t.me/BabiesIQ
Keywords: youtube,search,scraper,async,iq-yt,babiesiq
Classifier: Development Status :: 5 - Production/Stable
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 :: Software Development :: Libraries
Classifier: Topic :: Internet
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp>=3.9.0
Dynamic: license-file

# iq-yt

> YouTube data extraction — **no API key needed** 🚀

[![PyPI](https://img.shields.io/pypi/v/iq-yt)](https://pypi.org/project/iq-yt/)
[![Python](https://img.shields.io/pypi/pyversions/iq-yt)](https://pypi.org/project/iq-yt/)
[![License](https://img.shields.io/github/license/BabiesIQ/iq-yt)](LICENSE)
[![Telegram](https://img.shields.io/badge/Telegram-@BabiesIQ-blue?logo=telegram)](https://t.me/BabiesIQ)

`iq-yt` is an async Python library for searching YouTube and extracting video, channel, playlist, transcript, and suggestion data — **without the YouTube Data API v3**.

Made with ❤️ by [@BabiesIQ](https://t.me/BabiesIQ)

---

## Installation

```bash
pip install iq-yt
```

Or install latest from GitHub:

```bash
pip install git+https://github.com/BabiesIQ/iq-yt
```

---

## Features

- 🔍 Search videos, channels, and playlists
- 🎬 Get full video info by URL or ID (uses player API — always accurate)
- 📋 Get playlist details and video list
- 💬 Fetch video transcripts in any language
- 📡 Get search suggestions (autocomplete)
- 📺 Get channel info
- 🔄 Async/await support (asyncio)
- 🌐 Proxy support

---

## Quick Start

```python
import asyncio
from iq_yt import VideosSearch, Video

async def main():
    # Search videos
    search = VideosSearch("Arijit Singh", limit=5)
    result = await search.next()
    for video in result["result"]:
        print(video["title"], video["link"])

    # Get video info by URL or ID — always returns correct data
    info = await Video.get("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
    print(info["title"])

asyncio.run(main())
```

---

## Usage

### Search Videos

```python
from iq_yt import VideosSearch

search = VideosSearch("NoCopyrightSounds", limit=10, language="en", region="US")
result = await search.next()
print(result)
```

### Search Channels

```python
from iq_yt import ChannelsSearch

search = ChannelsSearch("NoCopyrightSounds", limit=5)
result = await search.next()
print(result)
```

### Search Playlists

```python
from iq_yt import PlaylistsSearch

search = PlaylistsSearch("lofi hip hop", limit=5)
result = await search.next()
print(result)
```

### Get Video Info (by ID or URL)

```python
from iq_yt import Video

# Works with full URL
video = await Video.get("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

# Also works with just the video ID
video = await Video.get("dQw4w9WgXcQ")

print(video["title"])
print(video["channel"]["name"])
print(video["duration"]["text"])
```

### Get Video Transcript

```python
from iq_yt import Transcript

transcript = await Transcript.get("https://www.youtube.com/watch?v=dQw4w9WgXcQ", language="en")
for segment in transcript["result"]:
    print(segment["start"], segment["text"])
```

### Get Search Suggestions

```python
from iq_yt import Suggestions

result = await Suggestions.get("arijit", language="en", region="IN")
print(result["result"])
```

### Get Channel Info

```python
from iq_yt import Channel

info = await Channel.get("https://www.youtube.com/@NoCopyrightSounds")
print(info["result"]["name"])
print(info["result"]["subscribers"])
```

### Get Playlist Info

```python
from iq_yt import Playlist

info = await Playlist.get("https://www.youtube.com/playlist?list=PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK")
print(info["result"]["title"])
for video in info["result"]["videos"]:
    print(video["title"])
```

### Using with Proxy

```python
search = VideosSearch("lofi", limit=5, proxy="http://user:pass@host:port")
result = await search.next()
```

---

## Music Bot — Best Practice

When using in a music bot, **always use `Video.get()` for video IDs/URLs** — it hits the player API directly and always returns the correct data. `VideosSearch` is only for text queries.

```python
from iq_yt import Video, VideosSearch
import re

YT_REGEX = re.compile(
    r"(?:https?://)?(?:www\.)?(?:youtube\.com/watch\?v=|youtu\.be/)([a-zA-Z0-9_-]{11})"
)

async def resolve_track(query: str):
    match = YT_REGEX.search(query)
    if match or len(query) == 11:
        # Direct fetch — always accurate
        return await Video.get(query)
    else:
        # Text search
        search = VideosSearch(query, limit=1)
        result = await search.next()
        return result["result"][0] if result["result"] else None
```

---

## License

[MIT](LICENSE)
