Here's a README.md file for your project:
# Youtube Search
An asynchronous Python library to search for YouTube videos and retrieve detailed metadata, such as video title, channel, views, and more.
## Features
- Search for YouTube videos using keywords.
- Retrieve video metadata such as ID, title, description, channel, duration, views, and more.
- Supports setting a maximum number of search results.
- Provides data in `dict` or `JSON` format.
## Installation
Ensure you have Python 3.7 or higher installed.
-
Clone the repository:
git clone https://github.com/rafkix/youtube-search.git cd youtube-search
-
Install dependencies:
pip install aiohttp
Usage
import asyncio
from async_youtube_search import AsyncYoutubeSearch
async def main():
# Create an instance of AsyncYoutubeSearch
search = AsyncYoutubeSearch("rafkix", max_results=5)
# Fetch video results
await search.fetch_results()
# Get results as a dictionary
videos = search.to_dict()
print(videos)
# Get results as JSON
videos_json = search.to_json()
print(videos_json)
# Run the script
asyncio.run(main())
Methods
fetch_results()
Fetches video search results asynchronously.
to_dict(clear_cache=True)
Returns the search results as a Python dictionary.
clear_cache: Clears the internal cache of video results if set toTrue.
to_json(clear_cache=True)
Returns the search results as a JSON string.
clear_cache: Clears the internal cache of video results if set toTrue.
Example Output
{
"videos": [
{
"id": "abcd1234",
"thumbnails": ["https://example.com/thumbnail.jpg"],
"title": "Learn Python Programming",
"long_desc": "An introductory tutorial to Python programming.",
"channel": "Programming with John",
"duration": "12:34",
"views": "1.2M views",
"publish_time": "3 weeks ago",
"url_suffix": "/watch?v=abcd1234"
}
]
}
Requirements
- Python 3.7+
- aiohttp
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
rafkix
Feel free to contribute, open issues, or suggest improvements!
Metadata
Release files for async-youtube-search 2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| async_youtube_search-2.tar.gz | 3.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_youtube_search-2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / async_youtube_search-2.tar.gz
| Download URL | async_youtube_search-2.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e7650a734f0d0f97bf3d73f95d816fce8357c49640efab634ac79765f3cd89b
|
|
BLAKE2b-256 checksum How to use checksums |
7b95e2ee1195989223c8365f8c9c70f0e1913d7dfce7dd0b2c0875a407f9e4a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Release files / async_youtube_search-2-py3-none-any.whl
| Download URL | async_youtube_search-2-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70cbbbec8793ed2e32f3e8ad1a98e658db013a12b9c6ae74f3c9aae458f4e7d6
|
|
BLAKE2b-256 checksum How to use checksums |
f9cf394f248849abae4e6454d2b000b9383a4e31b48922b4f35cb447e190056c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Security for async-youtube-search 2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.