Added argparse support

This commit is contained in:
Navan Chauhan 2020-03-09 22:50:22 +05:30
parent b3fb1f3d6c
commit 29df89f0d4
1 changed files with 28 additions and 4 deletions

28
main.py
View File

@ -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
"""
if music:
name, title = download_file(query)
gen_vapor(name, title)