mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 09:07:47 +01:00
51 lines
1.4 KiB
Dart
51 lines
1.4 KiB
Dart
import 'package:github/github.dart';
|
|
import 'package:injectable/injectable.dart';
|
|
import 'package:timeago/timeago.dart';
|
|
|
|
@lazySingleton
|
|
class GithubAPI {
|
|
var github = GitHub();
|
|
|
|
Future<String?> latestRelease(String org, repoName) async {
|
|
String? dlurl = '';
|
|
try {
|
|
var latestRelease = await github.repositories.getLatestRelease(
|
|
RepositorySlug(org, repoName),
|
|
);
|
|
dlurl = latestRelease.assets
|
|
?.firstWhere((asset) =>
|
|
asset.name != null &&
|
|
(asset.name!.endsWith('.dex') || asset.name!.endsWith('.apk')) &&
|
|
!asset.name!.contains('-sources') &&
|
|
!asset.name!.contains('-javadoc'))
|
|
.browserDownloadUrl;
|
|
} on Exception {
|
|
dlurl = '';
|
|
}
|
|
return dlurl;
|
|
}
|
|
|
|
Future<String> latestCommitTime(String org, repoName) async {
|
|
String pushedAt = '';
|
|
try {
|
|
var repo = await github.repositories.getRepository(
|
|
RepositorySlug(org, repoName),
|
|
);
|
|
pushedAt = repo.pushedAt != null ? format(repo.pushedAt!) : '';
|
|
} on Exception {
|
|
pushedAt = '';
|
|
}
|
|
return pushedAt;
|
|
}
|
|
|
|
Future<List<Contributor>> getContributors(String org, repoName) async {
|
|
try {
|
|
var contributors = github.repositories.listContributors(
|
|
RepositorySlug(org, repoName),
|
|
);
|
|
return contributors.toList();
|
|
} on Exception {
|
|
return List.empty();
|
|
}
|
|
}
|
|
}
|