mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-30 21:13:28 +01:00 
			
		
		
		
	Merge pull request #406 from ImranR98/dev
Fixed Mullvad web scraping (again)
This commit is contained in:
		| @@ -1,7 +1,6 @@ | |||||||
| import 'package:html/parser.dart'; | import 'package:html/parser.dart'; | ||||||
| import 'package:http/http.dart'; | import 'package:http/http.dart'; | ||||||
| import 'package:obtainium/app_sources/github.dart'; | import 'package:obtainium/app_sources/github.dart'; | ||||||
| import 'package:obtainium/app_sources/html.dart'; |  | ||||||
| import 'package:obtainium/custom_errors.dart'; | import 'package:obtainium/custom_errors.dart'; | ||||||
| import 'package:obtainium/providers/source_provider.dart'; | import 'package:obtainium/providers/source_provider.dart'; | ||||||
|  |  | ||||||
| @@ -29,24 +28,41 @@ class Mullvad extends AppSource { | |||||||
|     String standardUrl, |     String standardUrl, | ||||||
|     Map<String, dynamic> additionalSettings, |     Map<String, dynamic> additionalSettings, | ||||||
|   ) async { |   ) async { | ||||||
|     var details = await HTML().getLatestAPKDetails( |     Response res = await get(Uri.parse('$standardUrl/en/download/android')); | ||||||
|         '$standardUrl/en/download/android', additionalSettings); |     if (res.statusCode == 200) { | ||||||
|     var fileName = details.apkUrls[0].split('/').last; |       var versions = parse(res.body) | ||||||
|     var versionMatch = RegExp('[0-9]+(\\.[0-9]+)+').firstMatch(fileName); |           .querySelectorAll('p') | ||||||
|     if (versionMatch == null) { |           .map((e) => e.innerHtml) | ||||||
|       throw NoVersionError(); |           .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; |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; | |||||||
| // ignore: implementation_imports | // ignore: implementation_imports | ||||||
| import 'package:easy_localization/src/localization.dart'; | import 'package:easy_localization/src/localization.dart'; | ||||||
|  |  | ||||||
| const String currentVersion = '0.11.17'; | const String currentVersion = '0.11.18'; | ||||||
| const String currentReleaseTag = | const String currentReleaseTag = | ||||||
|     'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES |     '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 | # 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 | # 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. | # 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: | environment: | ||||||
|   sdk: '>=2.18.2 <3.0.0' |   sdk: '>=2.18.2 <3.0.0' | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user