[code]npm install parse-torrent[/code]
var fs = require("fs");
var parseTorrent = require('parse-torrent');
var info = parseTorrent(fs.readFileSync('my.torrent'));
console.log(info);
function cleanInfo (info) {
// 将种子名用 md5 加密
info.name = md5(info.name);
info['name.utf-8'] = md5(info['name.utf-8']);
var files = info.files;
for (var i = 0; i < files.length; i++) {
var file = files[i];
for (var key in file) {
if (key == "path" || key == "path.utf-8") {
for (var j = 0; j < file[key].length; j++) {
var text = file[key][j].toString();
var dotIndex = text.lastIndexOf(".");
// 将种子名用 md5 加密
file[key][j] = md5(text.slice(0,dotIndex)) + text.slice(dotIndex,text.length);
}
}
}
}
return info;
}
// 将清洗干净后的 info 对象重新生成一个 torrent 文件
var buf = parseTorrent.toTorrentFile({
info: cleanInfos[i]
});
fs.writeFile(dir + "/" + cleanInfos[i].name + ".torrent", buf);
[code]node cleanTorrent IPTD-XXX.torrent[/code]下载成功了! [img]http://files.jb51.net/file_images/article/201503/201503270851137.png[/img] 脚本源码放在这里了,要去看一下我的下载内容了!!! [img]http://files.jb51.net/file_images/article/201503/201503270851138.png[/img] [img]http://files.jb51.net/file_images/article/201503/201503270851149.jpg[/img] (**都脱了你给我看这个!!!) [b]最后 [/b] 本文纯属技术讨论,感谢你的阅读,有不足之处请为我指出。 请您花一点时间将文章分享给您的朋友或者留下评论。我们将会由衷感谢您的支持!
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有