Session file tweaks and track url schema fix
bandcamp-dl will now ignore the session file if a url is manually provided, this should prevent clashing with things such as frontends or other external programs which make use of it. Restoring previous download sessions will still work, simply run bandcamp-dl without arguments (Other than --base-dir if previously used) and it will behave as normal. Bandcamp changed their file urls to include the protocol, code has been changed to reflect this.master
parent
abb32308a6
commit
905ff8cfd4
|
@ -63,9 +63,9 @@ Options
|
|||
-h --help Show this screen.
|
||||
-v --version Show version.
|
||||
-d --debug Verbose logging.
|
||||
--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)
|
||||
--artist=<artist> The artist's slug (from the URL, --track or --album is required)
|
||||
--track=<track> The track's slug (from the URL, for use with --artist)
|
||||
--album=<album> The album's slug (from the URL, for use with --artist)
|
||||
--template=<template> Output filename template.
|
||||
[default: %{artist}/%{album}/%{track} - %{title}]
|
||||
--base-dir=<dir> Base location of which all files are downloaded.
|
||||
|
|
|
@ -10,9 +10,9 @@ Options:
|
|||
-h --help Show this screen.
|
||||
-v --version Show version.
|
||||
-d --debug Verbose logging.
|
||||
--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)
|
||||
--artist=<artist> The artist's slug (from the URL, --track or --album is required)
|
||||
--track=<track> The track's slug (from the URL, for use with --artist)
|
||||
--album=<album> The album's slug (from the URL, for use with --artist)
|
||||
--template=<template> Output filename template.
|
||||
[default: %{artist}/%{album}/%{track} - %{title}]
|
||||
--base-dir=<dir> Base location of which all files are downloaded.
|
||||
|
@ -67,11 +67,9 @@ def main():
|
|||
basedir = arguments['--base-dir'] or os.getcwd()
|
||||
session_file = "{}/{}.not.finished".format(basedir, __version__)
|
||||
|
||||
if os.path.isfile(session_file):
|
||||
if os.path.isfile(session_file) and arguments['URL'] is None:
|
||||
with open(session_file, "r") as f:
|
||||
arguments = ast.literal_eval(f.readline())
|
||||
elif arguments['URL'] is None and arguments['--artist'] is None:
|
||||
print(__doc__)
|
||||
else:
|
||||
with open(session_file, "w") as f:
|
||||
f.write("".join(str(arguments).split('\n')))
|
||||
|
@ -80,6 +78,8 @@ def main():
|
|||
url = Bandcamp.generate_album_url(arguments['--artist'], arguments['--album'], "album")
|
||||
elif arguments['--artist'] and arguments['--track']:
|
||||
url = Bandcamp.generate_album_url(arguments['--artist'], arguments['--track'], "track")
|
||||
elif arguments['--artist']:
|
||||
print(__doc__)
|
||||
else:
|
||||
url = arguments['URL']
|
||||
|
||||
|
@ -105,5 +105,6 @@ def main():
|
|||
else:
|
||||
logging.debug(" /!\ Something went horribly wrong /!\ ")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -126,7 +126,10 @@ class Bandcamp:
|
|||
}
|
||||
|
||||
if 'mp3-128' in track['file']:
|
||||
track_metadata['url'] = "http:" + track['file']['mp3-128']
|
||||
if 'https' in track['file']['mp3-128']:
|
||||
track_metadata['url'] = track['file']['mp3-128']
|
||||
else:
|
||||
track_metadata['url'] = "http:" + track['file']['mp3-128']
|
||||
else:
|
||||
track_metadata['url'] = None
|
||||
|
||||
|
|
Loading…
Reference in New Issue