Skip to content

Commit

Permalink
Merge pull request #20 from CCExtractor/develop
Browse files Browse the repository at this point in the history
Added ability to check torrent hash
  • Loading branch information
pratikbaid3 committed Aug 8, 2021
2 parents 780c911 + 9a61f94 commit 25c77c6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
30 changes: 30 additions & 0 deletions lib/Api/torrent_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,34 @@ class TorrentApi {
print(e.toString());
}
}

static Future<void> checkTorrentHash(
{List<String> hashes, BuildContext context}) async {
try {
String url = Provider.of<ApiProvider>(context, listen: false).baseUrl +
ApiProvider.checkHash;
print('---CHECK TORRENT HASH---');
print(url);
Response response;
Dio dio = new Dio();
//Headers
dio.options.headers['Accept'] = "application/json";
dio.options.headers['Content-Type'] = "application/json";
dio.options.headers['Connection'] = "keep-alive";
dio.options.headers['Cookie'] =
Provider.of<UserDetailProvider>(context, listen: false).token;
Map<String, dynamic> mp = Map();
mp['hashes'] = hashes;
String rawBody = json.encode(mp);
response = await dio.post(
url,
data: rawBody,
);
if (response.statusCode == 200) {
} else {}
} catch (e) {
print('--ERROR--');
print(e.toString());
}
}
}
18 changes: 4 additions & 14 deletions lib/Components/torrent_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,6 @@ class _TorrentTileState extends State<TorrentTile> {
menuItemExtent: 60,
onPressed: () {},
menuItems: [
FocusedMenuItem(
title: Text(
'Torrent Details',
style: TextStyle(
color: Colors.black,
),
),
trailingIcon: Icon(
Icons.info_outline,
color: Colors.black,
),
onPressed: () {},
),
FocusedMenuItem(
title: Text(
'Set Tags',
Expand All @@ -99,7 +86,10 @@ class _TorrentTileState extends State<TorrentTile> {
Icons.tag,
color: Colors.black,
),
onPressed: () {},
onPressed: () {
TorrentApi.checkTorrentHash(
hashes: [widget.model.hash], context: context);
},
),
FocusedMenuItem(
backgroundColor: Colors.redAccent,
Expand Down
1 change: 1 addition & 0 deletions lib/Provider/api_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ApiProvider extends ChangeNotifier {

//api/notifications?id=notification-tooltip&limit=10&start=0
static String notifications = '/api/notifications';
static String checkHash = '/api/torrents/check-hash';

Future<void> setBaseUrl(String url) async {
baseUrl = url;
Expand Down

0 comments on commit 25c77c6

Please sign in to comment.