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
Anthony Forsberg 2017-09-27 14:22:03 -04:00
parent abb32308a6
commit 905ff8cfd4
4 changed files with 15 additions and 11 deletions

View File

@ -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.

View File

@ -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()

View File

@ -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

View File

@ -3,7 +3,7 @@ from codecs import open
from os import path
import sys
appversion = "0.0.8-07"
appversion = "0.0.8-08"
here = path.abspath(path.dirname(__file__))