Skip to content

Commit 3d3f1c1

Browse files
committed
Fixed bug caused due to spaces in path
1 parent c160918 commit 3d3f1c1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

main.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,14 @@ def download_using_aria2(links: list, anime_dir: str) -> None:
158158
"""
159159
start = time.perf_counter()
160160
download_dir = client.config.downloads_dir / anime_dir
161-
cmd = f"'{client.config.aria_2_path}' -s 16 -x 16 -j 16 --max-concurrent-downloads=6 -d \"{download_dir}\" -Z " + "\"" + "\" \"".join(links) + "\""
161+
cmd = [str(client.config.aria_2_path.resolve()), "-s", '16', "-x", '16', "-j", '16', "--max-concurrent-downloads=6", "-d", str(download_dir.resolve()), "-Z"]
162+
cmd = subprocess.list2cmdline(cmd)
163+
cmd += " \"" + "\" \"".join(links) + "\""
162164
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
163165
for line in p.stdout:
164166
print(line.decode('utf-8', errors='ignore').rstrip())
165167
p.wait()
166-
total_time = f"{round(time.perf_counter() - start, 2)}s"
168+
total_time = client.utils.convert_seconds_to_time(round(time.perf_counter() - start))
167169
client.config.logger.info(f"Downloaded {len(links)} episodes to \"{download_dir.resolve()}\" in {total_time}")
168170
print(f"{Fore.GREEN}>>> Download Completed in {total_time} {Fore.WHITE}| Downloaded {Fore.GREEN}{len(links)} episodes{Fore.WHITE} to {Fore.RED}\"{download_dir.resolve()}\" {Fore.GREEN}<<<")
169171
# Some pyinstaller config for --onefile option
@@ -281,7 +283,7 @@ def download_anime() -> None:
281283
print(f"\n>>> {Fore.GREEN}Fetched Download Links. Starting Download in 10 seconds. Please do not close the window.")
282284
print(f"\n>>> {Fore.RED}If you are an experienced aria2 user, download links have also been logged in the log file, you can do stuffs with them later.")
283285
print(f"\n>>> {Fore.GREEN}Downloads a maximum of 6 episodes at a time to maximize speed and downloads.")
284-
client.utils.sleep(10)
286+
client.utils.sleep(6)
285287
header()
286288
download_using_aria2(download_links, anime_dir) # The actual downloading here
287289

0 commit comments

Comments
 (0)