Skip to content

Commit 06d95c1

Browse files
committed
Fixed notification error caused due to --onefile's temp directory and aria2's executable location call
1 parent f39b5c6 commit 06d95c1

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ __pycache__/
88

99
# Project specific files
1010
config.json
11+
*.exe
1112

1213
# Distribution / packaging
1314
.Python

main.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,24 @@ 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"aria2c -s 16 -x 16 -j 16 --max-concurrent-downloads=6 -d \"{download_dir}\" -Z " + "\"" + "\" \"".join(links) + "\""
161+
cmd = f"{client.config.aria_2_path} -s 16 -x 16 -j 16 --max-concurrent-downloads=6 -d \"{download_dir}\" -Z " + "\"" + "\" \"".join(links) + "\""
162162
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
163163
for line in p.stdout:
164164
print(line.decode('utf-8', errors='ignore').rstrip())
165165
p.wait()
166166
total_time = f"{round(time.perf_counter() - start, 2)}s"
167167
client.config.logger.info(f"Downloaded {len(links)} episodes to \"{download_dir.resolve()}\" in {total_time}")
168168
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}<<<")
169+
# Some pyinstaller config for --onefile option
169170
try:
170-
notification.notify(title="SenPY | Download Completed", message=f"Downloaded {len(links)} episode(s) to \"{str(download_dir.resolve())}\" in {total_time}", app_icon=str(Path("icon.ico").resolve()), timeout=10)
171+
base_path = Path(sys._MEIPASS)
171172
except Exception:
172-
pass # silently ignore if unable to show notification
173+
base_path = Path(".")
174+
app_icon = base_path / "icon.ico"
175+
try:
176+
notification.notify(title="SenPY | Download Completed", message=f"Downloaded {len(links)} episode(s) to \"{str(download_dir.resolve())}\" in {total_time}", app_icon=str(app_icon.resolve()), timeout=10)
177+
except Exception as e:
178+
client.config.logger.error(f"Unable to send notification | Error: {e}") # silently ignore if unable to show notification
173179
client.utils.sleep(10)
174180
home()
175181

senpy/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
from .client import GogoClient
44
from .errors import *
55

6-
__version__ = "0.1.1"
6+
__version__ = "0.1.2"
77
__author__ = "</Rudransh Joshi> (FireHead90544)"

0 commit comments

Comments
 (0)