addTorrent method
Add torrent to transmission
filename
optional filename or URL of the .torrent file
metaInfo
optional base64-encoded .torrent content
downloadDir
optional directory where to download the torrent
cookies
optional pointer to a string of one or more cookies
paused
optional boolean to paused the torrent when added
Returns TorrentLight
light torrent info if added successfully
Throws AddTorrentException if errors
Implementation
Future<TorrentLight> addTorrent({
String? filename,
String? metaInfo,
String? downloadDir,
String? cookies,
bool? paused,
}) async {
final results = await _dio.post('/',
data: _Request(methodAddTorrent, arguments: {
if (filename != null) 'filename': filename,
if (metaInfo != null) 'metainfo': metaInfo,
if (downloadDir != null) 'download-dir': downloadDir,
if (cookies != null) 'cookies': cookies,
if (paused != null) 'paused': paused,
}).toJSON());
final response = _Response.fromJSON(results.data);
if (response.isSuccess) {
if (response.arguments!['torrent-duplicate'] != null) {
throw AddTorrentException._(
response.copyWith(result: 'Torrent duplicated'),
TorrentLight._(response.arguments!['torrent-duplicate']));
} else {
return TorrentLight._(response.arguments!['torrent-added']);
}
} else {
throw AddTorrentException._(
response, TorrentLight._(response.arguments!['torrent-duplicate']));
}
}