Top Menu

使用Mortix的RPC接口添加任务

有一个需求是通过点击web页面的按钮给本机的mortix添加任务,mortix提供RPC接口,可以直接调用http://localhost:16800/jsonrpc接口

使用post方法,内容为raw-json格式

{ "jsonrpc": "2.0", "id": "qwer", "method": "aria2.addUri", "params":[["magnet:?xt=urn:btih:"]] }

Continue Reading 0

使用api向Cloud Torrent添加任务

Cloud Torrent除了支持web界面外,还有一些隐藏的api,可以通过post方式使用\

  • api address: /api/magnet
  • method: post
  • data:(raw) magnet URI

该方法可以直接向Cloud Torrent提交magnet链接,无需访问web界面

当然,如果跨域了,还需要用proxy解决跨域调用问题

jQuery实现

$("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); }}); });

Continue Reading 0

使用bash初始化root用户

使用bash方式自动初始化root用户,其中涉及一个步骤是需要给root用户设置密码

可以使用以下方法,通过两次echo来提交两次密码

get_passwd=$( curl -s https://minir.plus/password ) ( echo $get_passwd; echo $get_passwd ) | sudo passwd root

Continue Reading 0

清理magnet链接

magnet的链接格式在再次使用前需要对其中的内容进行识别和整理

  • magnet:?
    • scheme
    &xt=urn:btih:
    • file hash
    &dn=
    • Display Name
    &tr=
    • Tracker URL

    使用regex提取各部分

    preg_match_all('/^magnet:\?(xt=.*)(&dn=.*?)(&tr=.*)$/', $list->dl_url2, $matches_dl_url2);

Continue Reading 0

Powered by WordPress. Designed by WooThemes