Commit ·
035d47f
1
Parent(s): 59eebb3
init
Browse files
aria.py
CHANGED
|
@@ -24,11 +24,23 @@ class Aria2Client:
|
|
| 24 |
logger.info(f"Download status: {download.status}")
|
| 25 |
return download
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
class Aria2Downloader:
|
| 28 |
def __init__(self, client):
|
| 29 |
self.client = client
|
| 30 |
|
| 31 |
def add_download(self, link, path):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if link.startswith("magnet:"):
|
| 33 |
return self.client.add_magnet(link, path)
|
| 34 |
else:
|
|
|
|
| 24 |
logger.info(f"Download status: {download.status}")
|
| 25 |
return download
|
| 26 |
|
| 27 |
+
def check_url(self, link: str):
|
| 28 |
+
try:
|
| 29 |
+
response = self.api.client.get(link)
|
| 30 |
+
return response.status_code == 200
|
| 31 |
+
except Exception as e:
|
| 32 |
+
logger.error(f"Error checking URL: {e}")
|
| 33 |
+
return False
|
| 34 |
+
|
| 35 |
class Aria2Downloader:
|
| 36 |
def __init__(self, client):
|
| 37 |
self.client = client
|
| 38 |
|
| 39 |
def add_download(self, link, path):
|
| 40 |
+
if not self.client.check_url(link):
|
| 41 |
+
logger.error(f"Invalid URL: {link}")
|
| 42 |
+
return None
|
| 43 |
+
|
| 44 |
if link.startswith("magnet:"):
|
| 45 |
return self.client.add_magnet(link, path)
|
| 46 |
else:
|