Search Youtube videos using python requests without Youtube API
Project description
youtube-search-requests
Search Youtube videos using python requests without Youtube API.
youtube-search-requests can search unlimited videos !!!
NOTE: youtube-search-requests is still in development. But, it should be stable for now.
Installation
pip install youtube-search-requests
CLI (Command Line Interface) Usage:
ysr "fish" --json
# or
youtube-search-requests "fish" --json
# do this if "ysr" and "youtube_search_requests" didn't work
python3 -m youtube_search_requests "fish" --json
# Output: {"urls": {'title': ..., 'url': 'https://www.youtube.com/watch?v=0gT8Ty0ClHc', thumbnails: [...], ...}}
Simple usage:
from youtube_search_requests import YoutubeSearch
y = YoutubeSearch('fish', max_results=10)
videos = y.search()
print(videos)
Search with given time usage:
from youtube_search_requests import YoutubeSearch
# given time 60 seconds for searching videos
y = YoutubeSearch('fish', max_results=10, timeout=60)
# if search not complete after 60 seconds
# force it to return results
videos = y.search()
print(videos)
Search with related videos usage:
from youtube_search_requests import YoutubeSearch
y = YoutubeSearch('fish', max_results=10, include_related_videos=True)
videos = y.search()
print(videos)
youtube-search-requests support safe search !!!
this helps to prevent mature videos in search results.
search with safe search usage:
from youtube_search_requests import YoutubeSearch
y = YoutubeSearch('fish', max_results=10, safe_search=True)
videos = y.search()
print(videos)
youtube-search-requests also support asynchronous method ! (using aiohttp module)
search with async usage:
import asyncio
from youtube_search_requests import AsyncYoutubeSearch
async def search():
y = AsyncYoutubeSearch('fish', max_results=10)
results = await y.search()
print(results)
asyncio.run(search())
You might be wonder, how youtube-search-requests work ?
in-short-word:
youtube-search-requests work like Youtube in browsers (playing with POST and GET method).
in-long-word:
- First, youtube-search-requests create a session for Youtube. (every opened youtube page in browser have it own session)
- Second, youtube-search-requests search videos using "Public Search Youtube API" that have been used youtube for searching videos in browsers.
- There we go, done !!! :D.
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
Close
Hashes for youtube-search-requests-0.0.26.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13edfa4d33b665e996963f7616c0a299ab9de7bc227bd2974c5fdde9726616ca |
|
MD5 | f2acf124ad3d4e38c60221630647fafe |
|
BLAKE2b-256 | b67056fadea0774f7da08acc52b5486cfc241a2f842f04f955d267f2f58ff12a |
Close
Hashes for youtube_search_requests-0.0.26-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec51728f343557a23ca6b30a5656e2833b72e293fb5904dc9153c0dfd7d2dfc6 |
|
MD5 | 08df070b5fdc69ef940f3bc6644b9a5b |
|
BLAKE2b-256 | b8aa870253f5b6313f4fb34a8e0fa66adc795a7c16c9a9aea3c4aa5092aae260 |