alaskavix12 commited on
Commit
99e03b0
·
1 Parent(s): d044791

initial commit

Browse files
Files changed (2) hide show
  1. aria.py +10 -1
  2. bot.py +0 -5
aria.py CHANGED
@@ -69,7 +69,7 @@ class Aria:
69
  logger.info(f'Changed gid from {gid} to {new_gid}')
70
  else:
71
  # Perform actions on download complete
72
- pass
73
 
74
  def __on_download_error(self, api, gid):
75
  sleep(0.5) # Ensure proper gid update
@@ -79,6 +79,15 @@ class Aria:
79
  logger.info(f"Download error message: {error}")
80
  # Perform actions on download error
81
 
 
 
 
 
 
 
 
 
 
82
  def start_listener(self):
83
  self.aria2.listen_to_notifications(
84
  threaded=True,
 
69
  logger.info(f'Changed gid from {gid} to {new_gid}')
70
  else:
71
  # Perform actions on download complete
72
+ threading.Thread(target=self.notify_download_complete, args=(download,)).start()
73
 
74
  def __on_download_error(self, api, gid):
75
  sleep(0.5) # Ensure proper gid update
 
79
  logger.info(f"Download error message: {error}")
80
  # Perform actions on download error
81
 
82
+ def notify_download_complete(self, download):
83
+ # This method will be called in a separate thread
84
+ asyncio.run(self.send_download_complete_message(download))
85
+
86
+ async def send_download_complete_message(self, download):
87
+ message = f"Download complete: {download.name}\nDownload path: {self.download_dir}/{download.name}"
88
+ await bot.send_message(CHAT_ID, message)
89
+ logger.info(message)
90
+
91
  def start_listener(self):
92
  self.aria2.listen_to_notifications(
93
  threaded=True,
bot.py CHANGED
@@ -66,11 +66,6 @@ async def clientbot():
66
  await message.reply_text(status_message)
67
  logger.info(f"Download status requested: {gid}")
68
 
69
- async def send_download_complete_message(download):
70
- message = f"Download complete: {download.name}\nDownload path: {aria2.download_dir}/{download.name}"
71
- await bot.send_message(CHAT_ID, message)
72
- logger.info(message)
73
-
74
  aria2.start_listener()
75
 
76
  await bot.start()
 
66
  await message.reply_text(status_message)
67
  logger.info(f"Download status requested: {gid}")
68
 
 
 
 
 
 
69
  aria2.start_listener()
70
 
71
  await bot.start()