Checks and alternative values added for singles

master
Anthony Forsberg 2017-01-28 08:23:31 -05:00
parent ce27187c87
commit fcd7526d5c
4 changed files with 15 additions and 5 deletions

View File

@ -28,10 +28,17 @@ class Bandcamp:
self.tracks = self.tralbum_data_json['trackinfo']
album_release = self.tralbum_data_json['album_release_date']
if album_release is None:
album_release = self.tralbum_data_json['current']['release_date']
try:
album_title = self.embed_data_json['album_title']
except KeyError:
album_title = self.tralbum_data_json['trackinfo'][0]['title']
album = {
"tracks": [],
"title": self.embed_data_json['album_title'],
"title": album_title,
"artist": self.embed_data_json['artist'],
"full": False,
"art": "",

View File

@ -51,7 +51,7 @@ from .bandcampdownloader import BandcampDownloader
def main():
arguments = docopt(__doc__, version='bandcamp-dl 0.0.7-05')
arguments = docopt(__doc__, version='bandcamp-dl 0.0.7-06')
bandcamp = Bandcamp()
basedir = arguments['--base-dir'] or os.getcwd()

View File

@ -24,7 +24,7 @@ class BandcampDownloader:
:param directory: download location
:param overwrite: if True overwrite existing files
"""
self.headers = {'user_agent': 'bandcamp-dl/0.0.7-05 (https://github.com/iheanyi/bandcamp-dl)'}
self.headers = {'user_agent': 'bandcamp-dl/0.0.7-06 (https://github.com/iheanyi/bandcamp-dl)'}
self.session = requests.Session()
if type(urls) is str:
@ -60,7 +60,10 @@ class BandcampDownloader:
path = self.template
path = path.replace("%{artist}", slugify(track['artist']))
path = path.replace("%{album}", slugify(track['album']))
path = path.replace("%{track}", str(track['track']).zfill(2))
if track['track'] == "None":
path = path.replace("%{track}", "Single")
else:
path = path.replace("%{track}", str(track['track']).zfill(2))
path = path.replace("%{title}", slugify(track['title']))
path = u"{0}/{1}.{2}".format(self.directory, path, "mp3")

View File

@ -6,7 +6,7 @@ here = path.abspath(path.dirname(__file__))
setup(
name='bandcamp-downloader',
version='0.0.7-05',
version='0.0.7-06',
description='bandcamp-dl downloads albums and tracks from Bandcamp for you',
long_description=open('README.rst').read(),
url='https://github.com/iheanyi/bandcamp-dl',