From 3590eaca3d3b8c5f49242f172e85fa3f7170bd54 Mon Sep 17 00:00:00 2001 From: sakamoto Date: Mon, 5 Aug 2024 07:17:58 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 utils.py diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..87e4e51 --- /dev/null +++ b/utils.py @@ -0,0 +1,72 @@ +import yt_dlp +import logging +import argparse + + + +parser = argparse.ArgumentParser( + description="A video-to-sheet music converter that uses opencv-python to extract significant frame changes.", + formatter_class=argparse.ArgumentDefaultsHelpFormatter, +) + +parser.add_argument("source", type=str, help="source of the file or a youtube link") +parser.add_argument( + "destination", type=str, help="destination of the output in pdf form" +) +parser.add_argument("-v", "--verbose", action="store_true", help="debug mode") +parser.add_argument( + "-a", "--alt-temp", action="store_false", help="use var dest to store temporary files" +) +parser.add_argument("-i","--ignore-temp", action="store_true", help="[requires -a] do not delete alt tmp") +parser.add_argument( + "-f", "--format", type=str, default="png", help="use output custom img format" +) + +args = parser.parse_args() +src = args.source +dest = args.destination +verbose = args.verbose +alt_temp = args.alt_temp +ignore_temp = args.ignore_temp +format = args.format + +if verbose: + logging.basicConfig(level=logging.DEBUG, format="[%(levelname)s] - %(message)s") +else: + logging.basicConfig(level=logging.INFO, format="[%(levelname)s] - %(message)s") +log = logging.getLogger() + +class Download: + def __init__(self): + pass + + def video(self, src, dest): + ydl_opts = { + "outtmpl": f"{dest}/%(title)s.%(ext)s", + "quiet": True, + } + try: + with yt_dlp.YoutubeDL(ydl_opts) as ydl: + info_dict = ydl.extract_info(src, download=False) + video_title = info_dict.get('title', 'Unknown Title') + log.info(f"Downloading: {video_title}") + ydl.download([src]) + log.info("Download Successful") + + except Exception as e: + log.error(f"An error occurred: {e}") + exit() + + def playlist(self, src, dest): + ydl_opts = { + "outtmpl": f"{dest}/%(title)s.%(ext)s", + "quiet": True, + } + + +class Misc: + def __init__(self): + pass + + def create_blank_image(self): + pass