Skip to content

Commit

Permalink
APKPure bugfix: Correctly extract APKs that are multi-arch but not un…
Browse files Browse the repository at this point in the history
…iversal
  • Loading branch information
Imran Remtulla committed Aug 6, 2024
1 parent f00758c commit ed2e6e2
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/app_sources/apkpure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ class APKPure extends AppSource {
'customLinkFilterRegex': '$standardUrl/download/[^/]+\$'
});

// if (versionLinks.length > 7) {
// // Returns up to 30 which is too much - would take too long and possibly get blocked/rate-limited
// versionLinks = versionLinks.sublist(0, 7);
// }

var supportedArchs = (await DeviceInfoPlugin().androidInfo).supportedAbis;

if (additionalSettings['autoApkFilterByArch'] != true) {
Expand All @@ -94,11 +89,15 @@ class APKPure extends AppSource {
var apkUrls = apksDiv
?.querySelectorAll('div.group-title')
.map((e) {
String architecture = e.text.trim();
if (architecture.toLowerCase() == 'unlimited' ||
architecture.toLowerCase() == 'universal') {
architecture = '';
String architectureString = e.text.trim();
if (architectureString.toLowerCase() == 'unlimited' ||
architectureString.toLowerCase() == 'universal') {
architectureString = '';
}
List<String> architectures = architectureString
.split(',')
.map((e) => e.trim())
.toList();
// Only take the first APK for each architecture, ignore others for now, for simplicity
// Unclear why there can even be multiple APKs for the same version and arch
var apkInfo = e.nextElementSibling?.querySelector('div.info');
Expand All @@ -121,14 +120,16 @@ class APKPure extends AppSource {
DateTime? releaseDate =
parseDateTimeMMMddCommayyyy(dateString);
if (additionalSettings['autoApkFilterByArch'] == true &&
architecture.isNotEmpty &&
!supportedArchs.contains(architecture)) {
architectures.isNotEmpty &&
architectures
.where((a) => supportedArchs.contains(a))
.isEmpty) {
return const MapEntry('', '');
}
topReleaseDate ??=
releaseDate; // Just use the release date of the first APK in the list as the release date for this version
return MapEntry(
'$appId-$versionCode-$architecture.${type.toLowerCase()}',
'$appId-$versionCode-$architectureString.${type.toLowerCase()}',
'https://d.${hosts.contains(host) ? 'cdnpure.com' : host}/b/$type/$appId?versionCode=$versionCode');
})
.where((e) => e.key.isNotEmpty)
Expand Down

0 comments on commit ed2e6e2

Please sign in to comment.