有一个需求是通过点击web页面的按钮给本机的mortix添加任务,mortix提供RPC接口,可以直接调用http://localhost:16800/jsonrpc接口
使用post方法,内容为raw-json格式
{ "jsonrpc": "2.0", "id": "qwer", "method": "aria2.addUri", "params":[["magnet:?xt=urn:btih:"]] }
有一个需求是通过点击web页面的按钮给本机的mortix添加任务,mortix提供RPC接口,可以直接调用http://localhost:16800/jsonrpc接口
使用post方法,内容为raw-json格式
{ "jsonrpc": "2.0", "id": "qwer", "method": "aria2.addUri", "params":[["magnet:?xt=urn:btih:"]] }
Cloud Torrent除了支持web界面外,还有一些隐藏的api,可以通过post方式使用\
该方法可以直接向Cloud Torrent提交magnet链接,无需访问web界面
当然,如果跨域了,还需要用proxy解决跨域调用问题
$("button#send").click(function(){ var myUrl = 'https://Cloud-Torrent:3000/api/magnet'; var proxy = 'https://minir.plus/cors/?url='; var finalURL = proxy + myUrl; raw=$(this).attr("data"); $.ajax({ url:finalURL, type:"POST", data:raw, contentType:"Content-Type: text/plain", dataType:"json", success: function( data, status ) { console.log("Data: " + JSON.stringify(data) + "nStatus: " + status); }}); });
使用bash方式自动初始化root用户,其中涉及一个步骤是需要给root用户设置密码
可以使用以下方法,通过两次echo来提交两次密码
get_passwd=$( curl -s https://minir.plus/password ) ( echo $get_passwd; echo $get_passwd ) | sudo passwd root
magnet的链接格式在再次使用前需要对其中的内容进行识别和整理
使用regex提取各部分
preg_match_all('/^magnet:\?(xt=.*)(&dn=.*?)(&tr=.*)$/', $list->dl_url2, $matches_dl_url2);
使用blade给JS传值的时候,会自动转换链接里的特殊字符
var magnet = @foreach ($data as $list) @if ($loop->last) "{{ $list->dl_url2 }}\n" @else "{{ $list->dl_url2 }}\n" + @endif @endforeach;