4

I want to develop a flutter app to search and download files from torrent. The searching part is done but now I'm out of any idea how to implement the download functionality.

I want to download the actual file that the torrent file or the magnet link directing to. For example I want the app to download Linux distro from given torrent file or from given magnet link.

Is there any plugin for this or I need to build it myself? If I need to create one, then how?

T Hansda
  • 111
  • 1
  • 9
  • Isn't that equivalent to downloading a file? – 10101010 Jul 14 '19 at 10:35
  • No, that's not. Torrent has its own protocol to handle multiple peers and to collect the pieces from all the peers. – T Hansda Jul 14 '19 at 11:09
  • I think your question is how to download a torrent file. Do you mean to ask something different? – 10101010 Jul 14 '19 at 11:40
  • I apologise, my question is not that clear. I don't want to download the .torrent file. I want to download the actual file that the magnet link or the .torrent file is directing to. For example download the Linux distro from its .torrent file or from the magnet link. – T Hansda Jul 14 '19 at 11:52
  • 2
    You would need a bitorrent client to download the actual files. I am not aware of a bittorrent plugin for flutter. https://github.com/mpetazzoni/ttorrent is one written in java. "How to do it" is a broad question. You would need to implement the bittorrent protocol. The spec for which is available at https://www.bittorrent.org/beps/bep_0003.html. – 10101010 Jul 14 '19 at 12:12
  • I have searched the GitHub before, there are few libraries written in Java, but I'm struggling to implement then into flutter. Thank you for the spec link, it should be helpful if I have to create plugin myself. – T Hansda Jul 14 '19 at 12:27
  • 1
    You could send that torrent file to a server, do stuff there and send the content to the app. There are a lot of server side clients. – 10101010 Jul 18 '19 at 11:04

2 Answers2

5

I developed Torrento package for dealing with torrents.

It has support for many torrent clients and lets you control them remotely.

Here's what you can try to download torrents:

  • Install your torrent client software
  • Setup username and password for Web Ui in the preferences.

Then you can download or add torrents etc , by including the above package in your flutter's pubspec.yaml file.

Here's a small exampel :

import 'package:torrento/torrento.dart';

QbitTorrentController obj = QbitTorrentController('192.168.0.101' , 8080) ; 
await obj.logIn('username' , 'password') ; 

await obj.addTorrent('magnet:?xt=urn:btih:0d18397945bcc9f495818aa2c823ab167dc8da5c&dn=The.Lion.King.2019.1080p.BluRay.H264.AAC-RARBG') ; 

var torrents = await obj.getTorrentsList(filter: TorrentFilter.paused) ; 

torrents.forEach((t)=>print('${t['name']} : ${t['hash']}')) ; 

print("Starting all torrents") ;
await obj.startAllTorrents() ; 

print(await obj.getVersion()) ; 

await obj.logOut() ; 
Natesh bhat
  • 12,274
  • 10
  • 84
  • 125
1

The torrent_task plugin is a pure dart implementation of the BitTorrent protocol.

Ben Hagen
  • 595
  • 6
  • 15