Skip to main content

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 asyncio for efficient asynchronous operations.
  • Some operations may require multiple calls to retrieve all available data (e.g., pagination for comments and playlists).
  • py-yt-search provides 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_yt_search-0.7.2.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_yt_search-0.7.2-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file py_yt_search-0.7.2.tar.gz.

File metadata

  • Download URL: py_yt_search-0.7.2.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_yt_search-0.7.2.tar.gz
Algorithm Hash digest
SHA256 e91bba58d89d97f2a8ad190db2cc47ab0866ccee600db02dfcde312fd1ab7360
MD5 0bd39dd50de73bb7301093c6f159f2fe
BLAKE2b-256 ee7c15c2212bb5924892c3accd5b5f824e4997f730d1d597944d2d84f06206e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_yt_search-0.7.2.tar.gz:

Publisher: publish.yml on AshokShau/py-yt-search

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_yt_search-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: py_yt_search-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_yt_search-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e0e9cd429df9c16aa21a0cfc176e56ff0093e1aa666c8f46523b5c6bbd21ada8
MD5 b4fc2be868322e9a35cf53b1177eb1ba
BLAKE2b-256 6f9f99f2b3c3fcaa994fd639cbb3583ab869038024762b9680ce2075968e5aa0

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_yt_search-0.7.2-py3-none-any.whl:

Publisher: publish.yml on AshokShau/py-yt-search

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page