mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-22 17:19:42 +02:00
Fixed F-Droid repo search (#1400) + general search bugfixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:html/parser.dart';
|
import 'package:html/parser.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
import 'package:obtainium/components/generated_form.dart';
|
import 'package:obtainium/components/generated_form.dart';
|
||||||
import 'package:obtainium/custom_errors.dart';
|
import 'package:obtainium/custom_errors.dart';
|
||||||
import 'package:obtainium/providers/source_provider.dart';
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
@@ -45,7 +46,7 @@ class FDroidRepo extends AppSource {
|
|||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url) {
|
||||||
var standardUri = Uri.parse(url);
|
var standardUri = Uri.parse(url);
|
||||||
var pathSegments = standardUri.pathSegments;
|
var pathSegments = standardUri.pathSegments;
|
||||||
if (pathSegments.last == 'index.xml') {
|
if (pathSegments.isNotEmpty && pathSegments.last == 'index.xml') {
|
||||||
pathSegments.removeLast();
|
pathSegments.removeLast();
|
||||||
standardUri = standardUri.replace(path: pathSegments.join('/'));
|
standardUri = standardUri.replace(path: pathSegments.join('/'));
|
||||||
}
|
}
|
||||||
@@ -60,7 +61,7 @@ class FDroidRepo extends AppSource {
|
|||||||
throw NoReleasesError();
|
throw NoReleasesError();
|
||||||
}
|
}
|
||||||
url = removeQueryParamsFromUrl(standardizeUrl(url));
|
url = removeQueryParamsFromUrl(standardizeUrl(url));
|
||||||
var res = await sourceRequest('$url/index.xml', {});
|
var res = await sourceRequestWithURLVariants(url, {});
|
||||||
if (res.statusCode == 200) {
|
if (res.statusCode == 200) {
|
||||||
var body = parse(res.body);
|
var body = parse(res.body);
|
||||||
Map<String, List<String>> results = {};
|
Map<String, List<String>> results = {};
|
||||||
@@ -72,7 +73,11 @@ class FDroidRepo extends AppSource {
|
|||||||
appId.contains(query) ||
|
appId.contains(query) ||
|
||||||
appName.contains(query) ||
|
appName.contains(query) ||
|
||||||
appDesc.contains(query)) {
|
appDesc.contains(query)) {
|
||||||
results['$url?appId=$appId'] = [appName, appDesc];
|
results[
|
||||||
|
'${res.request!.url.toString().split('/').reversed.toList().sublist(1).reversed.join('/')}?appId=$appId'] = [
|
||||||
|
appName,
|
||||||
|
appDesc
|
||||||
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
@@ -102,6 +107,26 @@ class FDroidRepo extends AppSource {
|
|||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Response> sourceRequestWithURLVariants(
|
||||||
|
String url,
|
||||||
|
Map<String, dynamic> additionalSettings,
|
||||||
|
) async {
|
||||||
|
var res = await sourceRequest(
|
||||||
|
'$url${url.endsWith('/index.xml') ? '' : '/index.xml'}',
|
||||||
|
additionalSettings);
|
||||||
|
if (res.statusCode != 200) {
|
||||||
|
var base = url.endsWith('/index.xml')
|
||||||
|
? url.split('/').reversed.toList().sublist(1).reversed.join('/')
|
||||||
|
: url;
|
||||||
|
res = await sourceRequest('$base/repo/index.xml', additionalSettings);
|
||||||
|
if (res.statusCode != 200) {
|
||||||
|
res = await sourceRequest(
|
||||||
|
'$base/fdroid/repo/index.xml', additionalSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<APKDetails> getLatestAPKDetails(
|
Future<APKDetails> getLatestAPKDetails(
|
||||||
String standardUrl,
|
String standardUrl,
|
||||||
@@ -117,25 +142,8 @@ class FDroidRepo extends AppSource {
|
|||||||
if (appIdOrName == null) {
|
if (appIdOrName == null) {
|
||||||
throw NoReleasesError();
|
throw NoReleasesError();
|
||||||
}
|
}
|
||||||
var res = await sourceRequest(
|
var res =
|
||||||
'$standardUrl${standardUrl.endsWith('/index.xml') ? '' : '/index.xml'}',
|
await sourceRequestWithURLVariants(standardUrl, additionalSettings);
|
||||||
additionalSettings);
|
|
||||||
if (res.statusCode != 200) {
|
|
||||||
var base = standardUrl.endsWith('/index.xml')
|
|
||||||
? standardUrl
|
|
||||||
.split('/')
|
|
||||||
.reversed
|
|
||||||
.toList()
|
|
||||||
.sublist(1)
|
|
||||||
.reversed
|
|
||||||
.join('/')
|
|
||||||
: standardUrl;
|
|
||||||
res = await sourceRequest('$base/repo/index.xml', additionalSettings);
|
|
||||||
if (res.statusCode != 200) {
|
|
||||||
res = await sourceRequest(
|
|
||||||
'$base/fdroid/repo/index.xml', additionalSettings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res.statusCode == 200) {
|
if (res.statusCode == 200) {
|
||||||
var body = parse(res.body);
|
var body = parse(res.body);
|
||||||
var foundApps = body.querySelectorAll('application').where((element) {
|
var foundApps = body.querySelectorAll('application').where((element) {
|
||||||
|
@@ -163,7 +163,7 @@ class AddAppPageState extends State<AddAppPage> {
|
|||||||
app = await sourceProvider.getApp(
|
app = await sourceProvider.getApp(
|
||||||
pickedSource!, userInput.trim(), additionalSettings,
|
pickedSource!, userInput.trim(), additionalSettings,
|
||||||
trackOnlyOverride: trackOnly,
|
trackOnlyOverride: trackOnly,
|
||||||
overrideSource: pickedSourceOverride,
|
sourceIsOverriden: pickedSourceOverride != null,
|
||||||
inferAppIdIfOptional: inferAppIdIfOptional);
|
inferAppIdIfOptional: inferAppIdIfOptional);
|
||||||
// Only download the APK here if you need to for the package ID
|
// Only download the APK here if you need to for the package ID
|
||||||
if (isTempId(app) && app.additionalSettings['trackOnly'] != true) {
|
if (isTempId(app) && app.additionalSettings['trackOnly'] != true) {
|
||||||
|
@@ -213,7 +213,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
importInProgress = true;
|
importInProgress = true;
|
||||||
});
|
});
|
||||||
if (values['url'] != source.hosts[0]) {
|
if (source.hosts.isEmpty || values['url'] != source.hosts[0]) {
|
||||||
source = sourceProvider.getSource(values['url'],
|
source = sourceProvider.getSource(values['url'],
|
||||||
overrideSource: source.runtimeType.toString());
|
overrideSource: source.runtimeType.toString());
|
||||||
}
|
}
|
||||||
|
@@ -819,7 +819,7 @@ class SourceProvider {
|
|||||||
AppSource source, String url, Map<String, dynamic> additionalSettings,
|
AppSource source, String url, Map<String, dynamic> additionalSettings,
|
||||||
{App? currentApp,
|
{App? currentApp,
|
||||||
bool trackOnlyOverride = false,
|
bool trackOnlyOverride = false,
|
||||||
String? overrideSource,
|
bool sourceIsOverriden = false,
|
||||||
bool inferAppIdIfOptional = false}) async {
|
bool inferAppIdIfOptional = false}) async {
|
||||||
if (trackOnlyOverride || source.enforceTrackOnly) {
|
if (trackOnlyOverride || source.enforceTrackOnly) {
|
||||||
additionalSettings['trackOnly'] = true;
|
additionalSettings['trackOnly'] = true;
|
||||||
@@ -887,7 +887,9 @@ class SourceProvider {
|
|||||||
categories: currentApp?.categories ?? const [],
|
categories: currentApp?.categories ?? const [],
|
||||||
releaseDate: apk.releaseDate,
|
releaseDate: apk.releaseDate,
|
||||||
changeLog: apk.changeLog,
|
changeLog: apk.changeLog,
|
||||||
overrideSource: overrideSource ?? currentApp?.overrideSource,
|
overrideSource: sourceIsOverriden
|
||||||
|
? source.runtimeType.toString()
|
||||||
|
: currentApp?.overrideSource,
|
||||||
allowIdChange: currentApp?.allowIdChange ??
|
allowIdChange: currentApp?.allowIdChange ??
|
||||||
trackOnly ||
|
trackOnly ||
|
||||||
(source.appIdInferIsOptional &&
|
(source.appIdInferIsOptional &&
|
||||||
@@ -911,6 +913,7 @@ class SourceProvider {
|
|||||||
apps.add(await getApp(
|
apps.add(await getApp(
|
||||||
source,
|
source,
|
||||||
url,
|
url,
|
||||||
|
sourceIsOverriden: sourceOverride != null,
|
||||||
getDefaultValuesFromFormItems(
|
getDefaultValuesFromFormItems(
|
||||||
source.combinedAppSpecificSettingFormItems)));
|
source.combinedAppSpecificSettingFormItems)));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Reference in New Issue
Block a user