From 97de4f86d6637ddf1ba7420b9cd90ea7d9368340 Mon Sep 17 00:00:00 2001 From: Jackson Taylor Date: Thu, 31 Mar 2022 00:39:29 -0400 Subject: Add argparse command line parser --- jamos | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/jamos b/jamos index 9e6c850..a6cec06 100755 --- a/jamos +++ b/jamos @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import argparse import datetime import glob import json @@ -62,6 +63,15 @@ def get_all_files(directory): return files +def get_command_line_options(): + parser = argparse.ArgumentParser(description="Download songs from YouTube Music") + parser.add_argument("url", metavar="string", type=str, help="Playlist or Song URL to download") + parser.add_argument("-c", "--cookies", metavar="string", type=str, help="Cookie file to use.") + parser.add_argument("-o", "--output", metavar="string", type=str, help="Output directory to use") + + return parser.parse_args() + + # TODO: switch command line args to argparse def get_playlist_url(): return sys.argv[1] @@ -151,8 +161,10 @@ def write_metadata_to_song_file(file, metadata): if __name__ == "__main__": + args = get_command_line_options() + # Get the playlist url from the command line - playlist_url = get_playlist_url() + playlist_url = args.url # TODO: Save urls to file so we can start in the # middle of the playlist if needed @@ -173,3 +185,4 @@ if __name__ == "__main__": json_data = json.load(json_file) write_metadata_to_song_file(f, json_data) move_file(f, json_data) + -- cgit v1.2.3