1
0
mirror of https://github.com/snobu/destreamer.git synced 2026-05-20 00:23:32 +00:00

new version of error retry, couldn't test it

This commit is contained in:
Luca Armaroli
2020-12-03 18:34:11 +01:00
parent ddafc5091d
commit 08364ed635
2 changed files with 23 additions and 19 deletions

View File

@@ -107,6 +107,12 @@ export class DownloadManager {
this.setOptions(options);
}
this.webSocket.send(JSON.stringify({
jsonrpc: '2.0',
id: 'Destreamer',
method: 'aria2.getGlobalOption'
}));
logger.debug('[DownloadMangaer] Setup listener count on "message": ' + this.webSocket.listenerCount('message'));
}
@@ -153,7 +159,7 @@ export class DownloadManager {
}
private createMessage(method: 'aria2.addUri', params: [[string]] | [[string], object], id?: string): string;
private createMessage(method: 'aria2.tellStatus', params: [[string]] | [[string], object], id?: string): string;
private createMessage(method: 'aria2.tellStatus', params: [[string]] | [string, object], id?: string): string;
private createMessage(method: 'aria2.changeOption', params: [string, object], id?: string): string;
private createMessage(method: 'aria2.changeGlobalOption', params: [{ [option: string]: string }], id?: string): string;
private createMessage(method: 'system.multicall', params: [Array<object>], id?: string): string;
@@ -236,21 +242,19 @@ export class DownloadManager {
// handle download errors
else if (parsed.method === 'aria2.onDownloadError') {
// NOTE: to test error just pull the cord mid dowload,
// then reconnect, wait 30 sec and voilà
logger.error(JSON.stringify(parsed));
logger.error('Error while downloading, retrying...');
const errorGid: string = parsed.params.pop().gid.toString();
this.queue.delete(errorGid);
// FIXME: this does not work
this.webSocket.send(this.createMessage('aria2.tellStatus', [[errorGid], ['files']], 'getUrlForRetry'));
// FIXME: I don't know if it's fixed, I was not able to reproduce a fail reliably
this.webSocket.send(this.createMessage('aria2.tellStatus', [errorGid, ['files']], 'getUrlForRetry'));
}
// TODO: handle download retries
else if (parsed.id === 'getUrlForRetry') {
logger.error('RECIVED URL TO RETRY, NOT IMPLEMENTED YET');
logger.error(JSON.stringify(parsed, null, 4));
const retryUrl = parsed.result.files[0].uris[0].uri;
const retryTitle = parsed.result.files[0].path;
this.webSocket.send(this.createMessage('aria2.addUri', [[retryUrl], { out: retryTitle }], 'addUrl'));
}
// handle url added to download list in aria

View File

@@ -164,7 +164,7 @@ async function downloadVideo(videoGUIDs: Array<string>,
// Launch aria2c
aria2cExec = spawn(
'aria2c',
['--enable-rpc', '--pause=true', `--rpc-listen-port=${port}`],
['--pause=true', '--enable-rpc', '--allow-overwrite=true', '--auto-file-renaming=false', `--rpc-listen-port=${port}`],
{stdio: 'ignore'}
);
@@ -184,7 +184,7 @@ async function downloadVideo(videoGUIDs: Array<string>,
});
// init webSocket
await downloadManager.init(port);
await downloadManager.init(port, );
// We are connected
},
error => {