A Python package for searching and retrieving YouTube data using py-yt-search.
Project description
YouTube Data Extraction with py-yt-search
Features
- Search YouTube for videos, channels, and playlists
- Retrieve video information and available formats
- Extract comments from videos
- Get video transcripts in different languages
- Fetch search suggestions from YouTube
- Retrieve details of YouTube channels and their playlists
Installation
Make sure you have Python installed (>=3.8). Install py-yt-search using:
pip install git+https://github.com/AshokShau/py-yt-search@master
pip install py-yt-search
Usage
The script uses asyncio to execute YouTube queries asynchronously. Below is an overview of the main functions:
Search YouTube
_search = Search('NoCopyrightSounds', limit=1, language='en', region='US')
result = await _search.next()
print(result)
Search for Videos Only
videosSearch = VideosSearch('NoCopyrightSounds', limit=10, language='en', region='US')
videosResult = await videosSearch.next()
print(videosResult)
Search for Channels Only
channelsSearch = ChannelsSearch('NoCopyrightSounds', limit=1, language='en', region='US')
channelsResult = await channelsSearch.next()
print(channelsResult)
Search for Playlists Only
playlistsSearch = PlaylistsSearch('NoCopyrightSounds', limit=1, language='en', region='US')
playlistsResult = await playlistsSearch.next()
print(playlistsResult)
Get Video Details
video = await Video.get('z0GKGpObgPY')
print(video)
Get Playlist Details
playlist = await Playlist.get('https://www.youtube.com/playlist?list=PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK')
print(playlist)
Fetch Comments from a Video
comments = Comments('_ZdsmLgCVdU')
await comments.getNextComments()
print(len(comments.comments['result']))
Retrieve Video Transcript
transcript = await Transcript.get('https://www.youtube.com/watch?v=L7kF4MXXCoA')
print(transcript)
Get YouTube Search Suggestions
suggestions = await Suggestions.get('NoCopyrightSounds', language='en', region='US')
print(suggestions)
Running the Script
To run the script, execute:
python script.py
Ensure asyncio.run(main()) is at the end of the script to handle async execution.
Notes
- The script uses
asynciofor efficient asynchronous operations. - Some operations may require multiple calls to retrieve all available data (e.g., pagination for comments and playlists).
py-yt-searchprovides various search filters to refine results, such as sorting by upload date or filtering by duration.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Credits
This project is based on youtube-search-python by Alex Mercer.
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 py_yt_search-0.7.0b2.tar.gz.
File metadata
- Download URL: py_yt_search-0.7.0b2.tar.gz
- Upload date:
- Size: 35.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da579fecb2c653245518832cee16e73e7b8200173e2d2e2472cc0dcfe1884676
|
|
| MD5 |
478864b72aa4242f21ca1e89809f1eab
|
|
| BLAKE2b-256 |
bf92c0c1091b98a08cb44a3064bd40b4b51c02f0eb6b3e392f7c51ad484ce71b
|
Provenance
The following attestation bundles were made for py_yt_search-0.7.0b2.tar.gz:
Publisher:
publish.yml on AshokShau/py-yt-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_yt_search-0.7.0b2.tar.gz -
Subject digest:
da579fecb2c653245518832cee16e73e7b8200173e2d2e2472cc0dcfe1884676 - Sigstore transparency entry: 1278762052
- Sigstore integration time:
-
Permalink:
AshokShau/py-yt-search@68dc3f1ae978a2888abb9a437a829ba73e9d609b -
Branch / Tag:
refs/tags/v0.7.0b2 - Owner: https://github.com/AshokShau
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68dc3f1ae978a2888abb9a437a829ba73e9d609b -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_yt_search-0.7.0b2-py3-none-any.whl.
File metadata
- Download URL: py_yt_search-0.7.0b2-py3-none-any.whl
- Upload date:
- Size: 46.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
751c2fbf26923ae9b03875f737608fa651fb9058b1a5279c5929c4838d644c2a
|
|
| MD5 |
757ca514a9e563d2bcd6fda8b38736e9
|
|
| BLAKE2b-256 |
25bd41e76b2124640fd5261e16ba4f5480422a605ed09d438bae26f7039956e0
|
Provenance
The following attestation bundles were made for py_yt_search-0.7.0b2-py3-none-any.whl:
Publisher:
publish.yml on AshokShau/py-yt-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_yt_search-0.7.0b2-py3-none-any.whl -
Subject digest:
751c2fbf26923ae9b03875f737608fa651fb9058b1a5279c5929c4838d644c2a - Sigstore transparency entry: 1278762209
- Sigstore integration time:
-
Permalink:
AshokShau/py-yt-search@68dc3f1ae978a2888abb9a437a829ba73e9d609b -
Branch / Tag:
refs/tags/v0.7.0b2 - Owner: https://github.com/AshokShau
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68dc3f1ae978a2888abb9a437a829ba73e9d609b -
Trigger Event:
push
-
Statement type: