Name | pytubefix JSON |
Version |
8.12.1
JSON |
| download |
home_page | None |
Summary | Python3 library for downloading YouTube Videos. |
upload_time | 2025-02-01 17:33:55 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | MIT license |
keywords |
youtube
download
video
stream
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Pytubefix
[](https://pypi.org/project/pytubefix/)
[](https://github.com/sponsors/juanbindez)
[](https://opensource.org/licenses/MIT)
[](https://pytubefix.readthedocs.io/)
[](https://github.com/JuanBindez/pytubefix/releases)
[](https://pypi.org/project/pytubefix/)
## Python3 Library for Downloading YouTube Videos
---
## Installation
```bash
pip install pytubefix
```
---
## Quickstart
### Download MP4 Video in Highest Resolution:
```python
from pytubefix import YouTube
from pytubefix.cli import on_progress
url = "url"
yt = YouTube(url, on_progress_callback=on_progress)
print(yt.title)
ys = yt.streams.get_highest_resolution()
ys.download()
```
### Download Audio-Only (.m4a):
```python
from pytubefix import YouTube
from pytubefix.cli import on_progress
url = "url"
yt = YouTube(url, on_progress_callback=on_progress)
print(yt.title)
ys = yt.streams.get_audio_only()
ys.download()
```
### Download a Complete Playlist:
```python
from pytubefix import Playlist
from pytubefix.cli import on_progress
url = "url"
pl = Playlist(url)
for video in pl.videos:
ys = video.streams.get_audio_only()
ys.download()
```
### Use OAuth Authentication:
```python
from pytubefix import YouTube
from pytubefix.cli import on_progress
url = "url"
yt = YouTube(url, use_oauth=True, allow_oauth_cache=True, on_progress_callback=on_progress)
ys = yt.streams.get_highest_resolution()
ys.download() # Authenticate once for subsequent downloads
```
### Specify Output Directory for Downloads:
```python
from pytubefix import YouTube
from pytubefix.cli import on_progress
url = "url"
yt = YouTube(url, on_progress_callback=on_progress)
ys = yt.streams.get_highest_resolution()
ys.download(output_path="path/to/directory")
```
---
## Working with Subtitles/Caption Tracks
### View Available Subtitles:
```python
from pytubefix import YouTube
yt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')
print(yt.captions)
```
### Print Subtitle Tracks:
```python
from pytubefix import YouTube
yt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')
caption = yt.captions['a.en']
print(caption.generate_srt_captions())
```
### Save Subtitles to a Text File:
```python
from pytubefix import YouTube
yt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')
caption = yt.captions['a.en']
caption.save_captions("captions.txt")
```
---
## Using Channels
### Get Channel Name:
```python
from pytubefix import Channel
c = Channel("https://www.youtube.com/@ProgrammingKnowledge/featured")
print(f'Channel name: {c.channel_name}')
```
### Download All Videos from a Channel:
```python
from pytubefix import Channel
c = Channel("https://www.youtube.com/@ProgrammingKnowledge")
print(f'Downloading videos by: {c.channel_name}')
for video in c.videos:
video.streams.get_highest_resolution().download()
```
---
## Search for Videos
### Basic Search:
```python
from pytubefix import Search
results = Search('GitHub Issue Best Practices')
for video in results.videos:
print(f'Title: {video.title}')
print(f'URL: {video.watch_url}')
print(f'Duration: {video.length} sec')
print('---')
```
### Use Filters:
```python
from pytubefix.contrib.search import Search, Filter
filters = {
'upload_date': Filter.get_upload_date('Today'),
'type': Filter.get_type("Video"),
'duration': Filter.get_duration("Under 4 minutes"),
'features': [Filter.get_features("4K"), Filter.get_features("Creative Commons")],
'sort_by': Filter.get_sort_by("Upload date")
}
s = Search('music', filters=filters)
for video in s.videos:
print(video.watch_url)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pytubefix",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "youtube, download, video, stream",
"author": null,
"author_email": "Juan Bindez <juanbindez780@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/dd/c0/5201796b7df003368ac718225f26109300a9ac9c8c1cce9966c163b8636c/pytubefix-8.12.1.tar.gz",
"platform": null,
"description": "# Pytubefix\n\n[](https://pypi.org/project/pytubefix/)\n[](https://github.com/sponsors/juanbindez)\n[](https://opensource.org/licenses/MIT)\n[](https://pytubefix.readthedocs.io/)\n[](https://github.com/JuanBindez/pytubefix/releases)\n[](https://pypi.org/project/pytubefix/)\n\n## Python3 Library for Downloading YouTube Videos\n\n---\n\n## Installation\n\n```bash\npip install pytubefix\n```\n\n---\n\n## Quickstart\n\n### Download MP4 Video in Highest Resolution:\n\n```python\nfrom pytubefix import YouTube\nfrom pytubefix.cli import on_progress\n\nurl = \"url\"\n\nyt = YouTube(url, on_progress_callback=on_progress)\nprint(yt.title)\n\nys = yt.streams.get_highest_resolution()\nys.download()\n```\n\n### Download Audio-Only (.m4a):\n\n```python\nfrom pytubefix import YouTube\nfrom pytubefix.cli import on_progress\n\nurl = \"url\"\n\nyt = YouTube(url, on_progress_callback=on_progress)\nprint(yt.title)\n\nys = yt.streams.get_audio_only()\nys.download()\n```\n\n### Download a Complete Playlist:\n\n```python\nfrom pytubefix import Playlist\nfrom pytubefix.cli import on_progress\n\nurl = \"url\"\n\npl = Playlist(url)\nfor video in pl.videos:\n ys = video.streams.get_audio_only()\n ys.download()\n```\n\n### Use OAuth Authentication:\n\n```python\nfrom pytubefix import YouTube\nfrom pytubefix.cli import on_progress\n\nurl = \"url\"\n\nyt = YouTube(url, use_oauth=True, allow_oauth_cache=True, on_progress_callback=on_progress)\nys = yt.streams.get_highest_resolution()\nys.download() # Authenticate once for subsequent downloads\n```\n\n### Specify Output Directory for Downloads:\n\n```python\nfrom pytubefix import YouTube\nfrom pytubefix.cli import on_progress\n\nurl = \"url\"\n\nyt = YouTube(url, on_progress_callback=on_progress)\nys = yt.streams.get_highest_resolution()\nys.download(output_path=\"path/to/directory\")\n```\n\n---\n\n## Working with Subtitles/Caption Tracks\n\n### View Available Subtitles:\n\n```python\nfrom pytubefix import YouTube\n\nyt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')\nprint(yt.captions)\n```\n\n### Print Subtitle Tracks:\n\n```python\nfrom pytubefix import YouTube\n\nyt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')\ncaption = yt.captions['a.en']\nprint(caption.generate_srt_captions())\n```\n\n### Save Subtitles to a Text File:\n\n```python\nfrom pytubefix import YouTube\n\nyt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')\ncaption = yt.captions['a.en']\ncaption.save_captions(\"captions.txt\")\n```\n\n---\n\n## Using Channels\n\n### Get Channel Name:\n\n```python\nfrom pytubefix import Channel\n\nc = Channel(\"https://www.youtube.com/@ProgrammingKnowledge/featured\")\nprint(f'Channel name: {c.channel_name}')\n```\n\n### Download All Videos from a Channel:\n\n```python\nfrom pytubefix import Channel\n\nc = Channel(\"https://www.youtube.com/@ProgrammingKnowledge\")\nprint(f'Downloading videos by: {c.channel_name}')\n\nfor video in c.videos:\n video.streams.get_highest_resolution().download()\n```\n\n---\n\n## Search for Videos\n\n### Basic Search:\n\n```python\nfrom pytubefix import Search\n\nresults = Search('GitHub Issue Best Practices')\nfor video in results.videos:\n print(f'Title: {video.title}')\n print(f'URL: {video.watch_url}')\n print(f'Duration: {video.length} sec')\n print('---')\n```\n\n### Use Filters:\n\n```python\nfrom pytubefix.contrib.search import Search, Filter\n\nfilters = {\n 'upload_date': Filter.get_upload_date('Today'),\n 'type': Filter.get_type(\"Video\"),\n 'duration': Filter.get_duration(\"Under 4 minutes\"),\n 'features': [Filter.get_features(\"4K\"), Filter.get_features(\"Creative Commons\")],\n 'sort_by': Filter.get_sort_by(\"Upload date\")\n}\n\ns = Search('music', filters=filters)\nfor video in s.videos:\n print(video.watch_url)\n```\n",
"bugtrack_url": null,
"license": "MIT license",
"summary": "Python3 library for downloading YouTube Videos.",
"version": "8.12.1",
"project_urls": {
"Bug Reports": "https://github.com/juanbindez/pytubefix/issues",
"Homepage": "https://github.com/juanbindez/pytubefix",
"Read the Docs": "http://pytubefix.readthedocs.io/"
},
"split_keywords": [
"youtube",
" download",
" video",
" stream"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "36ff185aaa78e74bfcd75a1d174070ba1e037b07822779f0e834556e2f9e7fcf",
"md5": "0099fa6a7fbb08cefeeec71c0c6a0734",
"sha256": "1101463302b87c9a7172632232740413366919c4456255f5a85d114d0c60e0ec"
},
"downloads": -1,
"filename": "pytubefix-8.12.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0099fa6a7fbb08cefeeec71c0c6a0734",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 730673,
"upload_time": "2025-02-01T17:33:52",
"upload_time_iso_8601": "2025-02-01T17:33:52.419770Z",
"url": "https://files.pythonhosted.org/packages/36/ff/185aaa78e74bfcd75a1d174070ba1e037b07822779f0e834556e2f9e7fcf/pytubefix-8.12.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ddc05201796b7df003368ac718225f26109300a9ac9c8c1cce9966c163b8636c",
"md5": "1e91564533528bceb5588766820b7a19",
"sha256": "64af1ce25543007b1eadf1e2e01363839b0e4dd3c62ca2ae008f46c5462a2c54"
},
"downloads": -1,
"filename": "pytubefix-8.12.1.tar.gz",
"has_sig": false,
"md5_digest": "1e91564533528bceb5588766820b7a19",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 733063,
"upload_time": "2025-02-01T17:33:55",
"upload_time_iso_8601": "2025-02-01T17:33:55.993082Z",
"url": "https://files.pythonhosted.org/packages/dd/c0/5201796b7df003368ac718225f26109300a9ac9c8c1cce9966c163b8636c/pytubefix-8.12.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-01 17:33:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "juanbindez",
"github_project": "pytubefix",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pytubefix"
}