Async YouTube search library (using YouTube MWeb API).
Project description
# ytq
`ytq` is a lightweight and fast Python library for searching YouTube videos using the official MWeb API.
It supports both synchronous and asynchronous usage, making it suitable for scripts, bots, and larger applications.
---
## Features
- Simple and fast YouTube search
- Asynchronous and synchronous support
- Returns structured JSON results
- Includes video title, ID, URL, and thumbnail
- Supports result limiting (`limit` parameter)
- Works without any API keys
---
## Installation
You can install `ytq` from PyPI (after publishing):
```bash
pip install ytq
Or from source:
git clone https://github.com/ahmeddreas/ytq.git
cd ytq
pip install .
Example Usage
Synchronous
from ytq import search
results = search("lofi music", limit=5)
for video in results:
print(video["title"], video["url"])
Asynchronous
import asyncio
from ytq import asearch
async def main():
results = await asearch("python tutorials", limit=3)
print(results[0]["title"], results[0]["url"])
asyncio.run(main())
Parameters
| Parameter | Type | Description |
|---|---|---|
query |
str |
The search query (e.g., "python programming") |
limit |
int or None |
Number of results to return. If None, returns all available results. |
auto_print |
bool |
If True, prints formatted results to console. Default is True. |
Returned JSON Structure
Each search result is a dictionary with the following keys:
{
"video_id": "abcd1234",
"title": "Example video title",
"url": "https://m.youtube.com/watch?v=abcd1234",
"thumbnail": "https://i.ytimg.com/vi/abcd1234/hqdefault.jpg"
}
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Author
Ahmed D. Ismail GitHub: Ahmed d. Ismail
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ytq_search-0.1.1.tar.gz
(2.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ytq_search-0.1.1.tar.gz.
File metadata
- Download URL: ytq_search-0.1.1.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3019c3fd11e161841098361759874bc8c2d956a95670d5ee1f06bebff097f12c
|
|
| MD5 |
e11cfe4ca315f0fd2f19ad12f27bbe99
|
|
| BLAKE2b-256 |
56640b7641f30ce2ed46df0a282f11bcd292513cbf6dec3247e90f746267e5b1
|
File details
Details for the file ytq_search-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ytq_search-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8521a82fee35dadce05cfd560c0ccfc282215bbe0a869c73bce159128dfa2e2c
|
|
| MD5 |
ee0c0df448fb1416d009e9b3e787cd9d
|
|
| BLAKE2b-256 |
8c67a604a6701df7438456ef46e8256025903957826b70fe8d504c45c1772f06
|