mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-08 00:00:15 +02:00
Fix parsing vivo app id from URL when using source override
This commit is contained in:
@@ -17,11 +17,7 @@ class VivoAppStore extends AppSource {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
var vivoAppId =
|
var vivoAppId = parseVivoAppId(url);
|
||||||
Uri.parse(url.replaceAll('/#', '')).queryParameters['appId'];
|
|
||||||
if (vivoAppId == null) {
|
|
||||||
throw InvalidURLError(name);
|
|
||||||
}
|
|
||||||
return '$appDetailUrl$vivoAppId';
|
return '$appDetailUrl$vivoAppId';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,20 +72,26 @@ class VivoAppStore extends AppSource {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getDetailJson(
|
Future<Map<String, dynamic>> getDetailJson(
|
||||||
String standardUrl, Map<String, dynamic> additionalSettings) async {
|
String standardUrl, Map<String, dynamic> additionalSettings) async {
|
||||||
var vivoAppId = Uri.parse(standardUrl).queryParameters['appId'];
|
var vivoAppId = parseVivoAppId(standardUrl);
|
||||||
var apiBaseUrl = 'https://h5-api.appstore.vivo.com.cn/detail/';
|
var apiBaseUrl = 'https://h5-api.appstore.vivo.com.cn/detail/';
|
||||||
var params = '?frompage=messageh5&app_version=2100';
|
var params = '?frompage=messageh5&app_version=2100';
|
||||||
|
|
||||||
var detailUrl = '$apiBaseUrl$vivoAppId$params';
|
var detailUrl = '$apiBaseUrl$vivoAppId$params';
|
||||||
var response = await sourceRequest(detailUrl, additionalSettings);
|
var response = await sourceRequest(detailUrl, additionalSettings);
|
||||||
if (response.statusCode != 200) {
|
if (response.statusCode != 200) {
|
||||||
throw getObtainiumHttpError(response);
|
throw getObtainiumHttpError(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = jsonDecode(response.body);
|
var json = jsonDecode(response.body);
|
||||||
if (json['id'] == null) {
|
if (json['id'] == null) {
|
||||||
throw NoReleasesError();
|
throw NoReleasesError();
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String parseVivoAppId(String url) {
|
||||||
|
var appId = Uri.parse(url.replaceAll('/#', '')).queryParameters['appId'];
|
||||||
|
if (appId == null) {
|
||||||
|
throw InvalidURLError(name);
|
||||||
|
}
|
||||||
|
return appId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user