Skip to content

Instantly share code, notes, and snippets.

@pakkinlau
Created October 28, 2023 17:34
Show Gist options
  • Save pakkinlau/fd49ae6fd20fe82f66cc963c08468e78 to your computer and use it in GitHub Desktop.
Save pakkinlau/fd49ae6fd20fe82f66cc963c08468e78 to your computer and use it in GitHub Desktop.
A python script that download a video without chopping. Only videoID is needed to be provided to run the script.
from pytube.cli import on_progress
from pytube import YouTube
import os
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
def download(link, target_folder=None):
yt = YouTube(
link, on_progress_callback=on_progress, use_oauth=True, allow_oauth_cache=True
)
yt.streams.filter(progressive=True, file_extension="mp4").order_by(
"resolution"
).desc().first().download(output_path=target_folder)
links = ["https://www.youtube.com/watch?v=iIJ6qnbfKCQ"]
target_folder = r"C:\Users\kinla\Downloads\YT extracts" # Replace with the desired target folder path
if __name__ == "__main__":
for link in links:
download(link, target_folder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment