Commit ·
d2d3d49
1
Parent(s): 5419f28
init
Browse files- aria.py +3 -25
- bot_commands.py +1 -0
aria.py
CHANGED
|
@@ -20,28 +20,6 @@ class Aria2Client:
|
|
| 20 |
return self.api.add_uris([link], {'dir': path})
|
| 21 |
|
| 22 |
def get_download(self, gid: str):
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
def __init__(self, client: Aria2Client):
|
| 27 |
-
self.client = client
|
| 28 |
-
|
| 29 |
-
def add_download(self, link: str, path: str):
|
| 30 |
-
try:
|
| 31 |
-
if link.startswith("magnet:"):
|
| 32 |
-
download = self.client.add_magnet(link, path)
|
| 33 |
-
else:
|
| 34 |
-
download = self.client.add_uris(link, path)
|
| 35 |
-
logger.info(f"Started: {download.gid} DIR:{download.dir}")
|
| 36 |
-
return download
|
| 37 |
-
except Exception as e:
|
| 38 |
-
logger.error(f"Download Error: {str(e)}")
|
| 39 |
-
return None
|
| 40 |
-
|
| 41 |
-
def get_download_path(self, gid: str):
|
| 42 |
-
try:
|
| 43 |
-
download = self.client.get_download(gid)
|
| 44 |
-
return str(download.dir), download.name
|
| 45 |
-
except Exception as e:
|
| 46 |
-
logger.error(f"Error getting download path: {str(e)}")
|
| 47 |
-
return None, None
|
|
|
|
| 20 |
return self.api.add_uris([link], {'dir': path})
|
| 21 |
|
| 22 |
def get_download(self, gid: str):
|
| 23 |
+
download = self.api.get_download(gid)
|
| 24 |
+
logger.info(f"Download status: {download.status}")
|
| 25 |
+
return download
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bot_commands.py
CHANGED
|
@@ -37,6 +37,7 @@ class BotCommands:
|
|
| 37 |
while True:
|
| 38 |
await asyncio.sleep(5) # Check every 5 seconds
|
| 39 |
download_status = self.aria2_downloader.client.get_download(download.gid)
|
|
|
|
| 40 |
if download_status.is_complete:
|
| 41 |
download_path, download_name = self.aria2_downloader.get_download_path(download.gid)
|
| 42 |
await message.reply_text(f"Download complete: {download_name}\nPath: {download_path}")
|
|
|
|
| 37 |
while True:
|
| 38 |
await asyncio.sleep(5) # Check every 5 seconds
|
| 39 |
download_status = self.aria2_downloader.client.get_download(download.gid)
|
| 40 |
+
logger.info(f"Checking download status: {download_status}")
|
| 41 |
if download_status.is_complete:
|
| 42 |
download_path, download_name = self.aria2_downloader.get_download_path(download.gid)
|
| 43 |
await message.reply_text(f"Download complete: {download_name}\nPath: {download_path}")
|