Parse out flags, mock like we're actuall downloading things

This commit is contained in:
Salt 2020-03-03 20:08:14 -06:00
parent f3485fe42d
commit 83f79a0d4a

View File

@ -12,6 +12,7 @@ from appdirs import AppDirs
from pathlib import Path
import argparse
import json
import logging
import sys
class Library:
@ -34,9 +35,18 @@ class Library:
json.dump(self.albums, libfd, indent='\t')
return
def download(self):
for album in self.albums:
return
def validate(self):
self.load()
# Download library
def download(self, album=None):
if album is not None:
print('Downloading album: ' + album)
else:
print('Downloading entire library')
for album, albumcontent in self.albums.items():
for song, songcontent in albumcontent.items():
logging.info('Downloaded song: ' + song + ' by ' + songcontent['artist'])
class BadWitch:
# Our program
@ -48,6 +58,8 @@ class BadWitch:
help='Override default library file with this one')
self.argparser.add_argument('-v', '--verbose', action='store_true',
help='Show more status messages')
self.argparser.add_argument('-d', '--debug', action='store_true',
help='Show even more status messages')
self.argparser.add_argument('action', metavar='action', nargs='?',
choices=['download', 'list', 'test'],
help='Action to perform on the library')
@ -57,11 +69,18 @@ class BadWitch:
def execute(self):
self.args = self.argparser.parse_args()
# Parse flags
if self.args.debug:
logging.basicConfig(level=logging.DEBUG)
elif self.args.verbose:
logging.basicConfig(level=logging.INFO)
# Initialize library
libfile = self.args.library or self.dirs.user_data_dir + '/lib.json'
lib = Library(file=libfile)
# Perform action
if self.args.action == 'download':
lib.load()
lib.download()
return
elif self.args.action == 'list':
lib.load()