From 3fc8876218f371600213e299caf0c3f9770f80cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Tue, 7 Jun 2022 15:52:26 +0300 Subject: [PATCH] WIP: yt-dlp helper script --- ytdlp_helper.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 ytdlp_helper.py diff --git a/ytdlp_helper.py b/ytdlp_helper.py new file mode 100644 index 0000000..3455684 --- /dev/null +++ b/ytdlp_helper.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# Helps me to download whole playlists or just one video, in any format I wish. +from subprocess import run + + +def yt_dlp(url: str, what: int, form: int, ): + try: + if what == 1 and form == 1: + run(['yt-dlp', '-x', '--audio-format', "'mp3'", '--audio-quality', '0', f"'{url}'"]) + elif what == 1 and form == 2: + run(['yt-dlp', '-S', "'ext'", f"'{url}'"]) + elif what == 2 and form == 1: + run(['yt-dlp']) + except FileNotFoundError: + print("Are you sure that yt-dlp is installed?") + + +def main(): + print("Welcome to yt-dlp helper!\n") + url = input("Would you be kind and share the URL of content you wish to download: ") + + print("Which format do you want the downloaded content be in?") + print("1. mp3") + print("2. mp4") + form = int(input("Please make your selection: ")) + + print("1. I want to download a video.") + print("2. I want to download a playlist.") + if input("Please make your selection: ") == 1: + print("Alright! Your download shall begin now: ") + yt_dlp(url, 1, form) + else: + yt_dlp(url, 2, form) + + +if __name__ == '__main__': + main()