Perform YouTube video searches without the API
Project description
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!
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
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 async_youtube_search-2.tar.gz.
File metadata
- Download URL: async_youtube_search-2.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e7650a734f0d0f97bf3d73f95d816fce8357c49640efab634ac79765f3cd89b
|
|
| MD5 |
e33465a68e96dff997f10fba8085f502
|
|
| BLAKE2b-256 |
7b95e2ee1195989223c8365f8c9c70f0e1913d7dfce7dd0b2c0875a407f9e4a2
|
File details
Details for the file async_youtube_search-2-py3-none-any.whl.
File metadata
- Download URL: async_youtube_search-2-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70cbbbec8793ed2e32f3e8ad1a98e658db013a12b9c6ae74f3c9aae458f4e7d6
|
|
| MD5 |
f63ae78c71aa66361cbff94b78f68050
|
|
| BLAKE2b-256 |
f9cf394f248849abae4e6454d2b000b9383a4e31b48922b4f35cb447e190056c
|