Various fixes and improvements (#454, #1026, #1050, #1051, #1052, #1060)

This commit is contained in:
Imran Remtulla
2023-11-03 19:35:42 -04:00
parent 26971aa109
commit 5b142b4401
6 changed files with 31 additions and 22 deletions

View File

@ -181,7 +181,7 @@ APKDetails getAPKUrlsFromFDroidPackagesAPIResponse(
List<String> apkUrls = releaseChoices List<String> apkUrls = releaseChoices
.map((e) => '${apkUrlPrefix}_${e['versionCode']}.apk') .map((e) => '${apkUrlPrefix}_${e['versionCode']}.apk')
.toList(); .toList();
return APKDetails(version, getApkUrlsFromUrls(apkUrls), return APKDetails(version, getApkUrlsFromUrls(apkUrls.toSet().toList()),
AppNames(sourceName, Uri.parse(standardUrl).pathSegments.last)); AppNames(sourceName, Uri.parse(standardUrl).pathSegments.last));
} else { } else {
throw getObtainiumHttpError(res); throw getObtainiumHttpError(res);

View File

@ -108,7 +108,8 @@ class FDroidRepo extends AppSource {
if (appIdOrName == null) { if (appIdOrName == null) {
throw NoReleasesError(); throw NoReleasesError();
} }
var res = await sourceRequest('$standardUrl/index.xml'); var res = await sourceRequest(
'$standardUrl${standardUrl.endsWith('/index.xml') ? '' : '/index.xml'}');
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) {

View File

@ -170,7 +170,15 @@ class HTML extends AppSource {
List<String> allLinks = html List<String> allLinks = html
.querySelectorAll('a') .querySelectorAll('a')
.map((element) => element.attributes['href'] ?? '') .map((element) => element.attributes['href'] ?? '')
.where((element) => element.isNotEmpty)
.toList(); .toList();
if (allLinks.isEmpty) {
allLinks = RegExp(
r'(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?')
.allMatches(res.body)
.map((match) => match.group(0)!)
.toList();
}
List<String> links = []; List<String> links = [];
if ((additionalSettings['intermediateLinkRegex'] as String?) if ((additionalSettings['intermediateLinkRegex'] as String?)
?.isNotEmpty == ?.isNotEmpty ==

View File

@ -89,11 +89,11 @@ class Uptodown extends AppSource {
throw getObtainiumHttpError(res); throw getObtainiumHttpError(res);
} }
var html = parse(res.body); var html = parse(res.body);
var finalUrl = var finalUrlKey =
(html.querySelector('.post-download')?.attributes['data-url']); html.querySelector('.post-download')?.attributes['data-url'];
if (finalUrl == null) { if (finalUrlKey == null) {
throw NoAPKError(); throw NoAPKError();
} }
return finalUrl; return 'https://dw.$host/dwn/$finalUrlKey';
} }
} }

View File

@ -155,10 +155,13 @@ class _AppPageState extends State<AppPage> {
const SizedBox(height: 20), const SizedBox(height: 20),
app?.icon != null app?.icon != null
? Row(mainAxisAlignment: MainAxisAlignment.center, children: [ ? Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Image.memory( GestureDetector(
app!.icon!, child: Image.memory(
height: 150, app!.icon!,
gaplessPlayback: true, height: 150,
gaplessPlayback: true,
),
onTap: () => pm.openApp(app.app.id),
) )
]) ])
: Container(), : Container(),
@ -463,15 +466,15 @@ class _AppPageState extends State<AppPage> {
: null)) : null))
], ],
)); ));
appScreenAppBar() => AppBar( appScreenAppBar() => AppBar(
leading: IconButton( leading: IconButton(
icon: const Icon(Icons.arrow_back), icon: const Icon(Icons.arrow_back),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
); );
return Scaffold( return Scaffold(
appBar: settingsProvider.showAppWebpage ? AppBar() : appScreenAppBar(), appBar: settingsProvider.showAppWebpage ? AppBar() : appScreenAppBar(),

View File

@ -283,9 +283,6 @@ preStandardizeUrl(String url) {
url.toLowerCase().indexOf('https://') != 0) { url.toLowerCase().indexOf('https://') != 0) {
url = 'https://$url'; url = 'https://$url';
} }
if (url.toLowerCase().indexOf('https://www.') == 0) {
url = 'https://${url.substring(12)}';
}
url = url url = url
.split('/') .split('/')
.where((e) => e.isNotEmpty) .where((e) => e.isNotEmpty)
@ -599,7 +596,7 @@ class SourceProvider {
AppSource? source; AppSource? source;
for (var s in sources.where((element) => element.host != null)) { for (var s in sources.where((element) => element.host != null)) {
if (RegExp( if (RegExp(
'://${s.allowSubDomains ? '([^\\.]+\\.)*' : ''}${s.host}(/|\\z)?') '://(${s.allowSubDomains ? '([^\\.]+\\.)*' : ''}|www\\.)${s.host}(/|\\z)?')
.hasMatch(url)) { .hasMatch(url)) {
source = s; source = s;
break; break;