Usage cleanup, squashed URL error

master
Anthony Forsberg 2017-05-23 13:51:19 -04:00
parent 25e5da8cdb
commit ff13704c83
1 changed files with 25 additions and 36 deletions

View File

@ -1,35 +1,27 @@
"""bandcamp-dl
Usage:
bandcamp-dl [url]
bandcamp-dl [--template=<template>] [--base-dir=<dir>]
[--full-album]
(<url> | --artist=<artist> --album=<album> | --artist=<artist> --track=<track>)
[--overwrite]
[--no-art]
[--embed-lyrics]
[--group]
[--embed-art]
[--no-slugify]
bandcamp-dl (-h | --help)
bandcamp-dl (--version)
bandcamp-dl [options] [URL]
Arguments:
URL Bandcamp album/track URL
Options:
-h --help Show this screen.
-v --version Show version.
-a --artist=<artist> The artist's slug (from the URL)
-s --track=<track> The track's slug (from the URL)
-b --album=<album> The album's slug (from the URL)
-t --template=<template> Output filename template.
[default: %{artist}/%{album}/%{track} - %{title}]
-d --base-dir=<dir> Base location of which all files are downloaded.
-f --full-album Download only if all tracks are available.
-o --overwrite Overwrite tracks that already exist. Default is False.
-n --no-art Skip grabbing album art
-e --embed-lyrics Embed track lyrics (If available)
-g --group Use album/track Label as iTunes grouping
-r --embed-art Embed album art (If available)
-n --no-slugify Disable slugification of track, album, and artist names.
-h --help Show this screen.
-v --version Show version.
--artist=<artist> The artist's slug (from the URL)
--track=<track> The track's slug (from the URL)
--album=<album> The album's slug (from the URL)
--template=<template> Output filename template.
[default: %{artist}/%{album}/%{track} - %{title}]
--base-dir=<dir> Base location of which all files are downloaded.
-f --full-album Download only if all tracks are available.
-o --overwrite Overwrite tracks that already exist. Default is False.
-n --no-art Skip grabbing album art
-e --embed-lyrics Embed track lyrics (If available)
-g --group Use album/track Label as iTunes grouping
-r --embed-art Embed album art (If available)
-y --no-slugify Disable slugification of track, album, and artist names.
"""
"""
Coded by:
@ -73,7 +65,7 @@ def main():
if os.path.isfile(session_file):
with open(session_file, "r") as f:
arguments = ast.literal_eval(f.readline())
elif arguments['<url>'] is None and arguments['--artist'] is None:
elif arguments['URL'] is None and arguments['--artist'] is None:
print(__doc__)
else:
with open(session_file, "w") as f:
@ -84,23 +76,20 @@ def main():
elif arguments['--artist'] and arguments['--track']:
url = Bandcamp.generate_album_url(arguments['--artist'], arguments['--track'], "track")
else:
url = arguments['<url>']
url = arguments['URL']
if arguments['--no-art']:
album = bandcamp.parse(url, False)
else:
album = bandcamp.parse(url)
if not album:
print("The url {} is not a valid bandcamp page.".format(url))
elif arguments['--full-album'] and not album['full']:
if arguments['--full-album'] and not album['full']:
print("Full album not available. Skipping...")
else:
bandcamp_downloader = BandcampDownloader(url, arguments['--template'], basedir, arguments['--overwrite'],
elif arguments['URL']:
bandcamp_downloader = BandcampDownloader(arguments['--template'], basedir, arguments['--overwrite'],
arguments['--embed-lyrics'], arguments['--group'],
arguments['--embed-art'], arguments['--no-slugify'])
arguments['--embed-art'], arguments['--no-slugify'], url)
bandcamp_downloader.start(album)
if __name__ == '__main__':
main()