summaryrefslogtreecommitdiff
path: root/jamos
diff options
context:
space:
mode:
authorJackson Taylor <jackson@jacksontaylor.xyz>2022-03-31 00:39:29 -0400
committerJackson Taylor <jackson@jacksontaylor.xyz>2022-04-05 16:52:15 -0400
commit97de4f86d6637ddf1ba7420b9cd90ea7d9368340 (patch)
tree07109612aec746c4c0d96d32f1afce67bb6de00a /jamos
parent2845fe0df3b89ef01167890db70307f5934859a9 (diff)
Add argparse command line parser
Diffstat (limited to 'jamos')
-rwxr-xr-xjamos15
1 files changed, 14 insertions, 1 deletions
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)
+