revanced-manager/lib/services/github_api.dart

30 lines
889 B
Dart
Raw Normal View History

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 {
2022-08-07 01:37:12 +02:00
var latestRelease = await github.repositories.getLatestRelease(
RepositorySlug(org, repoName),
);
2022-08-06 15:04:18 +02:00
var dlurl = latestRelease.assets
?.firstWhere((asset) =>
asset.name != null &&
2022-08-07 00:01:05 +02:00
(asset.name!.endsWith('.dex') || asset.name!.endsWith('.apk')) &&
2022-08-06 15:04:18 +02:00
!asset.name!.contains('-sources') &&
!asset.name!.contains('-javadoc'))
.browserDownloadUrl;
return dlurl;
}
Future<String> latestCommitTime(String org, repoName) async {
2022-08-07 01:37:12 +02:00
var repo = await github.repositories.getRepository(
RepositorySlug(org, repoName),
);
return format(repo.pushedAt!);
}
}