mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-12 21:06:43 +02:00
Merge pull request #2269 from iKirby/vivo
Add support for vivo App Store
This commit is contained in:
@ -31,6 +31,7 @@ Currently supported App sources:
|
||||
- [Huawei AppGallery](https://appgallery.huawei.com/)
|
||||
- [Tencent App Store](https://sj.qq.com/)
|
||||
- [CoolApk](https://coolapk.com/)
|
||||
- [vivo App Store (CN)](https://h5.appstore.vivo.com.cn/)
|
||||
- [RuStore](https://rustore.ru/)
|
||||
- Jenkins Jobs
|
||||
- [APKMirror](https://apkmirror.com/) (Track-Only)
|
||||
|
@ -321,6 +321,7 @@
|
||||
"refreshBeforeDownload": "Refresh app details before download",
|
||||
"tencentAppStore": "Tencent App Store",
|
||||
"coolApk": "CoolApk",
|
||||
"vivoAppStore": "vivo App Store (CN)",
|
||||
"name": "Name",
|
||||
"smartname": "Name (smart)",
|
||||
"sortMethod": "Sort method",
|
||||
|
@ -321,6 +321,7 @@
|
||||
"refreshBeforeDownload": "下载前刷新应用程序详细信息",
|
||||
"tencentAppStore": "腾讯应用宝",
|
||||
"coolApk": "酷安",
|
||||
"vivoAppStore": "vivo 应用商店(中国)",
|
||||
"name": "名称",
|
||||
"smartname": "姓名(智能)",
|
||||
"sortMethod": "排序方法",
|
||||
|
@ -26,6 +26,7 @@
|
||||
<li>Huawei AppGallery</li>
|
||||
<li>Tencent App Store</li>
|
||||
<li>CoolApk</li>
|
||||
<li>vivo App Store (CN)</li>
|
||||
<li>Jenkins Jobs</li>
|
||||
<li>RuStore</li>
|
||||
</ul>
|
||||
|
@ -26,6 +26,7 @@
|
||||
<li>Huawei AppGallery</li>
|
||||
<li>Tencent App Store</li>
|
||||
<li>CoolApk</li>
|
||||
<li>vivo App Store (CN)</li>
|
||||
<li>Jenkins Jobs</li>
|
||||
<li>RuStore</li>
|
||||
</ul>
|
||||
|
97
lib/app_sources/vivoappstore.dart
Normal file
97
lib/app_sources/vivoappstore.dart
Normal file
@ -0,0 +1,97 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
|
||||
class VivoAppStore extends AppSource {
|
||||
static const appDetailUrl =
|
||||
'https://h5coml.vivo.com.cn/h5coml/appdetail_h5/browser_v2/index.html?appId=';
|
||||
|
||||
VivoAppStore() {
|
||||
name = tr('vivoAppStore');
|
||||
hosts = ['h5.appstore.vivo.com.cn', 'h5coml.vivo.com.cn'];
|
||||
naiveStandardVersionDetection = true;
|
||||
canSearch = true;
|
||||
}
|
||||
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
var vivoAppId = parseVivoAppId(url);
|
||||
return '$appDetailUrl$vivoAppId';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
var json = await getDetailJson(standardUrl, additionalSettings);
|
||||
return json['package_name'];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<APKDetails> getLatestAPKDetails(
|
||||
String standardUrl, Map<String, dynamic> additionalSettings) async {
|
||||
var json = await getDetailJson(standardUrl, additionalSettings);
|
||||
var appName = json['title_zh'].toString();
|
||||
var packageName = json['package_name'].toString();
|
||||
var versionName = json['version_name'].toString();
|
||||
var versionCode = json['version_code'].toString();
|
||||
var developer = json['developer'].toString();
|
||||
var uploadTime = json['upload_time'].toString();
|
||||
var apkUrl = json['download_url'].toString();
|
||||
var apkName = '${packageName}_$versionCode.apk';
|
||||
return APKDetails(
|
||||
versionName, [MapEntry(apkName, apkUrl)], AppNames(developer, appName),
|
||||
releaseDate: DateTime.parse(uploadTime));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, List<String>>> search(String query,
|
||||
{Map<String, dynamic> querySettings = const {}}) async {
|
||||
var apiBaseUrl =
|
||||
'https://h5-api.appstore.vivo.com.cn/h5appstore/search/result-list?app_version=2100&page_index=1&apps_per_page=20&target=local&cfrom=2&key=';
|
||||
var searchUrl = '$apiBaseUrl${Uri.encodeQueryComponent(query)}';
|
||||
var response = await sourceRequest(searchUrl, {});
|
||||
if (response.statusCode != 200) {
|
||||
throw getObtainiumHttpError(response);
|
||||
}
|
||||
var json = jsonDecode(response.body);
|
||||
if (json['code'] != 0 || !json['data']['appSearchResponse']['result']) {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
Map<String, List<String>> results = {};
|
||||
var resultsJson = json['data']['appSearchResponse']['value'];
|
||||
for (var item in (resultsJson as List<dynamic>)) {
|
||||
results['$appDetailUrl${item['id']}'] = [
|
||||
item['title_zh'].toString(),
|
||||
item['developer'].toString()
|
||||
];
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getDetailJson(
|
||||
String standardUrl, Map<String, dynamic> additionalSettings) async {
|
||||
var vivoAppId = parseVivoAppId(standardUrl);
|
||||
var apiBaseUrl = 'https://h5-api.appstore.vivo.com.cn/detail/';
|
||||
var params = '?frompage=messageh5&app_version=2100';
|
||||
var detailUrl = '$apiBaseUrl$vivoAppId$params';
|
||||
var response = await sourceRequest(detailUrl, additionalSettings);
|
||||
if (response.statusCode != 200) {
|
||||
throw getObtainiumHttpError(response);
|
||||
}
|
||||
var json = jsonDecode(response.body);
|
||||
if (json['id'] == null) {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
String parseVivoAppId(String url) {
|
||||
var appId = Uri.parse(url.replaceAll('/#', '')).queryParameters['appId'];
|
||||
if (appId == null || appId.isEmpty) {
|
||||
throw InvalidURLError(name);
|
||||
}
|
||||
return appId;
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ import 'package:obtainium/app_sources/sourcehut.dart';
|
||||
import 'package:obtainium/app_sources/telegramapp.dart';
|
||||
import 'package:obtainium/app_sources/tencent.dart';
|
||||
import 'package:obtainium/app_sources/uptodown.dart';
|
||||
import 'package:obtainium/app_sources/vivoappstore.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/mass_app_sources/githubstars.dart';
|
||||
@ -955,6 +956,7 @@ class SourceProvider {
|
||||
HuaweiAppGallery(),
|
||||
Tencent(),
|
||||
CoolApk(),
|
||||
VivoAppStore(),
|
||||
Jenkins(),
|
||||
APKMirror(),
|
||||
RuStore(),
|
||||
|
Reference in New Issue
Block a user