Fixes #138 for all terminals

master
Anthony Forsberg 2018-02-07 17:32:53 -05:00
parent 1d82ca669a
commit e8a016fc35
3 changed files with 14 additions and 4 deletions

View File

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

View File

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

View File

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