Skip to content

Commit

Permalink
Improve basic display
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Dec 20, 2018
1 parent 8598654 commit 84ae386
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/aria2p/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ def main(args=None):
api = API(client)
downloads = api.get_downloads()

print(f"{'GID':<17} {'STATUS':<9} {'PROGRESS':<8} {'DOWN_SPEED':<12} {'ETA':<8} NAME")
for download in downloads:
total = int(download.total_length)
completed = int(download.completed_length)
download_speed = int(download.download_speed)
if total == 0:
progress = "?"
progress = "0%"
else:
progress = "%.2f%%" % (completed / total * 100)
if download_speed > 0:
Expand All @@ -100,6 +101,6 @@ def main(args=None):
download_speed /= 1024
unit = u
download_speed = "%.2f " % download_speed + unit
print(f"{download.gid} {download.status:<8} {progress:<8} {download_speed:<12} {eta:<12} {download.name}")
print(f"{download.gid:<17} {download.status:<9} {progress:<8} {download_speed:<12} {eta:<8} {download.name}")

return 0
2 changes: 1 addition & 1 deletion src/aria2p/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __str__(self):
@property
def name(self):
if not self._name:
self._name = self.files[0].path.replace(self.dir, "").lstrip("/")
self._name = self.files[0].path.replace(self.dir, "").lstrip("/").split("/")[0]
return self._name

@property
Expand Down

0 comments on commit 84ae386

Please sign in to comment.