Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
✨ Add Torrent Download
Browse files Browse the repository at this point in the history
  • Loading branch information
uiYzzi committed Feb 18, 2024
1 parent 5bec2be commit 73a9160
Show file tree
Hide file tree
Showing 13 changed files with 262 additions and 138 deletions.
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class MessageLookup extends MessageLookupByLibrary {
"downloadPathInfo":
MessageLookupByLibrary.simpleMessage("Set default download path"),
"downloading": MessageLookupByLibrary.simpleMessage("Downloading"),
"dropTorrent": MessageLookupByLibrary.simpleMessage(
"Drag the torrent file here or click here to open it"),
"exitApp": MessageLookupByLibrary.simpleMessage("Exit App"),
"general": MessageLookupByLibrary.simpleMessage("General"),
"language": MessageLookupByLibrary.simpleMessage("Language"),
Expand Down
1 change: 1 addition & 0 deletions lib/generated/intl/messages_zh_CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class MessageLookup extends MessageLookupByLibrary {
"downloadPath": MessageLookupByLibrary.simpleMessage("下载路径"),
"downloadPathInfo": MessageLookupByLibrary.simpleMessage("设置默认下载路径"),
"downloading": MessageLookupByLibrary.simpleMessage("下载中"),
"dropTorrent": MessageLookupByLibrary.simpleMessage("拖动种子文件到此处或点击打开"),
"exitApp": MessageLookupByLibrary.simpleMessage("退出程序"),
"general": MessageLookupByLibrary.simpleMessage("常规"),
"language": MessageLookupByLibrary.simpleMessage("语言"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@
"showWindow":"Show Window",
"exitApp":"Exit App",
"openDirectory":"Open Directory",
"openFile":"Open File"
"openFile":"Open File",
"dropTorrent":"Drag the torrent file here or click here to open it"
}
3 changes: 2 additions & 1 deletion lib/l10n/intl_zh_CN.arb
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@
"showWindow":"显示窗口",
"exitApp":"退出程序",
"openDirectory":"打开目录",
"openFile":"打开文件"
"openFile":"打开文件",
"dropTorrent":"拖动种子文件到此处或点击打开"
}
19 changes: 19 additions & 0 deletions lib/utils/ariar2_http_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ addUrl(params, aria2url) async {
}
}

addTorrent(params, aria2url) async {
try {
var rpcSecret = Global.rpcSecret;
var res = await http.post(Uri.parse(aria2url),
body: json.encode({
"jsonrpc": "2.0",
"method": "aria2.addTorrent",
"id": uuid.v4(),
"params": ['token:$rpcSecret', ...params]
}));
if (res.statusCode == 200) {
var resJson = json.decode(res.body);
return resJson['result'];
}
} catch (e) {
Log.e(e);
}
}

tellStopped(String aria2url) async {
try {
var rpcSecret = Global.rpcSecret;
Expand Down
Loading

0 comments on commit 73a9160

Please sign in to comment.