mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-22 05:59:30 +02:00
Better IzzyOnDroid support (#926)
This commit is contained in:
@@ -57,8 +57,63 @@ class FDroid extends AppSource {
|
|||||||
return Uri.parse(standardUrl).pathSegments.last;
|
return Uri.parse(standardUrl).pathSegments.last;
|
||||||
}
|
}
|
||||||
|
|
||||||
APKDetails getAPKUrlsFromFDroidPackagesAPIResponse(
|
@override
|
||||||
Response res, String apkUrlPrefix, String standardUrl,
|
Future<APKDetails> getLatestAPKDetails(
|
||||||
|
String standardUrl,
|
||||||
|
Map<String, dynamic> additionalSettings,
|
||||||
|
) async {
|
||||||
|
String? appId = await tryInferringAppId(standardUrl);
|
||||||
|
String host = Uri.parse(standardUrl).host;
|
||||||
|
return getAPKUrlsFromFDroidPackagesAPIResponse(
|
||||||
|
await sourceRequest('https://$host/api/v1/packages/$appId'),
|
||||||
|
'https://$host/repo/$appId',
|
||||||
|
standardUrl,
|
||||||
|
name,
|
||||||
|
autoSelectHighestVersionCode:
|
||||||
|
additionalSettings['autoSelectHighestVersionCode'] == true,
|
||||||
|
trySelectingSuggestedVersionCode:
|
||||||
|
additionalSettings['trySelectingSuggestedVersionCode'] == true,
|
||||||
|
filterVersionsByRegEx:
|
||||||
|
(additionalSettings['filterVersionsByRegEx'] as String?)
|
||||||
|
?.isNotEmpty ==
|
||||||
|
true
|
||||||
|
? additionalSettings['filterVersionsByRegEx']
|
||||||
|
: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Map<String, List<String>>> search(String query,
|
||||||
|
{Map<String, dynamic> querySettings = const {}}) async {
|
||||||
|
Response res = await sourceRequest(
|
||||||
|
'https://search.$host/?q=${Uri.encodeQueryComponent(query)}');
|
||||||
|
if (res.statusCode == 200) {
|
||||||
|
Map<String, List<String>> urlsWithDescriptions = {};
|
||||||
|
parse(res.body).querySelectorAll('.package-header').forEach((e) {
|
||||||
|
String? url = e.attributes['href'];
|
||||||
|
if (url != null) {
|
||||||
|
try {
|
||||||
|
standardizeUrl(url);
|
||||||
|
} catch (e) {
|
||||||
|
url = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (url != null) {
|
||||||
|
urlsWithDescriptions[url] = [
|
||||||
|
e.querySelector('.package-name')?.text.trim() ?? '',
|
||||||
|
e.querySelector('.package-summary')?.text.trim() ??
|
||||||
|
tr('noDescription')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return urlsWithDescriptions;
|
||||||
|
} else {
|
||||||
|
throw getObtainiumHttpError(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
APKDetails getAPKUrlsFromFDroidPackagesAPIResponse(
|
||||||
|
Response res, String apkUrlPrefix, String standardUrl, String sourceName,
|
||||||
{bool autoSelectHighestVersionCode = false,
|
{bool autoSelectHighestVersionCode = false,
|
||||||
bool trySelectingSuggestedVersionCode = false,
|
bool trySelectingSuggestedVersionCode = false,
|
||||||
String? filterVersionsByRegEx}) {
|
String? filterVersionsByRegEx}) {
|
||||||
@@ -126,62 +181,8 @@ class FDroid extends AppSource {
|
|||||||
.map((e) => '${apkUrlPrefix}_${e['versionCode']}.apk')
|
.map((e) => '${apkUrlPrefix}_${e['versionCode']}.apk')
|
||||||
.toList();
|
.toList();
|
||||||
return APKDetails(version, getApkUrlsFromUrls(apkUrls),
|
return APKDetails(version, getApkUrlsFromUrls(apkUrls),
|
||||||
AppNames(name, Uri.parse(standardUrl).pathSegments.last));
|
AppNames(sourceName, Uri.parse(standardUrl).pathSegments.last));
|
||||||
} else {
|
} else {
|
||||||
throw getObtainiumHttpError(res);
|
throw getObtainiumHttpError(res);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<APKDetails> getLatestAPKDetails(
|
|
||||||
String standardUrl,
|
|
||||||
Map<String, dynamic> additionalSettings,
|
|
||||||
) async {
|
|
||||||
String? appId = await tryInferringAppId(standardUrl);
|
|
||||||
String host = Uri.parse(standardUrl).host;
|
|
||||||
return getAPKUrlsFromFDroidPackagesAPIResponse(
|
|
||||||
await sourceRequest('https://$host/api/v1/packages/$appId'),
|
|
||||||
'https://$host/repo/$appId',
|
|
||||||
standardUrl,
|
|
||||||
autoSelectHighestVersionCode:
|
|
||||||
additionalSettings['autoSelectHighestVersionCode'] == true,
|
|
||||||
trySelectingSuggestedVersionCode:
|
|
||||||
additionalSettings['trySelectingSuggestedVersionCode'] == true,
|
|
||||||
filterVersionsByRegEx:
|
|
||||||
(additionalSettings['filterVersionsByRegEx'] as String?)
|
|
||||||
?.isNotEmpty ==
|
|
||||||
true
|
|
||||||
? additionalSettings['filterVersionsByRegEx']
|
|
||||||
: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Map<String, List<String>>> search(String query,
|
|
||||||
{Map<String, dynamic> querySettings = const {}}) async {
|
|
||||||
Response res = await sourceRequest(
|
|
||||||
'https://search.$host/?q=${Uri.encodeQueryComponent(query)}');
|
|
||||||
if (res.statusCode == 200) {
|
|
||||||
Map<String, List<String>> urlsWithDescriptions = {};
|
|
||||||
parse(res.body).querySelectorAll('.package-header').forEach((e) {
|
|
||||||
String? url = e.attributes['href'];
|
|
||||||
if (url != null) {
|
|
||||||
try {
|
|
||||||
standardizeUrl(url);
|
|
||||||
} catch (e) {
|
|
||||||
url = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (url != null) {
|
|
||||||
urlsWithDescriptions[url] = [
|
|
||||||
e.querySelector('.package-name')?.text.trim() ?? '',
|
|
||||||
e.querySelector('.package-summary')?.text.trim() ??
|
|
||||||
tr('noDescription')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return urlsWithDescriptions;
|
|
||||||
} else {
|
|
||||||
throw getObtainiumHttpError(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -6,16 +6,22 @@ class IzzyOnDroid extends AppSource {
|
|||||||
late FDroid fd;
|
late FDroid fd;
|
||||||
|
|
||||||
IzzyOnDroid() {
|
IzzyOnDroid() {
|
||||||
host = 'android.izzysoft.de';
|
host = 'izzysoft.de';
|
||||||
fd = FDroid();
|
fd = FDroid();
|
||||||
additionalSourceAppSpecificSettingFormItems =
|
additionalSourceAppSpecificSettingFormItems =
|
||||||
fd.additionalSourceAppSpecificSettingFormItems;
|
fd.additionalSourceAppSpecificSettingFormItems;
|
||||||
|
allowSubDomains = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url) {
|
||||||
RegExp standardUrlRegEx = RegExp('^https?://$host/repo/apk/[^/]+');
|
RegExp standardUrlRegExA = RegExp('^https?://android.$host/repo/apk/[^/]+');
|
||||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
|
RegExpMatch? match = standardUrlRegExA.firstMatch(url.toLowerCase());
|
||||||
|
if (match == null) {
|
||||||
|
RegExp standardUrlRegExB =
|
||||||
|
RegExp('^https?://apt.$host/fdroid/index/apk/[^/]+');
|
||||||
|
match = standardUrlRegExB.firstMatch(url.toLowerCase());
|
||||||
|
}
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
throw InvalidURLError(name);
|
throw InvalidURLError(name);
|
||||||
}
|
}
|
||||||
@@ -34,11 +40,12 @@ class IzzyOnDroid extends AppSource {
|
|||||||
Map<String, dynamic> additionalSettings,
|
Map<String, dynamic> additionalSettings,
|
||||||
) async {
|
) async {
|
||||||
String? appId = await tryInferringAppId(standardUrl);
|
String? appId = await tryInferringAppId(standardUrl);
|
||||||
return fd.getAPKUrlsFromFDroidPackagesAPIResponse(
|
return getAPKUrlsFromFDroidPackagesAPIResponse(
|
||||||
await sourceRequest(
|
await sourceRequest(
|
||||||
'https://apt.izzysoft.de/fdroid/api/v1/packages/$appId'),
|
'https://apt.izzysoft.de/fdroid/api/v1/packages/$appId'),
|
||||||
'https://android.izzysoft.de/frepo/$appId',
|
'https://android.izzysoft.de/frepo/$appId',
|
||||||
standardUrl,
|
standardUrl,
|
||||||
|
name,
|
||||||
autoSelectHighestVersionCode:
|
autoSelectHighestVersionCode:
|
||||||
additionalSettings['autoSelectHighestVersionCode'] == true,
|
additionalSettings['autoSelectHighestVersionCode'] == true,
|
||||||
trySelectingSuggestedVersionCode:
|
trySelectingSuggestedVersionCode:
|
||||||
|
Reference in New Issue
Block a user