https://github.com/webtorrent/create-torrent
https://github.com/webtorrent/parse-torrent
create-torrent可以用于创建torrent文件
parse-torrent可以用于解析torrent文件
const createTorrent = require('create-torrent')
const fs = require('fs')
createTorrent('/path/folder', (err, torrent) => {
if (!err) {
// `torrent` is a Buffer with the contents of the new .torrent file
fs.writeFile('my.torrent', torrent , function(){ })
}else{
console.log(err)
}
})
创建torrent时,可以指定以下选项: