Skip to content

Commit e35fd1e

Browse files
authored
Merge pull request #2350 from ImranR98/dev
- Minor wording changes (#2226, #2313, #2317, #2338) - HTML bugfix: Incorrect URL resolution on redirected pages (#2315)
2 parents b539f0a + 86be6a7 commit e35fd1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+6884
-5337
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Or, contribute some configurations to the website by creating a PR at [this repo
6363

6464
Verification info:
6565
- Package ID: `dev.imranr.obtainium`
66-
- SHA-256 Hash of Signing Certificate: `B3:53:60:1F:6A:1D:5F:D6:60:3A:E2:F5:0B:E8:0C:F3:01:36:7B:86:B6:AB:8B:1F:66:24:3D:A9:6C:D5:73:62`
66+
- SHA-256 hash of signing certificate: `B3:53:60:1F:6A:1D:5F:D6:60:3A:E2:F5:0B:E8:0C:F3:01:36:7B:86:B6:AB:8B:1F:66:24:3D:A9:6C:D5:73:62`
6767
- Note: The above signature is also valid for the F-Droid flavour of Obtainium, thanks to [reproducible builds](https://f-droid.org/docs/Reproducible_Builds/).
6868
- [PGP Public Key](https://keyserver.ubuntu.com/pks/lookup?search=contact%40imranr.dev&fingerprint=on&op=index) (to verify APK hashes)
6969

lib/app_sources/apkcombo.dart

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ class APKCombo extends AppSource {
1212
@override
1313
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
1414
RegExp standardUrlRegEx = RegExp(
15-
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+[^/]+',
16-
caseSensitive: false);
15+
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+[^/]+',
16+
caseSensitive: false,
17+
);
1718
var match = standardUrlRegEx.firstMatch(url);
1819
if (match == null) {
1920
throw InvalidURLError(name);
@@ -22,25 +23,30 @@ class APKCombo extends AppSource {
2223
}
2324

2425
@override
25-
Future<String?> tryInferringAppId(String standardUrl,
26-
{Map<String, dynamic> additionalSettings = const {}}) async {
26+
Future<String?> tryInferringAppId(
27+
String standardUrl, {
28+
Map<String, dynamic> additionalSettings = const {},
29+
}) async {
2730
return Uri.parse(standardUrl).pathSegments.last;
2831
}
2932

3033
@override
3134
Future<Map<String, String>?> getRequestHeaders(
32-
Map<String, dynamic> additionalSettings,
33-
{bool forAPKDownload = false}) async {
35+
Map<String, dynamic> additionalSettings, {
36+
bool forAPKDownload = false,
37+
}) async {
3438
return {
3539
"User-Agent": "curl/8.0.1",
3640
"Accept": "*/*",
3741
"Connection": "keep-alive",
38-
"Host": hosts[0]
42+
"Host": hosts[0],
3943
};
4044
}
4145

4246
Future<List<MapEntry<String, String>>> getApkUrls(
43-
String standardUrl, Map<String, dynamic> additionalSettings) async {
47+
String standardUrl,
48+
Map<String, dynamic> additionalSettings,
49+
) async {
4450
var res = await sourceRequest('$standardUrl/download/apk', {});
4551
if (res.statusCode != 200) {
4652
throw getObtainiumHttpError(res);
@@ -65,7 +71,9 @@ class APKCombo extends AppSource {
6571
String verCode =
6672
e.querySelector('.info .header .vercode')?.text.trim() ?? '';
6773
return MapEntry<String, String>(
68-
arch != null ? '$arch-$verCode.apk' : '', url ?? '');
74+
arch != null ? '$arch-$verCode.apk' : '',
75+
url ?? '',
76+
);
6977
}).toList();
7078
})
7179
.reduce((value, element) => [...value, ...element])
@@ -74,8 +82,11 @@ class APKCombo extends AppSource {
7482
}
7583

7684
@override
77-
Future<String> apkUrlPrefetchModifier(String apkUrl, String standardUrl,
78-
Map<String, dynamic> additionalSettings) async {
85+
Future<String> apkUrlPrefetchModifier(
86+
String apkUrl,
87+
String standardUrl,
88+
Map<String, dynamic> additionalSettings,
89+
) async {
7990
var freshURLs = await getApkUrls(standardUrl, additionalSettings);
8091
var path2Match = Uri.parse(apkUrl).path;
8192
for (var url in freshURLs) {
@@ -116,9 +127,10 @@ class APKCombo extends AppSource {
116127
}
117128
}
118129
return APKDetails(
119-
version,
120-
await getApkUrls(standardUrl, additionalSettings),
121-
AppNames(author, appName),
122-
releaseDate: releaseDate);
130+
version,
131+
await getApkUrls(standardUrl, additionalSettings),
132+
AppNames(author, appName),
133+
releaseDate: releaseDate,
134+
);
123135
}
124136
}

lib/app_sources/apkmirror.dart

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,44 @@ class APKMirror extends AppSource {
1717

1818
additionalSourceAppSpecificSettingFormItems = [
1919
[
20-
GeneratedFormSwitch('fallbackToOlderReleases',
21-
label: tr('fallbackToOlderReleases'), defaultValue: true)
20+
GeneratedFormSwitch(
21+
'fallbackToOlderReleases',
22+
label: tr('fallbackToOlderReleases'),
23+
defaultValue: true,
24+
),
2225
],
2326
[
24-
GeneratedFormTextField('filterReleaseTitlesByRegEx',
25-
label: tr('filterReleaseTitlesByRegEx'),
26-
required: false,
27-
additionalValidators: [
28-
(value) {
29-
return regExValidator(value);
30-
}
31-
])
32-
]
27+
GeneratedFormTextField(
28+
'filterReleaseTitlesByRegEx',
29+
label: tr('filterReleaseTitlesByRegEx'),
30+
required: false,
31+
additionalValidators: [
32+
(value) {
33+
return regExValidator(value);
34+
},
35+
],
36+
),
37+
],
3338
];
3439
}
3540

3641
@override
3742
Future<Map<String, String>?> getRequestHeaders(
38-
Map<String, dynamic> additionalSettings,
39-
{bool forAPKDownload = false}) async {
43+
Map<String, dynamic> additionalSettings, {
44+
bool forAPKDownload = false,
45+
}) async {
4046
return {
4147
"User-Agent":
42-
"Obtainium/${(await getInstalledInfo(obtainiumId))?.versionName ?? '1.0.0'}"
48+
"Obtainium/${(await getInstalledInfo(obtainiumId))?.versionName ?? '1.0.0'}",
4349
};
4450
}
4551

4652
@override
4753
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
4854
RegExp standardUrlRegEx = RegExp(
49-
'^https?://(www\\.)?${getSourceRegex(hosts)}/apk/[^/]+/[^/]+',
50-
caseSensitive: false);
55+
'^https?://(www\\.)?${getSourceRegex(hosts)}/apk/[^/]+/[^/]+',
56+
caseSensitive: false,
57+
);
5158
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
5259
if (match == null) {
5360
throw InvalidURLError(name);
@@ -68,12 +75,14 @@ class APKMirror extends AppSource {
6875
additionalSettings['fallbackToOlderReleases'] == true;
6976
String? regexFilter =
7077
(additionalSettings['filterReleaseTitlesByRegEx'] as String?)
71-
?.isNotEmpty ==
72-
true
73-
? additionalSettings['filterReleaseTitlesByRegEx']
74-
: null;
75-
Response res =
76-
await sourceRequest('$standardUrl/feed/', additionalSettings);
78+
?.isNotEmpty ==
79+
true
80+
? additionalSettings['filterReleaseTitlesByRegEx']
81+
: null;
82+
Response res = await sourceRequest(
83+
'$standardUrl/feed/',
84+
additionalSettings,
85+
);
7786
if (res.statusCode == 200) {
7887
var items = parse(res.body).querySelectorAll('item');
7988
dynamic targetRelease;
@@ -95,20 +104,27 @@ class APKMirror extends AppSource {
95104
.split(' ')
96105
.sublist(0, 5)
97106
.join(' ');
98-
DateTime? releaseDate =
99-
dateString != null ? HttpDate.parse('$dateString GMT') : null;
107+
DateTime? releaseDate = dateString != null
108+
? HttpDate.parse('$dateString GMT')
109+
: null;
100110
String? version = titleString
101-
?.substring(RegExp('[0-9]').firstMatch(titleString)?.start ?? 0,
102-
RegExp(' by ').allMatches(titleString).last.start)
111+
?.substring(
112+
RegExp('[0-9]').firstMatch(titleString)?.start ?? 0,
113+
RegExp(' by ').allMatches(titleString).last.start,
114+
)
103115
.trim();
104116
if (version == null || version.isEmpty) {
105117
version = titleString;
106118
}
107119
if (version == null || version.isEmpty) {
108120
throw NoVersionError();
109121
}
110-
return APKDetails(version, [], getAppNames(standardUrl),
111-
releaseDate: releaseDate);
122+
return APKDetails(
123+
version,
124+
[],
125+
getAppNames(standardUrl),
126+
releaseDate: releaseDate,
127+
);
112128
} else {
113129
throw getObtainiumHttpError(res);
114130
}

lib/app_sources/apkpure.dart

Lines changed: 59 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:obtainium/providers/source_provider.dart';
88

99
extension Unique<E, Id> on List<E> {
1010
List<E> unique([Id Function(E element)? id, bool inplace = true]) {
11-
final ids = Set();
11+
final ids = <dynamic>{};
1212
var list = inplace ? this : List<E>.from(this);
1313
list.retainWhere((x) => ids.add(id != null ? id(x) : x as Id));
1414
return list;
@@ -23,33 +23,44 @@ class APKPure extends AppSource {
2323
showReleaseDateAsVersionToggle = true;
2424
additionalSourceAppSpecificSettingFormItems = [
2525
[
26-
GeneratedFormSwitch('fallbackToOlderReleases',
27-
label: tr('fallbackToOlderReleases'), defaultValue: true)
26+
GeneratedFormSwitch(
27+
'fallbackToOlderReleases',
28+
label: tr('fallbackToOlderReleases'),
29+
defaultValue: true,
30+
),
2831
],
2932
[
30-
GeneratedFormSwitch('stayOneVersionBehind',
31-
label: tr('stayOneVersionBehind'), defaultValue: false)
33+
GeneratedFormSwitch(
34+
'stayOneVersionBehind',
35+
label: tr('stayOneVersionBehind'),
36+
defaultValue: false,
37+
),
3238
],
3339
[
34-
GeneratedFormSwitch('useFirstApkOfVersion',
35-
label: tr('useFirstApkOfVersion'), defaultValue: true)
36-
]
40+
GeneratedFormSwitch(
41+
'useFirstApkOfVersion',
42+
label: tr('useFirstApkOfVersion'),
43+
defaultValue: true,
44+
),
45+
],
3746
];
3847
}
3948

4049
@override
4150
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
4251
RegExp standardUrlRegExB = RegExp(
43-
'^https?://m.${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
44-
caseSensitive: false);
52+
'^https?://m.${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
53+
caseSensitive: false,
54+
);
4555
RegExpMatch? match = standardUrlRegExB.firstMatch(url);
4656
if (match != null) {
4757
var uri = Uri.parse(url);
4858
url = 'https://${uri.host.substring(2)}${uri.path}';
4959
}
5060
RegExp standardUrlRegExA = RegExp(
51-
'^https?://(www\\.)?${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
52-
caseSensitive: false);
61+
'^https?://(www\\.)?${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
62+
caseSensitive: false,
63+
);
5364
match = standardUrlRegExA.firstMatch(url);
5465
if (match == null) {
5566
throw InvalidURLError(name);
@@ -58,15 +69,18 @@ class APKPure extends AppSource {
5869
}
5970

6071
@override
61-
Future<String?> tryInferringAppId(String standardUrl,
62-
{Map<String, dynamic> additionalSettings = const {}}) async {
72+
Future<String?> tryInferringAppId(
73+
String standardUrl, {
74+
Map<String, dynamic> additionalSettings = const {},
75+
}) async {
6376
return Uri.parse(standardUrl).pathSegments.last;
6477
}
6578

66-
getDetailsForVersion(
67-
List<Map<String, dynamic>> versionVariants,
68-
List<String> supportedArchs,
69-
Map<String, dynamic> additionalSettings) async {
79+
Future<APKDetails> getDetailsForVersion(
80+
List<Map<String, dynamic>> versionVariants,
81+
List<String> supportedArchs,
82+
Map<String, dynamic> additionalSettings,
83+
) async {
7084
var apkUrls = versionVariants
7185
.map((e) {
7286
String appId = e['package_name'];
@@ -88,8 +102,9 @@ class APKPure extends AppSource {
88102
String downloadUri = e['asset']['url'];
89103

90104
return MapEntry(
91-
'$appId-$versionCode-$architectureString.${type.toLowerCase()}',
92-
downloadUri);
105+
'$appId-$versionCode-$architectureString.${type.toLowerCase()}',
106+
downloadUri,
107+
);
93108
})
94109
.nonNulls
95110
.toList()
@@ -114,14 +129,20 @@ class APKPure extends AppSource {
114129
apkUrls = [apkUrls.first];
115130
}
116131

117-
return APKDetails(version, apkUrls, AppNames(author, appName),
118-
releaseDate: releaseDate, changeLog: changeLog);
132+
return APKDetails(
133+
version,
134+
apkUrls,
135+
AppNames(author, appName),
136+
releaseDate: releaseDate,
137+
changeLog: changeLog,
138+
);
119139
}
120140

121141
@override
122142
Future<Map<String, String>?> getRequestHeaders(
123-
Map<String, dynamic> additionalSettings,
124-
{bool forAPKDownload = false}) async {
143+
Map<String, dynamic> additionalSettings, {
144+
bool forAPKDownload = false,
145+
}) async {
125146
if (forAPKDownload) {
126147
return null;
127148
} else {
@@ -145,19 +166,22 @@ class APKPure extends AppSource {
145166

146167
// request versions from API
147168
var res = await sourceRequest(
148-
"https://tapi.pureapk.com/v3/get_app_his_version?package_name=$appId&hl=en",
149-
additionalSettings);
169+
"https://tapi.pureapk.com/v3/get_app_his_version?package_name=$appId&hl=en",
170+
additionalSettings,
171+
);
150172
if (res.statusCode != 200) {
151173
throw getObtainiumHttpError(res);
152174
}
153-
List<Map<String, dynamic>> apks =
154-
jsonDecode(res.body)['version_list'].cast<Map<String, dynamic>>();
175+
List<Map<String, dynamic>> apks = jsonDecode(
176+
res.body,
177+
)['version_list'].cast<Map<String, dynamic>>();
155178

156179
// group by version
157180
List<List<Map<String, dynamic>>> versions = apks
158-
.fold<Map<String, List<Map<String, dynamic>>>>({},
159-
(Map<String, List<Map<String, dynamic>>> val,
160-
Map<String, dynamic> element) {
181+
.fold<Map<String, List<Map<String, dynamic>>>>({}, (
182+
Map<String, List<Map<String, dynamic>>> val,
183+
Map<String, dynamic> element,
184+
) {
161185
String v = element['version_name'];
162186
if (!val.containsKey(v)) {
163187
val[v] = [];
@@ -179,7 +203,10 @@ class APKPure extends AppSource {
179203
throw NoReleasesError();
180204
}
181205
return await getDetailsForVersion(
182-
v, supportedArchs, additionalSettings);
206+
v,
207+
supportedArchs,
208+
additionalSettings,
209+
);
183210
} catch (e) {
184211
if (additionalSettings['fallbackToOlderReleases'] != true ||
185212
i == versions.length - 1) {

0 commit comments

Comments
 (0)