基本上我制作的程序可以通过使用许多API从电影中获取所有信息。它还从电影中下载.torrent文件。我想在我的程序中下载这个并希望使用tTorrent。唯一的问题是:我该如何使用它?在阅读所有安装或自述文件时,它并没有为我说任何事情。我理解如何安装普通库,但这在多个地图中有多个文件等。
所以,第一个问题:您能否轻松解释我如何逐步安装库?
第二个问题:你能否给我一些如何用.torrent文件下载的代码?
Btw:如果有任何方法可以自动打开带有qBittorrent的.torrent文件,那么这对我来说是唯一可以接受的选择。答案 0 :(得分:0)
1)安装maven,查看如何快速启动" Hello World"使用maven的项目。抓住它后,添加
<dependency>
<groupId>com.turn</groupId>
<artifactId>ttorrent</artifactId>
<version>1.4</version>
</dependency>
到你的pom.xml
2)从你链接的页面:
// First, instantiate the Client object.
Client client = new Client(
// This is the interface the client will listen on (you might need something
// else than localhost here).
InetAddress.getLocalHost(),
// Load the torrent from the torrent file and use the given
// output directory. Partials downloads are automatically recovered.
SharedTorrent.fromFile(
new File("/path/to/your.torrent"),
new File("/path/to/output/directory")));
// You can optionally set download/upload rate limits
// in kB/second. Setting a limit to 0.0 disables rate
// limits.
client.setMaxDownloadRate(50.0);
client.setMaxUploadRate(50.0);
// At this point, can you either call download() to download the torrent and
// stop immediately after...
client.download();
// Or call client.share(...) with a seed time in seconds:
// client.share(3600);
// Which would seed the torrent for an hour after the download is complete.
// Downloading and seeding is done in background threads.
// To wait for this process to finish, call:
client.waitForCompletion();
// At any time you can call client.stop() to interrupt the download.