mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-13 02:14:31 +01:00
feat: fully complete manager api.
This commit is contained in:
parent
729ad82f77
commit
5542e9b943
1 changed files with 46 additions and 34 deletions
|
@ -5,22 +5,25 @@ import 'package:revanced_manager_flutter/constants.dart';
|
||||||
import 'github_api.dart';
|
import 'github_api.dart';
|
||||||
|
|
||||||
// use path_provider to get the path of the storage directory
|
// use path_provider to get the path of the storage directory
|
||||||
Dio dio = Dio();
|
|
||||||
GithubAPI githubAPI = GithubAPI();
|
|
||||||
|
|
||||||
Future<String?> getPath() async {
|
class ManagerAPI {
|
||||||
|
Dio dio = Dio();
|
||||||
|
GithubAPI githubAPI = GithubAPI();
|
||||||
|
|
||||||
|
Future<String?> getPath() async {
|
||||||
final path = await p.getApplicationSupportDirectory();
|
final path = await p.getApplicationSupportDirectory();
|
||||||
final workDir = Directory('${path.path}/revanced').createSync();
|
final workDir = Directory('${path.path}/revanced').createSync();
|
||||||
final workDirPath = "${path.path}/revanced";
|
final workDirPath = "${path.path}/revanced";
|
||||||
return workDirPath;
|
return workDirPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<File?> downloadAssets(String repo) async {
|
Future<File?> downloadAssets(String repo) async {
|
||||||
try {
|
try {
|
||||||
final workDir = await getPath();
|
final workDir = await getPath();
|
||||||
final dlUrl = await githubAPI.latestRelease(ghOrg, repo);
|
final dlUrl = await githubAPI.latestRelease(ghOrg, repo);
|
||||||
final name =
|
final name = dlUrl
|
||||||
dlUrl?.split('/').lastWhere((element) => element.contains('revanced'));
|
?.split('/')
|
||||||
|
.lastWhere((element) => element.contains('revanced'));
|
||||||
print(name);
|
print(name);
|
||||||
final assetFile = File('$workDir/$name');
|
final assetFile = File('$workDir/$name');
|
||||||
final response = await dio.get(
|
final response = await dio.get(
|
||||||
|
@ -42,4 +45,13 @@ Future<File?> downloadAssets(String repo) async {
|
||||||
print(e);
|
print(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> downloadPatches() async {
|
||||||
|
await downloadAssets(patchesRepo);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> downloadIntegrations() async {
|
||||||
|
await downloadAssets(integrationsRepo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue