Merge pull request #122 from nfvs/add_file_options

Add ability to specify per-file options in Add by URI.
This commit is contained in:
hamza zia 2014-12-15 19:25:49 +08:00
commit 9bb72eac8d
2 changed files with 18 additions and 3 deletions

View File

@ -646,7 +646,9 @@
- You can also add multiple uris (mirrors) for the
*same* file. To do this separate the uris
by a space. <br>
- A URI can be HTTP(S)/FTP/BitTorrent Magnet URI.
- Additional options can be specified for individual
files, in "--option[=value]" format. <br>
- A URI can be HTTP(S)/FTP/BitTorrent Magnet URI. </br>
- Aria2 will use multiple uris (or mirrors) to boost
the download speed for that file (download). <br>
E.g. To add 2 files (downloads) f1.jpg
@ -656,7 +658,7 @@
<!-- pre tags print tabs, so do not indent them! -->
<pre>
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
</pre>
</p>
<textarea rows="4" style="width: 100%" ng-model="getUris.uris"></textarea>

View File

@ -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