mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-11-04 07:13:28 +01:00 
			
		
		
		
	Compare commits
	
		
			4 Commits
		
	
	
		
			v0.11.12-b
			...
			v0.11.13-b
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					3bc5837999 | ||
| 
						 | 
					9fbe524818 | ||
| 
						 | 
					c21a9d7292 | ||
| 
						 | 
					9c6068b270 | 
							
								
								
									
										75
									
								
								lib/app_sources/whatsapp.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								lib/app_sources/whatsapp.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
				
			|||||||
 | 
					import 'package:html/parser.dart';
 | 
				
			||||||
 | 
					import 'package:http/http.dart';
 | 
				
			||||||
 | 
					import 'package:obtainium/custom_errors.dart';
 | 
				
			||||||
 | 
					import 'package:obtainium/providers/source_provider.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class WhatsApp extends AppSource {
 | 
				
			||||||
 | 
					  WhatsApp() {
 | 
				
			||||||
 | 
					    host = 'whatsapp.com';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  String standardizeURL(String url) {
 | 
				
			||||||
 | 
					    return 'https://$host';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  Future<String> apkUrlPrefetchModifier(String apkUrl) async {
 | 
				
			||||||
 | 
					    Response res = await get(Uri.parse('https://www.whatsapp.com/android'));
 | 
				
			||||||
 | 
					    if (res.statusCode == 200) {
 | 
				
			||||||
 | 
					      var targetLinks = parse(res.body)
 | 
				
			||||||
 | 
					          .querySelectorAll('a')
 | 
				
			||||||
 | 
					          .map((e) => e.attributes['href'])
 | 
				
			||||||
 | 
					          .where((e) => e != null)
 | 
				
			||||||
 | 
					          .where((e) =>
 | 
				
			||||||
 | 
					              e!.contains('scontent.whatsapp.net') &&
 | 
				
			||||||
 | 
					              e.contains('WhatsApp.apk'))
 | 
				
			||||||
 | 
					          .toList();
 | 
				
			||||||
 | 
					      if (targetLinks.isEmpty) {
 | 
				
			||||||
 | 
					        throw NoAPKError();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      return targetLinks[0]!;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      throw getObtainiumHttpError(res);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  Future<APKDetails> getLatestAPKDetails(
 | 
				
			||||||
 | 
					    String standardUrl,
 | 
				
			||||||
 | 
					    Map<String, dynamic> additionalSettings,
 | 
				
			||||||
 | 
					  ) async {
 | 
				
			||||||
 | 
					    Response res = await get(Uri.parse('https://www.whatsapp.com/android'));
 | 
				
			||||||
 | 
					    if (res.statusCode == 200) {
 | 
				
			||||||
 | 
					      var targetElements = parse(res.body)
 | 
				
			||||||
 | 
					          .querySelectorAll('p')
 | 
				
			||||||
 | 
					          .where((element) => element.innerHtml.contains('Version '))
 | 
				
			||||||
 | 
					          .toList();
 | 
				
			||||||
 | 
					      if (targetElements.isEmpty) {
 | 
				
			||||||
 | 
					        throw NoVersionError();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      var vLines = targetElements[0]
 | 
				
			||||||
 | 
					          .innerHtml
 | 
				
			||||||
 | 
					          .split('\n')
 | 
				
			||||||
 | 
					          .where((element) => element.contains('Version '))
 | 
				
			||||||
 | 
					          .toList();
 | 
				
			||||||
 | 
					      if (vLines.isEmpty) {
 | 
				
			||||||
 | 
					        throw NoVersionError();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      var versionMatch = RegExp('[0-9]+(\\.[0-9]+)+').firstMatch(vLines[0]);
 | 
				
			||||||
 | 
					      if (versionMatch == null) {
 | 
				
			||||||
 | 
					        throw NoVersionError();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      String version =
 | 
				
			||||||
 | 
					          vLines[0].substring(versionMatch.start, versionMatch.end);
 | 
				
			||||||
 | 
					      return APKDetails(
 | 
				
			||||||
 | 
					          version,
 | 
				
			||||||
 | 
					          [
 | 
				
			||||||
 | 
					            'https://www.whatsapp.com/android?v=$version&=thisIsaPlaceholder&a=realURLPrefetchedAtDownloadTime'
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          AppNames('Meta', 'WhatsApp'));
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      throw getObtainiumHttpError(res);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -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.12';
 | 
					const String currentVersion = '0.11.13';
 | 
				
			||||||
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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -571,7 +571,21 @@ class AppsProvider with ChangeNotifier {
 | 
				
			|||||||
    List<App> newApps = (await getAppsDir())
 | 
					    List<App> newApps = (await getAppsDir())
 | 
				
			||||||
        .listSync()
 | 
					        .listSync()
 | 
				
			||||||
        .where((item) => item.path.toLowerCase().endsWith('.json'))
 | 
					        .where((item) => item.path.toLowerCase().endsWith('.json'))
 | 
				
			||||||
        .map((e) => App.fromJson(jsonDecode(File(e.path).readAsStringSync())))
 | 
					        .map((e) {
 | 
				
			||||||
 | 
					          try {
 | 
				
			||||||
 | 
					            return App.fromJson(jsonDecode(File(e.path).readAsStringSync()));
 | 
				
			||||||
 | 
					          } catch (err) {
 | 
				
			||||||
 | 
					            if (err is FormatException) {
 | 
				
			||||||
 | 
					              logs.add('Corrupt JSON when loading App (will be ignored): $e');
 | 
				
			||||||
 | 
					              e.renameSync('${e.path}.corrupt');
 | 
				
			||||||
 | 
					              return App(
 | 
				
			||||||
 | 
					                  '', '', '', '', '', '', [], 0, {}, DateTime.now(), false);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					              rethrow;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        .where((element) => element.id.isNotEmpty)
 | 
				
			||||||
        .toList();
 | 
					        .toList();
 | 
				
			||||||
    var idsToDelete = apps.values
 | 
					    var idsToDelete = apps.values
 | 
				
			||||||
        .map((e) => e.app.id)
 | 
					        .map((e) => e.app.id)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@ import 'package:obtainium/app_sources/sourceforge.dart';
 | 
				
			|||||||
import 'package:obtainium/app_sources/steammobile.dart';
 | 
					import 'package:obtainium/app_sources/steammobile.dart';
 | 
				
			||||||
import 'package:obtainium/app_sources/telegramapp.dart';
 | 
					import 'package:obtainium/app_sources/telegramapp.dart';
 | 
				
			||||||
import 'package:obtainium/app_sources/vlc.dart';
 | 
					import 'package:obtainium/app_sources/vlc.dart';
 | 
				
			||||||
 | 
					import 'package:obtainium/app_sources/whatsapp.dart';
 | 
				
			||||||
import 'package:obtainium/components/generated_form.dart';
 | 
					import 'package:obtainium/components/generated_form.dart';
 | 
				
			||||||
import 'package:obtainium/custom_errors.dart';
 | 
					import 'package:obtainium/custom_errors.dart';
 | 
				
			||||||
import 'package:obtainium/mass_app_sources/githubstars.dart';
 | 
					import 'package:obtainium/mass_app_sources/githubstars.dart';
 | 
				
			||||||
@@ -342,14 +343,15 @@ class SourceProvider {
 | 
				
			|||||||
    Codeberg(),
 | 
					    Codeberg(),
 | 
				
			||||||
    FDroid(),
 | 
					    FDroid(),
 | 
				
			||||||
    IzzyOnDroid(),
 | 
					    IzzyOnDroid(),
 | 
				
			||||||
    Mullvad(),
 | 
					    FDroidRepo(),
 | 
				
			||||||
    Signal(),
 | 
					 | 
				
			||||||
    SourceForge(),
 | 
					    SourceForge(),
 | 
				
			||||||
    APKMirror(),
 | 
					    APKMirror(),
 | 
				
			||||||
    FDroidRepo(),
 | 
					    Mullvad(),
 | 
				
			||||||
    SteamMobile(),
 | 
					    Signal(),
 | 
				
			||||||
    TelegramApp(),
 | 
					 | 
				
			||||||
    VLC(),
 | 
					    VLC(),
 | 
				
			||||||
 | 
					    // WhatsApp(), // As of 2023-03-20 this is unusable as the version on the webpage is months out of date
 | 
				
			||||||
 | 
					    TelegramApp(),
 | 
				
			||||||
 | 
					    SteamMobile(),
 | 
				
			||||||
    NeutronCode(),
 | 
					    NeutronCode(),
 | 
				
			||||||
    HTML() // This should ALWAYS be the last option as they are tried in order
 | 
					    HTML() // This should ALWAYS be the last option as they are tried in order
 | 
				
			||||||
  ];
 | 
					  ];
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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.12+133 # When changing this, update the tag in main() accordingly
 | 
					version: 0.11.13+134 # 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