diff --git a/lib/app_sources/mullvad.dart b/lib/app_sources/mullvad.dart index a7449dd..763befd 100644 --- a/lib/app_sources/mullvad.dart +++ b/lib/app_sources/mullvad.dart @@ -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 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) { - throw NoVersionError(); + 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(); + } + String? changeLog; + try { + changeLog = (await GitHub().getLatestAPKDetails( + 'https://github.com/mullvad/mullvadvpn-app', + {'fallbackToOlderReleases': true})) + .changeLog; + } catch (e) { + // Ignore + } + return APKDetails( + versions[0], + ['https://mullvad.net/download/app/apk/latest'], + AppNames(name, 'Mullvad-VPN'), + changeLog: changeLog); + } else { + throw getObtainiumHttpError(res); } - details.version = fileName.substring(versionMatch.start, versionMatch.end); - details.names = AppNames(name, 'Mullvad-VPN'); - try { - details.changeLog = (await GitHub().getLatestAPKDetails( - 'https://github.com/mullvad/mullvadvpn-app', - {'fallbackToOlderReleases': true})) - .changeLog; - } catch (e) { - print(e); - // Ignore - } - return details; } } diff --git a/lib/main.dart b/lib/main.dart index e9251aa..94f7d2e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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 diff --git a/pubspec.yaml b/pubspec.yaml index eca32fa..0f6c57f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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'