Skip to content

Commit

Permalink
refactor: remove unused variables & format output
Browse files Browse the repository at this point in the history
  • Loading branch information
Zehina committed Sep 24, 2021
1 parent e7d7643 commit b9f4b37
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/webtoon_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ def render(self, task: "Task") -> Text:
"""Show data transfer speed."""
speed = task.finished_speed or task.speed
if speed is None:
return Text("?", style="progress.data.speed", justify='center')
return Text(f"?", style="progress.data.speed", justify='center')
return Text(f"{task.speed:2.0f} {task.fields.get('type')}/s", style="progress.data.speed", justify='center')


######################## Header Configuration ################################
if os.name == 'nt':
user_agent = ('Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
Expand All @@ -72,6 +71,7 @@ def render(self, task: "Task") -> Text:
BarColumn(bar_width=None),
"[progress.percentage]{task.percentage:>3.2f}%",
"•",
SpinnerColumn(style="progress.data.speed"),
CustomTransferSpeedColumn(),
"•",
TextColumn("[green]{task.completed:>02d}[/]/[bold green]{task.fields[rendered_total]}[/]", justify="left"),
Expand Down Expand Up @@ -220,7 +220,7 @@ def download_image(chapter_download_task_id: int, url: str, dest: str, chapter_n
r.raw.decode_content = True
file_name = f'{chapter_number}_{page_number}'
if(image_format == 'png'):
im = Image.open(r.raw).save(os.path.join(dest, f'{file_name}.png'))
Image.open(r.raw).save(os.path.join(dest, f'{file_name}.png'))
else:
with open(os.path.join(dest, f'{file_name}.jpg'), 'wb') as f:
shutil.copyfileobj(r.raw, f)
Expand Down Expand Up @@ -347,7 +347,7 @@ def download_webtoon(series_url: str, start_chapter: int, end_chapter: int, dest
chapter_download_futures, return_when=concurrent.futures.FIRST_COMPLETED
)

for future in done:
for _ in done:
progress.update(series_download_task, advance=1)
if done_event.is_set():
return
Expand Down

0 comments on commit b9f4b37

Please sign in to comment.