1
0
mirror of https://github.com/snobu/destreamer.git synced 2026-04-24 04:27:14 +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.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')); 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.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.changeOption', params: [string, object], id?: string): string;
private createMessage(method: 'aria2.changeGlobalOption', params: [{ [option: string]: string }], 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; private createMessage(method: 'system.multicall', params: [Array<object>], id?: string): string;
@@ -236,21 +242,19 @@ export class DownloadManager {
// handle download errors // handle download errors
else if (parsed.method === 'aria2.onDownloadError') { else if (parsed.method === 'aria2.onDownloadError') {
// NOTE: to test error just pull the cord mid dowload, logger.error('Error while downloading, retrying...');
// then reconnect, wait 30 sec and voilà
logger.error(JSON.stringify(parsed));
const errorGid: string = parsed.params.pop().gid.toString(); const errorGid: string = parsed.params.pop().gid.toString();
this.queue.delete(errorGid); this.queue.delete(errorGid);
// FIXME: this does not work // 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')); this.webSocket.send(this.createMessage('aria2.tellStatus', [errorGid, ['files']], 'getUrlForRetry'));
} }
// TODO: handle download retries
else if (parsed.id === 'getUrlForRetry') { else if (parsed.id === 'getUrlForRetry') {
logger.error('RECIVED URL TO RETRY, NOT IMPLEMENTED YET'); const retryUrl = parsed.result.files[0].uris[0].uri;
logger.error(JSON.stringify(parsed, null, 4)); 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 // handle url added to download list in aria

View File

@@ -164,7 +164,7 @@ async function downloadVideo(videoGUIDs: Array<string>,
// Launch aria2c // Launch aria2c
aria2cExec = spawn( aria2cExec = spawn(
'aria2c', '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'} {stdio: 'ignore'}
); );
@@ -184,7 +184,7 @@ async function downloadVideo(videoGUIDs: Array<string>,
}); });
// init webSocket // init webSocket
await downloadManager.init(port); await downloadManager.init(port, );
// We are connected // We are connected
}, },
error => { error => {