Skip to main content

khtube is an opensource software library enables you to download YouTube videos easily at all available qualities along with subtitles and can also download your videos in audio format.


Install

For installation::

pip install khtube

(For macOS)::

pip3 install khtube

Using khtube on Windows

In windows, make sure that if you don't have ffmpeg pre-installed in your computer then do install it first before downloading any video.

You can download ffmpeg in your system by runing our builtin python method which is written below:

import khtube

khtube.checkFFmpeg()

In linux based systems, ffmpeg is already installed by default.

Download your first YouTube video

import khtube

khtube.single_video(link, quality, verbose, output = "./Videos/", verbose)
  • Where link is string containing YouTube's video URL.
  • quality is by default best. But you can change it by passing the available quality in integer value. Tou find the all available formats of any YouTube video along with their quality extensions. Use khtube.available_quality(link), where link is again the string containing YouTube's url. It will print the available qualities of any video.
  • verbose is being used to express details in more words. It can be 1, 2 or 3 depending upon your needs.
  • output is the saving directory of your downloaded YouTube video. If you don't pass it it will save in your default location.

Download the videos of Entire Playlist of YouTube

khtube.video_playlist(link, min_views = 1, quality=248, start_index = 1, verbose, best=True, output="./Videos/")
  • Where link is string containing YouTube's Playlist URL.
  • min_views is the filtration of views. By default it is 1. So if there's any video with NO VIEWS, it will not be downloaded. However you can change it accordingly.
  • quality is by default best. But you can change it by passing the available quality in integer value. Tou find the all available formats of any YouTube video along with their quality extensions. Use khtube.available_quality(link), where link is again the string containing YouTube's url. It will print the available qualities of any video.
  • start_index is the Starting index of a video in playlist. For example, if you pass 4 and there are only 10 videos, only 7 will be downloaded. Given that, 0 is not inclusive.
  • verbose is being used to express details in more words. It can be 1, 2 or 3 depending upon your needs.
  • output is the saving directory of your downloaded YouTube video. If you don't pass it it will save in your default location.

Download the videos of Entire Channel on YouTube

khtube.video_playlist(link, min_views = 1, quality=248, start_index = 1, verbose, best=True, output="./Videos/")
  • Where link is string containing YouTube's Channel URL.
  • min_views is the filtration of views. By default it is 1. So if there's any video with NO VIEWS, it will not be downloaded. However you can change it accordingly.
  • quality is by default best. But you can change it by passing the available quality in integer value. Tou find the all available formats of any YouTube video along with their quality extensions. Use khtube.available_quality(link), where link is again the string containing YouTube's url. It will print the available qualities of any video.
  • start_index is the Starting index of a video in channel. For example, if you pass 4 and there are only 10 videos, only 7 will be downloaded. Given that, 0 is not inclusive.
  • verbose is being used to express details in more words. It can be 1, 2 or 3 depending upon your needs.
  • output is the saving directory of your downloaded YouTube video. If you don't pass it it will save in your default location.

Download Subtitles of any Video

khtube.download_sub(link, language="en-US")
  • Where link is string containing YouTube's Video URL.
  • language is the parameter in string for language format. A video can have multiple subtitles. By default it will download in English US. But you can always change that upon your needs. To find out the available subtitles, use khtube.available_sub(link), where link is again the string containing YouTube's url. It will print the available subtitle languages of any video with codes.

Download AudioOnly of any Video

khtube.only_music(link, quality=251, verbose=2)
  • Where link is string containing YouTube's Video URL.
  • quality is by default best. But you can change it by passing the available quality in integer value. Tou find all the available formats of any YouTube video along with their quality extensions. Use khtube.available_quality(link), where link is again the string containing YouTube's url. It will print the available qualities of any video. Caution: Be careful, only use audio quality code or else you can leave it by default.
  • verbose is being used to express details in more words. It can be 1, 2 or 3 depending upon your needs.

Download the AudioOnly of videos of Entire Playlist of YouTube

khtube.audio_playlist(link, min_views = 1, quality=248, start_index = 1, verbose = 2 , best=True, output="./Videos/")
  • Where link is string containing YouTube's Playlist URL.
  • min_views is the filtration of views. By default it is 1. So if there's any video with NO VIEWS, it will not be downloaded. However you can change it accordingly.
  • quality is by default best. But you can change it by passing the available quality in integer value. Tou find all the available formats of any YouTube video along with their quality extensions. Use khtube.available_quality(link), where link is again the string containing YouTube's url. It will print the available qualities of any video. Caution: Be careful, only use audio quality code or else you can leave it by default.
  • start_index is the Starting index of a video in playlist. For example, if you pass 4 and there are only 10 videos, only 7 will be downloaded. Given that, 0 is not inclusive.
  • verbose is being used to express details in more words. It can be 1, 2 or 3 depending upon your needs.
  • output is the saving directory of your downloaded YouTube video. If you don't pass it it will save in your default location.

Download the AudioOnly of videos of Entire Channel of YouTube

khtube.channel_audio(link, min_views = 1, quality=248, start_index = 1, verbose = 2 , best=True, output="./Videos/")
  • Where link is string containing YouTube's Channel URL.
  • min_views is the filtration of views. By default it is 1. So if there's any video with NO VIEWS, it will not be downloaded. However you can change it accordingly.
  • quality is by default best. But you can change it by passing the available quality in integer value. Tou find all the available formats of any YouTube video along with their quality extensions. Use khtube.available_quality(link), where link is again the string containing YouTube's url. It will print the available qualities of any video. Caution: Be careful, only use audio quality code or else you can leave it by default.
  • start_index is the Starting index of a video in channel. For example, if you pass 4 and there are only 10 videos, only 7 will be downloaded. Given that, 0 is not inclusive.
  • verbose is being used to express details in more words. It can be 1, 2 or 3 depending upon your needs.
  • output is the saving directory of your downloaded YouTube video. If you don't pass it it will save in your default location.

Contribute

You've discovered a bug or something else you want to change - excellent!

You've worked out a way to fix it – even better!

You want to tell us about it – best of all!

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

Contact

Send your message at this form https://forms.gle/eoxmiRzLiKJLSvTF7, We will review it shortly.

Developers

Kodershub Developers © https://kodershub.tech

License

MIT

Metadata

Release files for khtube 0.9.26

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for khtube 0.9.26
File Size Uploaded
khtube-0.9.26.tar.gz 7.4 kB Details

Release files / khtube-0.9.26.tar.gz

Download URL khtube-0.9.26.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
499ad1bd8a80149fbb4e5c6bc5823d6ade750c765d1265cc3e774135fae4329c
BLAKE2b-256 checksum
How to use checksums
501d438ded8e0e7ad9a06cde16c0f74c848af9e0a8299eb2360ae36b8f91d462
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.9.26 This release

1 release file

0.9.25

1 release file

0.9.24

1 release file

0.9.23

1 release file

0.9.22

1 release file

0.9.21

1 release file

0.9.20

1 release file

0.9.19

1 release file

0.9.18

1 release file

0.9.17

1 release file

0.9.16

1 release file

0.9.15

1 release file

0.9.14

1 release file

0.9.13

1 release file

0.9.12

1 release file

0.9.11

1 release file

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