mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-23 06:29:29 +02:00
Merge pull request #787 from ImranR98/dev
Enable Android TV 'OK' Button (#281), Add Huawei AppGallery (#756), Fix VLC Source (#758)
This commit is contained in:
@@ -18,6 +18,7 @@ Currently supported App sources:
|
|||||||
- [SourceHut](https://git.sr.ht/)
|
- [SourceHut](https://git.sr.ht/)
|
||||||
- [APKMirror](https://apkmirror.com/) (Track-Only)
|
- [APKMirror](https://apkmirror.com/) (Track-Only)
|
||||||
- [APKPure](https://apkpure.com/)
|
- [APKPure](https://apkpure.com/)
|
||||||
|
- [Huawei AppGallery](https://appgallery.huawei.com/)
|
||||||
- Third Party F-Droid Repos
|
- Third Party F-Droid Repos
|
||||||
- Jenkins Jobs
|
- Jenkins Jobs
|
||||||
- [Steam](https://store.steampowered.com/mobile)
|
- [Steam](https://store.steampowered.com/mobile)
|
||||||
|
90
lib/app_sources/huaweiappgallery.dart
Normal file
90
lib/app_sources/huaweiappgallery.dart
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:obtainium/custom_errors.dart';
|
||||||
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
|
|
||||||
|
class HuaweiAppGallery extends AppSource {
|
||||||
|
HuaweiAppGallery() {
|
||||||
|
name = 'Huawei AppGallery';
|
||||||
|
host = 'appgallery.huawei.com';
|
||||||
|
overrideVersionDetectionFormDefault('releaseDateAsVersion', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String sourceSpecificStandardizeURL(String url) {
|
||||||
|
RegExp standardUrlRegEx = RegExp('^https?://$host/app/[^/]+');
|
||||||
|
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase());
|
||||||
|
if (match == null) {
|
||||||
|
throw InvalidURLError(name);
|
||||||
|
}
|
||||||
|
return url.substring(0, match.end);
|
||||||
|
}
|
||||||
|
|
||||||
|
getDlUrl(String standardUrl) =>
|
||||||
|
'https://${host!.replaceAll('appgallery.', 'appgallery.cloud.')}/appdl/${standardUrl.split('/').last}';
|
||||||
|
|
||||||
|
requestAppdlRedirect(String dlUrl) async {
|
||||||
|
Response res = await sourceRequest(dlUrl, followRedirects: false);
|
||||||
|
if (res.statusCode == 200 ||
|
||||||
|
res.statusCode == 302 ||
|
||||||
|
res.statusCode == 304) {
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
throw getObtainiumHttpError(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
appIdFromRedirectDlUrl(String redirectDlUrl) {
|
||||||
|
var parts = redirectDlUrl
|
||||||
|
.split('?')[0]
|
||||||
|
.split('/')
|
||||||
|
.last
|
||||||
|
.split('.')
|
||||||
|
.reversed
|
||||||
|
.toList();
|
||||||
|
parts.removeAt(0);
|
||||||
|
parts.removeAt(0);
|
||||||
|
return parts.reversed.join('.');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String?> tryInferringAppId(String standardUrl,
|
||||||
|
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||||
|
String dlUrl = getDlUrl(standardUrl);
|
||||||
|
Response res = await requestAppdlRedirect(dlUrl);
|
||||||
|
return res.headers['location'] != null
|
||||||
|
? appIdFromRedirectDlUrl(res.headers['location']!)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<APKDetails> getLatestAPKDetails(
|
||||||
|
String standardUrl,
|
||||||
|
Map<String, dynamic> additionalSettings,
|
||||||
|
) async {
|
||||||
|
String dlUrl = getDlUrl(standardUrl);
|
||||||
|
Response res = await requestAppdlRedirect(dlUrl);
|
||||||
|
if (res.headers['location'] == null) {
|
||||||
|
throw NoReleasesError();
|
||||||
|
}
|
||||||
|
String appId = appIdFromRedirectDlUrl(res.headers['location']!);
|
||||||
|
var relDateStr =
|
||||||
|
res.headers['location']?.split('?')[0].split('.').reversed.toList()[1];
|
||||||
|
var relDateStrAdj = relDateStr?.split('');
|
||||||
|
var tempLen = relDateStrAdj?.length ?? 0;
|
||||||
|
var i = 2;
|
||||||
|
while (i < tempLen) {
|
||||||
|
relDateStrAdj?.insert((i + i ~/ 2 - 1), '-');
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
var relDate = relDateStrAdj == null
|
||||||
|
? null
|
||||||
|
: DateFormat('yy-MM-dd-HH-mm').parse(relDateStrAdj.join(''));
|
||||||
|
if (relDateStr == null) {
|
||||||
|
throw NoVersionError();
|
||||||
|
}
|
||||||
|
return APKDetails(
|
||||||
|
relDateStr, [MapEntry('$appId.apk', dlUrl)], AppNames(name, appId),
|
||||||
|
releaseDate: relDate);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +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/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';
|
||||||
|
|
||||||
@@ -7,40 +8,48 @@ class VLC extends AppSource {
|
|||||||
VLC() {
|
VLC() {
|
||||||
host = 'videolan.org';
|
host = 'videolan.org';
|
||||||
}
|
}
|
||||||
|
get dwUrlBase => 'https://get.$host/vlc-android/';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String>? get requestHeaders => HTML().requestHeaders;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url) {
|
||||||
return 'https://$host';
|
return 'https://$host';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String?> getLatestVersion(String standardUrl) async {
|
||||||
|
Response res = await sourceRequest(dwUrlBase);
|
||||||
|
if (res.statusCode == 200) {
|
||||||
|
var dwLinks = parse(res.body)
|
||||||
|
.querySelectorAll('a')
|
||||||
|
.where((element) => element.attributes['href'] != 'last/')
|
||||||
|
.map((e) => e.attributes['href']?.split('/')[0])
|
||||||
|
.toList();
|
||||||
|
String? version = dwLinks.isNotEmpty ? dwLinks.last : null;
|
||||||
|
if (version == null) {
|
||||||
|
throw NoVersionError();
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
} else {
|
||||||
|
throw getObtainiumHttpError(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<APKDetails> getLatestAPKDetails(
|
Future<APKDetails> getLatestAPKDetails(
|
||||||
String standardUrl,
|
String standardUrl,
|
||||||
Map<String, dynamic> additionalSettings,
|
Map<String, dynamic> additionalSettings,
|
||||||
) async {
|
) async {
|
||||||
Response res = await sourceRequest(
|
String? version = await getLatestVersion(standardUrl);
|
||||||
'https://www.videolan.org/vlc/download-android.html');
|
|
||||||
if (res.statusCode == 200) {
|
|
||||||
var dwUrlBase = 'get.videolan.org/vlc-android';
|
|
||||||
var dwLinks = parse(res.body)
|
|
||||||
.querySelectorAll('a')
|
|
||||||
.where((element) =>
|
|
||||||
element.attributes['href']?.contains(dwUrlBase) ?? false)
|
|
||||||
.toList();
|
|
||||||
String? version = dwLinks.isNotEmpty
|
|
||||||
? dwLinks.first.attributes['href']
|
|
||||||
?.split('/')
|
|
||||||
.where((s) => s.isNotEmpty)
|
|
||||||
.last
|
|
||||||
: null;
|
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
throw NoVersionError();
|
throw NoVersionError();
|
||||||
}
|
}
|
||||||
String? targetUrl = 'https://$dwUrlBase/$version/';
|
String? targetUrl = '$dwUrlBase$version/';
|
||||||
Response res2 = await sourceRequest(targetUrl);
|
Response res = await sourceRequest(targetUrl);
|
||||||
List<String> apkUrls = [];
|
List<String> apkUrls = [];
|
||||||
if (res2.statusCode == 200) {
|
if (res.statusCode == 200) {
|
||||||
apkUrls = parse(res2.body)
|
apkUrls = parse(res.body)
|
||||||
.querySelectorAll('a')
|
.querySelectorAll('a')
|
||||||
.map((e) => e.attributes['href']?.split('/').last)
|
.map((e) => e.attributes['href']?.split('/').last)
|
||||||
.where((h) =>
|
.where((h) =>
|
||||||
@@ -48,14 +57,11 @@ class VLC extends AppSource {
|
|||||||
.map((e) => targetUrl + e!)
|
.map((e) => targetUrl + e!)
|
||||||
.toList();
|
.toList();
|
||||||
} else {
|
} else {
|
||||||
throw getObtainiumHttpError(res2);
|
throw getObtainiumHttpError(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
return APKDetails(
|
return APKDetails(
|
||||||
version, getApkUrlsFromUrls(apkUrls), AppNames('VideoLAN', 'VLC'));
|
version, getApkUrlsFromUrls(apkUrls), AppNames('VideoLAN', 'VLC'));
|
||||||
} else {
|
|
||||||
throw getObtainiumHttpError(res);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@@ -22,7 +22,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.13.25';
|
const String currentVersion = '0.13.26';
|
||||||
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
|
||||||
|
|
||||||
@@ -299,7 +299,9 @@ class _ObtainiumState extends State<Obtainium> {
|
|||||||
? lightColorScheme
|
? lightColorScheme
|
||||||
: darkColorScheme,
|
: darkColorScheme,
|
||||||
fontFamily: 'Metropolis'),
|
fontFamily: 'Metropolis'),
|
||||||
home: const HomePage());
|
home: Shortcuts(shortcuts: <LogicalKeySet, Intent>{
|
||||||
|
LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(),
|
||||||
|
}, child: const HomePage()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -344,7 +344,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
// If we did not install the app (or it isn't installed), silent install is not possible
|
// If we did not install the app (or it isn't installed), silent install is not possible
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var targetSDK;
|
int? targetSDK;
|
||||||
try {
|
try {
|
||||||
targetSDK = (await pm.getPackageInfo(packageName: app.id))
|
targetSDK = (await pm.getPackageInfo(packageName: app.id))
|
||||||
?.applicationInfo
|
?.applicationInfo
|
||||||
@@ -391,7 +391,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
// If 0 APKs installed, throw the first install error encountered
|
// If 0 APKs installed, throw the first install error encountered
|
||||||
try {
|
try {
|
||||||
var somethingInstalled = false;
|
var somethingInstalled = false;
|
||||||
Object? firstError;
|
MultiAppMultiError errors = MultiAppMultiError();
|
||||||
for (var file in dir.extracted
|
for (var file in dir.extracted
|
||||||
.listSync(recursive: true, followLinks: false)
|
.listSync(recursive: true, followLinks: false)
|
||||||
.whereType<File>()) {
|
.whereType<File>()) {
|
||||||
@@ -402,7 +402,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
logs.add(
|
logs.add(
|
||||||
'Could not install APK from XAPK \'${file.path}\': ${e.toString()}');
|
'Could not install APK from XAPK \'${file.path}\': ${e.toString()}');
|
||||||
firstError ??= e;
|
errors.add(dir.appId, e.toString());
|
||||||
}
|
}
|
||||||
} else if (file.path.toLowerCase().endsWith('.obb')) {
|
} else if (file.path.toLowerCase().endsWith('.obb')) {
|
||||||
await moveObbFile(file, dir.appId);
|
await moveObbFile(file, dir.appId);
|
||||||
@@ -410,8 +410,8 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
if (somethingInstalled) {
|
if (somethingInstalled) {
|
||||||
dir.file.delete(recursive: true);
|
dir.file.delete(recursive: true);
|
||||||
} else if (firstError != null) {
|
} else if (errors.content.isNotEmpty) {
|
||||||
throw firstError;
|
throw errors;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
dir.extracted.delete(recursive: true);
|
dir.extracted.delete(recursive: true);
|
||||||
|
@@ -14,6 +14,7 @@ import 'package:obtainium/app_sources/fdroid.dart';
|
|||||||
import 'package:obtainium/app_sources/fdroidrepo.dart';
|
import 'package:obtainium/app_sources/fdroidrepo.dart';
|
||||||
import 'package:obtainium/app_sources/github.dart';
|
import 'package:obtainium/app_sources/github.dart';
|
||||||
import 'package:obtainium/app_sources/gitlab.dart';
|
import 'package:obtainium/app_sources/gitlab.dart';
|
||||||
|
import 'package:obtainium/app_sources/huaweiappgallery.dart';
|
||||||
import 'package:obtainium/app_sources/izzyondroid.dart';
|
import 'package:obtainium/app_sources/izzyondroid.dart';
|
||||||
import 'package:obtainium/app_sources/html.dart';
|
import 'package:obtainium/app_sources/html.dart';
|
||||||
import 'package:obtainium/app_sources/jenkins.dart';
|
import 'package:obtainium/app_sources/jenkins.dart';
|
||||||
@@ -355,10 +356,14 @@ abstract class AppSource {
|
|||||||
|
|
||||||
Map<String, String>? get requestHeaders => null;
|
Map<String, String>? get requestHeaders => null;
|
||||||
|
|
||||||
Future<Response> sourceRequest(String url) async {
|
Future<Response> sourceRequest(String url,
|
||||||
if (requestHeaders != null) {
|
{bool followRedirects = true}) async {
|
||||||
|
if (requestHeaders != null || followRedirects == false) {
|
||||||
var req = Request('GET', Uri.parse(url));
|
var req = Request('GET', Uri.parse(url));
|
||||||
|
req.followRedirects = followRedirects;
|
||||||
|
if (requestHeaders != null) {
|
||||||
req.headers.addAll(requestHeaders!);
|
req.headers.addAll(requestHeaders!);
|
||||||
|
}
|
||||||
return Response.fromStream(await Client().send(req));
|
return Response.fromStream(await Client().send(req));
|
||||||
} else {
|
} else {
|
||||||
return get(Uri.parse(url));
|
return get(Uri.parse(url));
|
||||||
@@ -508,6 +513,7 @@ class SourceProvider {
|
|||||||
SourceHut(),
|
SourceHut(),
|
||||||
APKMirror(),
|
APKMirror(),
|
||||||
APKPure(),
|
APKPure(),
|
||||||
|
HuaweiAppGallery(),
|
||||||
// APKCombo(), // Can't get past their scraping blocking yet (get 403 Forbidden)
|
// APKCombo(), // Can't get past their scraping blocking yet (get 403 Forbidden)
|
||||||
Mullvad(),
|
Mullvad(),
|
||||||
Signal(),
|
Signal(),
|
||||||
|
@@ -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.13.25+189 # When changing this, update the tag in main() accordingly
|
version: 0.13.26+190 # 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