diff --git a/bandcamp_dl/bandcampdownloader.py b/bandcamp_dl/bandcampdownloader.py index bae0e98..ebc0c4d 100644 --- a/bandcamp_dl/bandcampdownloader.py +++ b/bandcamp_dl/bandcampdownloader.py @@ -16,6 +16,8 @@ if not sys.version_info[:2] == (3, 6): from bandcamp_dl.__init__ import __version__ +from bandcamp_dl.utils.clean_print import print_clean + class BandcampDownloader: def __init__(self, template, directory, overwrite, embed_lyrics, grouping, embed_art, no_slugify, debugging, urls=None): @@ -175,7 +177,7 @@ class BandcampDownloader: f.write(data) if not self.debugging: done = int(50 * dl / file_length) - sys.stdout.write( + print_clean( "\r({}/{}) [{}{}] :: Downloading: {}".format(self.track_num, self.num_tracks, "=" * done, " " * (50 - done), filename[:-8])) @@ -220,7 +222,7 @@ class BandcampDownloader: filename = filepath.rsplit('/', 1)[1][:-8] if not self.debugging: - sys.stdout.write("\r({}/{}) [{}] :: Encoding: {}".format(self.track_num, self.num_tracks, "=" * 50, filename)) + print_clean("\r({}/{}) [{}] :: Encoding: {}".format(self.track_num, self.num_tracks, "=" * 50, filename)) audio = MP3(filepath) audio.delete() @@ -258,4 +260,4 @@ class BandcampDownloader: os.rename(filepath, filepath[:-4]) if not self.debugging: - sys.stdout.write("\r({}/{}) [{}] :: Finished: {}".format(self.track_num, self.num_tracks, "=" * 50, filename)) + print_clean("\r({}/{}) [{}] :: Finished: {}".format(self.track_num, self.num_tracks, "=" * 50, filename)) diff --git a/bandcamp_dl/utils/clean_print.py b/bandcamp_dl/utils/clean_print.py new file mode 100644 index 0000000..cc54a40 --- /dev/null +++ b/bandcamp_dl/utils/clean_print.py @@ -0,0 +1,8 @@ +import os +import sys + + +def print_clean(msg): + terminal_size = os.get_terminal_size() + msg_length = len(msg) + sys.stdout.write("{}{}".format(msg, " " * (int(terminal_size[0]) - msg_length))) \ No newline at end of file diff --git a/setup.py b/setup.py index 353bb7b..9a82609 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from codecs import open from os import path import sys -appversion = "0.0.8-09" +appversion = "0.0.8-10" here = path.abspath(path.dirname(__file__))