From 29df89f0d46e897ab8e4dcab2db4012a276a279b Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Mon, 9 Mar 2020 22:50:22 +0530 Subject: [PATCH] Added argparse support --- main.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 7b84260..9f050da 100644 --- a/main.py +++ b/main.py @@ -8,9 +8,31 @@ from logzero import setup_logger import re import urllib.request import urllib.parse - +import argparse import time +version = 1.0 +style = False + +text = 'This program takes YouTube URL or title of a song and converts it into vaporwave' + +parser = argparse.ArgumentParser(description = text) +parser.add_argument("-M", "--music", help="generate v a p o r w a v e music", action="store_true") +parser.add_argument("-V", "--version", help="show program version", action="store_true") +parser.add_argument("-i", "--input", help="input url") + +args = parser.parse_args() + +if args.version: + print("vaporwave generator 旺育栄", version) + exit +if args.music: + music = True +if args.input: + query = args.url +else: + query = input("Enter target song's name or YouTube URL: ") + MAX_DURATION = 600 # In-case the program finds a compilation youtube_urls = ('youtube.com', 'https://www.youtube.com/', 'http://www.youtube.com/', 'http://youtu.be/', 'https://youtu.be/', 'youtu.be') @@ -116,12 +138,14 @@ def gen_vapor(filePath, title): os.system("rm -r beats/") - +""" ## Makes this a command line tool: disable when we get the webserver going sys.argv.pop(0) query = "" for s in sys.argv: query = query + s +""" -name, title = download_file(query) -gen_vapor(name, title) +if music: + name, title = download_file(query) + gen_vapor(name, title)