Last active
November 14, 2021 14:18
-
-
Save rajendrakumaryadav/c4a3192582541d96a37b41fd8dd28fd4 to your computer and use it in GitHub Desktop.
Gist for Youtube-dl Help to download Video into Audio and Video Format
This file contains hidden or 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
import os | |
try: | |
video_link = input("Enter video path: ") | |
format = input("Enter [mp3] - Audio, [mp4] - Best Video: ") | |
string_param = "" | |
home = os.path.expanduser("~") | |
if format == "mp3": | |
string_param = "-x --audio-format='mp3' -o " + \ | |
home + "'/Music/%(title)s.%(ext)s' " + video_link | |
elif format == "mp4": | |
string_param = "-f 'bestvideo[height<=720]+bestaudio/best[height<=720]' -o" + \ | |
home + "'/Videos/%(title)s.%(ext)s' " + video_link | |
else: | |
print("Unknown format") | |
os._exit(1) | |
if string_param != "": | |
os.system("youtube-dl " + string_param) | |
else: | |
print("Sorry! Due to unknown format. Unable to Process!") | |
except KeyboardInterrupt as e: | |
print("\n\nExisting...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment