mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-22 18:33:56 +00:00
Compare commits
4 Commits
v3.4.0
...
fix/fixing
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc4043c2c4 | ||
|
|
97cf02577a | ||
|
|
fbce53d61a | ||
|
|
1835adf8b4 |
@@ -1,48 +1,61 @@
|
|||||||
import aria2p
|
import aria2p
|
||||||
|
|
||||||
class HttpDownloader:
|
class HttpDownloader:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.download = None
|
self.download = None
|
||||||
self.aria2 = aria2p.API(
|
self.aria2 = aria2p.API(
|
||||||
aria2p.Client(
|
aria2p.Client(
|
||||||
host="http://localhost",
|
host="http://localhost",
|
||||||
port=6800,
|
port=6800,
|
||||||
secret=""
|
secret=""
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def start_download(self, url: str, save_path: str, header: str, out: str = None):
|
def start_download(self, url: str, save_path: str, header: str, out: str = None, allow_multiple_connections: bool = False):
|
||||||
if self.download:
|
if self.download:
|
||||||
self.aria2.resume([self.download])
|
self.aria2.resume([self.download])
|
||||||
else:
|
else:
|
||||||
downloads = self.aria2.add(url, options={"header": header, "dir": save_path, "out": out})
|
options = {
|
||||||
|
"header": header,
|
||||||
|
"dir": save_path,
|
||||||
|
"out": out
|
||||||
|
}
|
||||||
|
|
||||||
self.download = downloads[0]
|
if allow_multiple_connections:
|
||||||
|
options.update({
|
||||||
|
"split": "16",
|
||||||
|
"max-connection-per-server": "16",
|
||||||
|
"min-split-size": "1M"
|
||||||
|
})
|
||||||
|
|
||||||
def pause_download(self):
|
downloads = self.aria2.add(url, options=options)
|
||||||
if self.download:
|
|
||||||
self.aria2.pause([self.download])
|
|
||||||
|
|
||||||
def cancel_download(self):
|
self.download = downloads[0]
|
||||||
if self.download:
|
|
||||||
self.aria2.remove([self.download])
|
|
||||||
self.download = None
|
|
||||||
|
|
||||||
def get_download_status(self):
|
def pause_download(self):
|
||||||
if self.download == None:
|
if self.download:
|
||||||
return None
|
self.aria2.pause([self.download])
|
||||||
|
|
||||||
download = self.aria2.get_download(self.download.gid)
|
def cancel_download(self):
|
||||||
|
if self.download:
|
||||||
|
self.aria2.remove([self.download])
|
||||||
|
self.download = None
|
||||||
|
|
||||||
response = {
|
def get_download_status(self):
|
||||||
'folderName': download.name,
|
if self.download == None:
|
||||||
'fileSize': download.total_length,
|
return None
|
||||||
'progress': download.completed_length / download.total_length if download.total_length else 0,
|
|
||||||
'downloadSpeed': download.download_speed,
|
|
||||||
'numPeers': 0,
|
|
||||||
'numSeeds': 0,
|
|
||||||
'status': download.status,
|
|
||||||
'bytesDownloaded': download.completed_length,
|
|
||||||
}
|
|
||||||
|
|
||||||
return response
|
download = self.aria2.get_download(self.download.gid)
|
||||||
|
|
||||||
|
response = {
|
||||||
|
'folderName': download.name,
|
||||||
|
'fileSize': download.total_length,
|
||||||
|
'progress': download.completed_length / download.total_length if download.total_length else 0,
|
||||||
|
'downloadSpeed': download.download_speed,
|
||||||
|
'numPeers': 0,
|
||||||
|
'numSeeds': 0,
|
||||||
|
'status': download.status,
|
||||||
|
'bytesDownloaded': download.completed_length,
|
||||||
|
}
|
||||||
|
|
||||||
|
return response
|
||||||
|
|||||||
@@ -147,11 +147,11 @@ def action():
|
|||||||
torrent_downloader.start_download(url, data['save_path'])
|
torrent_downloader.start_download(url, data['save_path'])
|
||||||
else:
|
else:
|
||||||
if existing_downloader and isinstance(existing_downloader, HttpDownloader):
|
if existing_downloader and isinstance(existing_downloader, HttpDownloader):
|
||||||
existing_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'))
|
existing_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False))
|
||||||
else:
|
else:
|
||||||
http_downloader = HttpDownloader()
|
http_downloader = HttpDownloader()
|
||||||
downloads[game_id] = http_downloader
|
downloads[game_id] = http_downloader
|
||||||
http_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'))
|
http_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False))
|
||||||
|
|
||||||
downloading_game_id = game_id
|
downloading_game_id = game_id
|
||||||
|
|
||||||
|
|||||||
@@ -123,3 +123,14 @@ const copyAria2 = () => {
|
|||||||
|
|
||||||
copyAria2();
|
copyAria2();
|
||||||
downloadLudusavi();
|
downloadLudusavi();
|
||||||
|
|
||||||
|
if (process.platform !== "win32") {
|
||||||
|
const binariesPath = path.join(__dirname, "..", "binaries");
|
||||||
|
|
||||||
|
if (fs.existsSync(binariesPath)) {
|
||||||
|
const zzzPath = path.join(binariesPath, "7zz");
|
||||||
|
const zzzsPath = path.join(binariesPath, "7zzs");
|
||||||
|
if (fs.existsSync(zzzPath)) fs.chmodSync(zzzPath, 0o755);
|
||||||
|
if (fs.existsSync(zzzsPath)) fs.chmodSync(zzzsPath, 0o755);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ export class SevenZip {
|
|||||||
});
|
});
|
||||||
|
|
||||||
child.once("exit", (code) => {
|
child.once("exit", (code) => {
|
||||||
console.log("EXIT CALLED", code, filePath);
|
|
||||||
|
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
successCb();
|
successCb();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -16,12 +16,6 @@ export class Aria2 {
|
|||||||
"--rpc-listen-all",
|
"--rpc-listen-all",
|
||||||
"--file-allocation=none",
|
"--file-allocation=none",
|
||||||
"--allow-overwrite=true",
|
"--allow-overwrite=true",
|
||||||
"-s",
|
|
||||||
"16",
|
|
||||||
"-x",
|
|
||||||
"16",
|
|
||||||
"-k",
|
|
||||||
"1M",
|
|
||||||
],
|
],
|
||||||
{ stdio: "inherit", windowsHide: true }
|
{ stdio: "inherit", windowsHide: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ export class DownloadManager {
|
|||||||
game_id: downloadId,
|
game_id: downloadId,
|
||||||
url: downloadUrl,
|
url: downloadUrl,
|
||||||
save_path: download.downloadPath,
|
save_path: download.downloadPath,
|
||||||
|
allow_multiple_connections: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case Downloader.TorBox: {
|
case Downloader.TorBox: {
|
||||||
@@ -383,6 +384,7 @@ export class DownloadManager {
|
|||||||
url,
|
url,
|
||||||
save_path: download.downloadPath,
|
save_path: download.downloadPath,
|
||||||
out: name,
|
out: name,
|
||||||
|
allow_multiple_connections: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user