Created
April 14, 2017 19:57
-
-
Save arundasan91/ec5176d0652ceb01d86acf7a34c273d9 to your computer and use it in GitHub Desktop.
Function to download video's from YouTube to a specific location. Requires 'youtube-dl'.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def download_video(url, output_dir, filename, ext='mp4'): | |
"""Function to download video's from YouTube to a specific location. | |
Args: | |
url: YouTube URL. | |
output_dir: Output directory to save the video. | |
filename: Filename of the video. | |
ext: File type to save the video to. Default to mp4. | |
""" | |
import os | |
file_loc = output_dir + filename + "." + ext | |
# Download from Youtube URL | |
if (url): | |
print("Downloading Youtube Video") | |
os.system("youtube-dl -o " + file_loc + " -f " + ext + " " + url) | |
print("Done..") | |
else: | |
print("Please input a URL") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment