mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-16 14:46:44 +02:00
Fixed Mullvad web scraping (again)
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:obtainium/app_sources/github.dart';
|
||||
import 'package:obtainium/app_sources/html.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
|
||||
@ -29,24 +28,41 @@ class Mullvad extends AppSource {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var details = await HTML().getLatestAPKDetails(
|
||||
'$standardUrl/en/download/android', additionalSettings);
|
||||
var fileName = details.apkUrls[0].split('/').last;
|
||||
var versionMatch = RegExp('[0-9]+(\\.[0-9]+)+').firstMatch(fileName);
|
||||
if (versionMatch == null) {
|
||||
Response res = await get(Uri.parse('$standardUrl/en/download/android'));
|
||||
if (res.statusCode == 200) {
|
||||
var versions = parse(res.body)
|
||||
.querySelectorAll('p')
|
||||
.map((e) => e.innerHtml)
|
||||
.where((p) => p.contains('Latest version: '))
|
||||
.map((e) {
|
||||
var match = RegExp('[0-9]+(\\.[0-9]+)*').firstMatch(e);
|
||||
if (match == null) {
|
||||
return '';
|
||||
} else {
|
||||
return e.substring(match.start, match.end);
|
||||
}
|
||||
})
|
||||
.where((element) => element.isNotEmpty)
|
||||
.toList();
|
||||
if (versions.isEmpty) {
|
||||
throw NoVersionError();
|
||||
}
|
||||
details.version = fileName.substring(versionMatch.start, versionMatch.end);
|
||||
details.names = AppNames(name, 'Mullvad-VPN');
|
||||
String? changeLog;
|
||||
try {
|
||||
details.changeLog = (await GitHub().getLatestAPKDetails(
|
||||
changeLog = (await GitHub().getLatestAPKDetails(
|
||||
'https://github.com/mullvad/mullvadvpn-app',
|
||||
{'fallbackToOlderReleases': true}))
|
||||
.changeLog;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
// Ignore
|
||||
}
|
||||
return details;
|
||||
return APKDetails(
|
||||
versions[0],
|
||||
['https://mullvad.net/download/app/apk/latest'],
|
||||
AppNames(name, 'Mullvad-VPN'),
|
||||
changeLog: changeLog);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:easy_localization/src/localization.dart';
|
||||
|
||||
const String currentVersion = '0.11.17';
|
||||
const String currentVersion = '0.11.18';
|
||||
const String currentReleaseTag =
|
||||
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
||||
|
||||
|
@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 0.11.17+139 # When changing this, update the tag in main() accordingly
|
||||
version: 0.11.18+140 # When changing this, update the tag in main() accordingly
|
||||
|
||||
environment:
|
||||
sdk: '>=2.18.2 <3.0.0'
|
||||
|
Reference in New Issue
Block a user