Skip to main content

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.

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.4.tar.gz (665.9 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.4-py3-none-any.whl (679.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_yt_search-0.7.4.tar.gz
  • Upload date:
  • Size: 665.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for py_yt_search-0.7.4.tar.gz
Algorithm Hash digest
SHA256 c5180e9cdf0f685c008f0053ab1218c664de54b6efde6d10fa0f389a4150b22b
MD5 03010a5e4402b64af6c93848114d768b
BLAKE2b-256 7cc3582e9f6c420c45951b0bc4f2184b1c240b97b1fa552cef7e4e1105ed876c

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_yt_search-0.7.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: py_yt_search-0.7.4-py3-none-any.whl
  • Upload date:
  • Size: 679.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for py_yt_search-0.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d01793d844710d448210dfefd634b1c9388b0be174eaa0cb6a556b528404bac2
MD5 49e5aee7af5d922b13bc661cc1c4e56f
BLAKE2b-256 84838e633299323c1eedf6b0066ee0b038efa8e70e837fb787da616fdff129c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_yt_search-0.7.4-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.

Release history Release notifications | RSS feed

0.8.0

2 files

0.7.5

2 files

This release

0.7.4 This release

2 files

0.7.3

2 files

0.7.2

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.9

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

1 file

0.5.5

1 file

0.5.4

1 file

0.5.3

1 file

0.5.2

1 file

0.5.1

1 file

0.5

1 file

0.4

1 file

0.3

1 file

0.2

2 files

0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page