From 0176249237e096b925e7deadd902fde2ca9243aa Mon Sep 17 00:00:00 2001 From: Anthony Forsberg Date: Thu, 12 Jan 2017 19:20:52 -0500 Subject: [PATCH] Fixes #95 --- bandcamp_dl/bandcamp_dl.py | 2 +- bandcamp_dl/bandcampdownloader.py | 14 ++++++++------ setup.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bandcamp_dl/bandcamp_dl.py b/bandcamp_dl/bandcamp_dl.py index 2f1d14d..de39b0d 100755 --- a/bandcamp_dl/bandcamp_dl.py +++ b/bandcamp_dl/bandcamp_dl.py @@ -49,7 +49,7 @@ from .bandcampdownloader import BandcampDownloader def main(): - arguments = docopt(__doc__, version='bandcamp-dl 0.0.6-01') + arguments = docopt(__doc__, version='bandcamp-dl 0.0.6-03') bandcamp = Bandcamp() if arguments['--artist'] and arguments['--album']: diff --git a/bandcamp_dl/bandcampdownloader.py b/bandcamp_dl/bandcampdownloader.py index 9f7da07..cae5b0c 100644 --- a/bandcamp_dl/bandcampdownloader.py +++ b/bandcamp_dl/bandcampdownloader.py @@ -31,7 +31,8 @@ class BandcampDownloader: return path.encode('utf-8') - def create_directory(self, filename): + @staticmethod + def create_directory(filename): directory = os.path.dirname(filename) if not os.path.exists(directory): os.makedirs(directory) @@ -50,7 +51,7 @@ class BandcampDownloader: print("Accessing track " + str(track_index + 1) + " of " + str(len(album['tracks']))) - filename = self.template_to_path(track_meta) + filename = self.template_to_path(track_meta).decode() dirname = self.create_directory(filename) if not track.get('url'): @@ -70,7 +71,7 @@ class BandcampDownloader: if not self.overwrite and os.path.isfile(filename): file_size = os.path.getsize(filename) - 128 if int(file_size) != int(file_length): - print(filename + " is incomplete, redownloading.") + print("{} is incomplete, redownloading.".format(filename)) os.remove(filename) else: print("Skipping track {0} - {1} as it's already downloaded, use --overwrite to overwrite existing files" @@ -78,7 +79,7 @@ class BandcampDownloader: continue with open(filename, "wb") as f: - print("Downloading: " + filename[:-4]) + print("Downloading: {}".format(filename[:-4])) if file_length is None: f.write(r.content) else: @@ -97,7 +98,7 @@ class BandcampDownloader: return False if album['art']: try: - with open(dirname + "/cover.jpg", "wb") as f: + with open("{}/cover.jpg".format(dirname), "wb") as f: r = requests.get(album['art'], stream=True) f.write(r.content) except Exception as e: @@ -106,7 +107,8 @@ class BandcampDownloader: return True - def write_id3_tags(self, filename, meta): + @staticmethod + def write_id3_tags(filename, meta): print("\nEncoding . . .") audio = MP3(filename) diff --git a/setup.py b/setup.py index 5087919..e792d2b 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ here = path.abspath(path.dirname(__file__)) setup( name='bandcamp-downloader', - version='0.0.6-02', + version='0.0.6-03', description='bandcamp-dl downloads albums and tracks from Bandcamp for you', long_description=open('README.rst').read(), url='https://github.com/iheanyi/bandcamp-dl',