mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-10-22 18:33:45 +02:00
Cleanup (#98)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
|
||||
class FDroid implements AppSource {
|
||||
@@ -18,7 +19,7 @@ class FDroid implements AppSource {
|
||||
RegExp standardUrlRegExA = RegExp('^https?://$host/+packages/+[^/]+');
|
||||
match = standardUrlRegExA.firstMatch(url.toLowerCase());
|
||||
if (match == null) {
|
||||
throw notValidURL(runtimeType.toString());
|
||||
throw InvalidURLError(runtimeType.toString());
|
||||
}
|
||||
return url.substring(0, match.end);
|
||||
}
|
||||
@@ -36,7 +37,7 @@ class FDroid implements AppSource {
|
||||
if (res.statusCode == 200) {
|
||||
var releases = parse(res.body).querySelectorAll('.package-version');
|
||||
if (releases.isEmpty) {
|
||||
throw couldNotFindReleases;
|
||||
throw NoReleasesError();
|
||||
}
|
||||
String? latestVersion = releases[0]
|
||||
.querySelector('.package-version-header b')
|
||||
@@ -45,7 +46,7 @@ class FDroid implements AppSource {
|
||||
.sublist(1)
|
||||
.join(' ');
|
||||
if (latestVersion == null) {
|
||||
throw couldNotFindLatestVersion;
|
||||
throw NoVersionError();
|
||||
}
|
||||
List<String> apkUrls = releases
|
||||
.where((element) =>
|
||||
@@ -64,11 +65,11 @@ class FDroid implements AppSource {
|
||||
.where((element) => element.isNotEmpty)
|
||||
.toList();
|
||||
if (apkUrls.isEmpty) {
|
||||
throw noAPKFound;
|
||||
throw NoAPKError();
|
||||
}
|
||||
return APKDetails(latestVersion, apkUrls);
|
||||
} else {
|
||||
throw couldNotFindReleases;
|
||||
throw NoReleasesError();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user