Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing configuration file #233

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions spotify_dl/spotify_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def spotify_dl():
"""Main entry point of the script."""
parser = argparse.ArgumentParser(prog='spotify_dl')
parser.add_argument('-l', '--url', action="store",
help="Spotify Playlist link URL", type=str, required=True)
help="Spotify Playlist link URL", type=str, required=False)
parser.add_argument('-o', '--output', type=str, action='store',
help='Specify download directory.', required=True)
help='Specify download directory.', required=False)
parser.add_argument('-d', '--download', action='store_true',
help='Download using youtube-dl', default=True)
parser.add_argument('-f', '--format_str', type=str, action='store',
Expand Down Expand Up @@ -50,14 +50,19 @@ def spotify_dl():
config = json.loads(file.read())

for key, value in config.items():
if value and (value.lower() in ['true', 't']):
if (isinstance(value, bool) and value) or (isinstance(value, str) and value and value.lower() in ['true', 't']):
setattr(args, key, True)
else:
setattr(args, key, value)

if args.verbose:
log.setLevel(DEBUG)

if not hasattr(args, 'url'):
raise(Exception("No playlist url provided"))
if not hasattr(args, 'o'):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be hasattr(args, 'output'): Caught this after merging. opened #235

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah crap. missed that.

raise(Exception("No output folder configured"))

log.info('Starting spotify_dl')
log.debug('Setting debug mode on spotify_dl')

Expand Down