From fb82efc14be5ceb8c87b83057321fc3f1a1084e1 Mon Sep 17 00:00:00 2001 From: Nuno Santos Date: Mon, 15 Dec 2014 11:30:39 +0100 Subject: [PATCH] Add ability to specify per-file options in Add by URI. --- index.html | 6 ++++-- js/services/rpc/helpers.js | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 272bf5f..5b73fc5 100755 --- a/index.html +++ b/index.html @@ -646,7 +646,9 @@ - You can also add multiple uris (mirrors) for the *same* file. To do this separate the uris by a space.
- - A URI can be HTTP(S)/FTP/BitTorrent Magnet URI. + - Additional options can be specified for individual + files, in "--option[=value]" format.
+ - A URI can be HTTP(S)/FTP/BitTorrent Magnet URI.
- Aria2 will use multiple uris (or mirrors) to boost the download speed for that file (download).
E.g. To add 2 files (downloads) f1.jpg @@ -656,7 +658,7 @@
 http://ex1.com/f1.jpg http://ex2.com/f1.jpg
-http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
+http://ex1.com/f2.mp4 http://ex2.com/f2.mp4 --out=file2.mp4
 

diff --git a/js/services/rpc/helpers.js b/js/services/rpc/helpers.js index ec3ce13..b983672 100644 --- a/js/services/rpc/helpers.js +++ b/js/services/rpc/helpers.js @@ -13,8 +13,21 @@ angular.module('webui.services.rpc.helpers', [ }, addUris: function(uris, settings, cb) { _.each(uris, function(uri) { + uri_parsed = []; + // parse options passed in the URIs. E.g. http://ex1.com/f1.jpg --out=image.jpg --check-integrity + _.each(uri, function(uri_element) { + if (uri_element.startsWith('--')) { + uri_options = uri_element.split(/--|=(.*)/); + if (uri_options.length > 2) { + settings[uri_options[2]] = uri_options[3] || 'true'; + } + } + else { + uri_parsed.push(uri_element); + } + }); // passing true to batch all the addUri calls - rpc.once('addUri', [uri, settings], cb, true); + rpc.once('addUri', [uri_parsed, settings], cb, true); }); // now dispatch all addUri syscalls