# 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:
```bash
pip install git+https://github.com/AshokShau/py-yt-search@master
```
```bash
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
```python
_search = Search('NoCopyrightSounds', limit=1, language='en', region='US')
result = await _search.next()
print(result)
```
### Search for Videos Only
```python
videosSearch = VideosSearch('NoCopyrightSounds', limit=10, language='en', region='US')
videosResult = await videosSearch.next()
print(videosResult)
```
### Search for Channels Only
```python
channelsSearch = ChannelsSearch('NoCopyrightSounds', limit=1, language='en', region='US')
channelsResult = await channelsSearch.next()
print(channelsResult)
```
### Search for Playlists Only
```python
playlistsSearch = PlaylistsSearch('NoCopyrightSounds', limit=1, language='en', region='US')
playlistsResult = await playlistsSearch.next()
print(playlistsResult)
```
### Get Video Details
```python
video = await Video.get('z0GKGpObgPY')
print(video)
```
### Get Playlist Details
```python
playlist = await Playlist.get('https://www.youtube.com/playlist?list=PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK')
print(playlist)
```
### Fetch Comments from a Video
```python
comments = Comments('_ZdsmLgCVdU')
await comments.getNextComments()
print(len(comments.comments['result']))
```
### Retrieve Video Transcript
```python
transcript = await Transcript.get('https://www.youtube.com/watch?v=L7kF4MXXCoA')
print(transcript)
```
### Get YouTube Search Suggestions
```python
suggestions = await Suggestions.get('NoCopyrightSounds', language='en', region='US')
print(suggestions)
```
## Running the Script
To run the script, execute:
```bash
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](/LICENSE) file for details.
## Credits
This project is based on [youtube-search-python](https://github.com/alexmercerind/youtube-search-python) by Alex Mercer.
Raw data
{
"_id": null,
"home_page": "https://github.com/AshokShau/py-yt",
"name": "py-yt-search",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "youtube youtube-api video-search playlist channel search py_yt py-yt-search py-yt",
"author": "AshokShau",
"author_email": "<abishnoi69@outlook.com>",
"download_url": "https://files.pythonhosted.org/packages/1b/09/edee0dcc341da5bc96b2b003b2b7971a1484c9d0f2c9caf6ec68975974e3/py_yt_search-0.2.tar.gz",
"platform": null,
"description": "# YouTube Data Extraction with py-yt-search\n\n\n## Features\n- Search YouTube for videos, channels, and playlists\n- Retrieve video information and available formats\n- Extract comments from videos\n- Get video transcripts in different languages\n- Fetch search suggestions from YouTube\n- Retrieve details of YouTube channels and their playlists\n\n## Installation\nMake sure you have Python installed (>=3.8). Install `py-yt-search` using:\n\n```bash\npip install git+https://github.com/AshokShau/py-yt-search@master\n```\n\n```bash\npip install py-yt-search\n```\n\n## Usage\nThe script uses `asyncio` to execute YouTube queries asynchronously. Below is an overview of the main functions:\n\n### Search YouTube\n```python\n_search = Search('NoCopyrightSounds', limit=1, language='en', region='US')\nresult = await _search.next()\nprint(result)\n```\n\n### Search for Videos Only\n```python\nvideosSearch = VideosSearch('NoCopyrightSounds', limit=10, language='en', region='US')\nvideosResult = await videosSearch.next()\nprint(videosResult)\n```\n\n### Search for Channels Only\n```python\nchannelsSearch = ChannelsSearch('NoCopyrightSounds', limit=1, language='en', region='US')\nchannelsResult = await channelsSearch.next()\nprint(channelsResult)\n```\n\n### Search for Playlists Only\n```python\nplaylistsSearch = PlaylistsSearch('NoCopyrightSounds', limit=1, language='en', region='US')\nplaylistsResult = await playlistsSearch.next()\nprint(playlistsResult)\n```\n\n### Get Video Details\n```python\nvideo = await Video.get('z0GKGpObgPY')\nprint(video)\n```\n\n### Get Playlist Details\n```python\nplaylist = await Playlist.get('https://www.youtube.com/playlist?list=PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK')\nprint(playlist)\n```\n\n### Fetch Comments from a Video\n```python\ncomments = Comments('_ZdsmLgCVdU')\nawait comments.getNextComments()\nprint(len(comments.comments['result']))\n```\n\n### Retrieve Video Transcript\n```python\ntranscript = await Transcript.get('https://www.youtube.com/watch?v=L7kF4MXXCoA')\nprint(transcript)\n```\n\n### Get YouTube Search Suggestions\n```python\nsuggestions = await Suggestions.get('NoCopyrightSounds', language='en', region='US')\nprint(suggestions)\n```\n\n## Running the Script\nTo run the script, execute:\n```bash\npython script.py\n```\n\nEnsure `asyncio.run(main())` is at the end of the script to handle async execution.\n\n## Notes\n- The script uses `asyncio` for efficient asynchronous operations.\n- Some operations may require multiple calls to retrieve all available data (e.g., pagination for comments and playlists).\n- `py-yt-search` provides various search filters to refine results, such as sorting by upload date or filtering by duration.\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](/LICENSE) file for details.\n\n## Credits\nThis project is based on [youtube-search-python](https://github.com/alexmercerind/youtube-search-python) by Alex Mercer.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for searching and retrieving YouTube data using py-yt-search.",
"version": "0.2",
"project_urls": {
"Download": "https://github.com/AshokShau/py-yt-search/releases/latest",
"Homepage": "https://github.com/AshokShau/py-yt",
"Source": "https://github.com/AshokShau/py-yt-search",
"Tracker": "https://github.com/AshokShau/py-yt-search/issues"
},
"split_keywords": [
"youtube",
"youtube-api",
"video-search",
"playlist",
"channel",
"search",
"py_yt",
"py-yt-search",
"py-yt"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0ebcccd65eac7b3a1c0352d48ca66428d86d902e31d3e1c787e551dce5a48203",
"md5": "5ef42f616cfdde909c8cfafe1fef26dd",
"sha256": "195c2bdb8b1495a2a5587fb5644f81878930e8a3fd14e85683ce0e59fc43a719"
},
"downloads": -1,
"filename": "py_yt_search-0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5ef42f616cfdde909c8cfafe1fef26dd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 41821,
"upload_time": "2025-02-22T11:12:21",
"upload_time_iso_8601": "2025-02-22T11:12:21.579993Z",
"url": "https://files.pythonhosted.org/packages/0e/bc/ccd65eac7b3a1c0352d48ca66428d86d902e31d3e1c787e551dce5a48203/py_yt_search-0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1b09edee0dcc341da5bc96b2b003b2b7971a1484c9d0f2c9caf6ec68975974e3",
"md5": "0b80b621379a6294e9bde86503534ebd",
"sha256": "d33f237ccbd1b3ed581a9bbe996b70e238ea67ceaae74da9ae84c018350f22ff"
},
"downloads": -1,
"filename": "py_yt_search-0.2.tar.gz",
"has_sig": false,
"md5_digest": "0b80b621379a6294e9bde86503534ebd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 35554,
"upload_time": "2025-02-22T11:12:23",
"upload_time_iso_8601": "2025-02-22T11:12:23.420327Z",
"url": "https://files.pythonhosted.org/packages/1b/09/edee0dcc341da5bc96b2b003b2b7971a1484c9d0f2c9caf6ec68975974e3/py_yt_search-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-22 11:12:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AshokShau",
"github_project": "py-yt",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "py-yt-search"
}