Aria2 一键添加任务到下载列表~

· 杂货 · 2459字


Development environment

<script src=""></script>


Request URL:http://localhost:6800/jsonrpc
Request Parameters:

"params": [
    { "out":"小倩_2018-09-04_r6qECA3BVRh2Rl.flv" }

jsonnrpc":"2.0", is Fixed value;
"method":"aria2.addUri", is Fixed value;
"id":1536032059123, use Current Timestamp;
"params", the first array is Download URL, the second parameters 'out' is output file name, and then add header, cookie to "out" after if you need to use the information.

eg: BaiduNetdiskDownload_Export.

"header":["User-Agent: netdisk;;PC;PC-Windows;10.0.16299;WindowsBaiduYunGuanJia",

like this.

So, using jQuery's ajax to send this data, you can add it to the aria2 download list.


var downloadID = new Date().getTime();
var data = '{"jsonrpc":"2.0", "method":"aria2.addUri", "id":'+downloadID+', "params": [["'+downloadURL+'"], { "out":"'+outputFileName+'" }]}';
var self = this;
    url: 'http://localhost:6800/jsonrpc', 
    type: 'post', 
    dataType: 'json', 
    data: data,
    success: function (res) {
        if (res.error != null) {
            // send failed.
            console.log('the file adding failed to aria2 download list.');
        } else {
            // send success.
            console.log('the file added to aria2 download list.');

Warning: Safari can't load cross-domain requests, chrome is OK.


最后一次编辑于 2018 09 04 19:56:46