Transmission WebUI 批量添加磁链
抓到一堆磁链,手动加入下载很麻烦… 于是做了个简单的脚本。
(() => {
async function request (object) {
return new Promise((resolve, reject) => {
transmission.remote.sendRequest(object, resolve);
});
}
async function addMagnets(urls) {
for(let i = 0; i < urls.length; i++) {
const url = urls[i];
console.info('add %d/%d: %O', i + 1, urls.length, await request({
method: 'torrent-add',
arguments: {
'paused': false,
'download-dir': $("#download-dir").val(),
'filename': url
}
}));
}
}
addMagnets(`
此处填入地址,一行一个 (填入时删除此行)
`.split('\n').map(n => n.trim()).filter(n => n));
})()