RubyTorrent 问题
我正在尝试创建一个脚本来帮助我在 Windows 内部网络上移动大型文件,并希望 Ruby 与 BitTorrent 结合起来会是理想的选择。 然而,我的代码似乎并没有真正下载任何东西。
我知道 RubyTorrent 项目已经被废弃很长时间了,所以我希望我的一位 Stackoverflow 用户能够帮助我。
我的代码(到目前为止):
require 'rubytorrent'
bt = RubyTorrent::BitTorrent.new('http://www.mininova.org/get/2511754')
puts bt.tracker
puts bt.port
thread = Thread.new do
while true
puts bt.percent_completed
sleep 15
end
end
bt.on_event(self, :complete) { thread.kill }
thread.join
如您所见,“bt.tracker”行显示为零,因此传递 .torrent 文件可能会出现问题,但为什么它会传递文件的其余部分? ?
任何帮助使其发挥作用的帮助将不胜感激。
I am trying to create a script to help me move large files accross an internal Windows network, and was hoping that Ruby, in conjunction with BitTorrent would be ideal. However, my code doesnt seem to actually download anything.
I know the RubyTorrent project has been abandoned for a long time, so I was hoping one of my fellow Stackoverflow'ers could help me.
My code (so far is):
require 'rubytorrent'
bt = RubyTorrent::BitTorrent.new('http://www.mininova.org/get/2511754')
puts bt.tracker
puts bt.port
thread = Thread.new do
while true
puts bt.percent_completed
sleep 15
end
end
bt.on_event(self, :complete) { thread.kill }
thread.join
As you can see, the 'bt.tracker' line is coming up as nil, so it might be a problem passing the .torrent file, but then why does it pass the rest of the file ok?
Any help getting this to work would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的代码很好,唯一的问题是当您仍未连接到跟踪器时尝试打印 bt.tracker 。
如果连接后尝试打印,没有问题
Your code is good, the only problem is that you try to print bt.tracker when you're still not connected to the tracker.
If you try to print it after being connected there's no problem
我认为它需要一个文件名。 难道就像需要
require 'open-uri'
一样简单吗?I think it expects a filename. Could it be as simple as needing to
require 'open-uri'
?