mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-12 01:50:15 +02:00
Add dynamic mirror picking to VLC (#715)
This commit is contained in:
@@ -38,16 +38,14 @@ class VLC extends AppSource {
|
|||||||
}
|
}
|
||||||
String? targetUrl = 'https://$dwUrlBase/$version/';
|
String? targetUrl = 'https://$dwUrlBase/$version/';
|
||||||
Response res2 = await sourceRequest(targetUrl);
|
Response res2 = await sourceRequest(targetUrl);
|
||||||
String mirrorDwBase =
|
|
||||||
'https://plug-mirror.rcac.purdue.edu/vlc/vlc-android/$version/';
|
|
||||||
List<String> apkUrls = [];
|
List<String> apkUrls = [];
|
||||||
if (res2.statusCode == 200) {
|
if (res2.statusCode == 200) {
|
||||||
apkUrls = parse(res2.body)
|
apkUrls = parse(res2.body)
|
||||||
.querySelectorAll('a')
|
.querySelectorAll('a')
|
||||||
.map((e) => e.attributes['href'])
|
.map((e) => e.attributes['href']?.split('/').last)
|
||||||
.where((h) =>
|
.where((h) =>
|
||||||
h != null && h.isNotEmpty && h.toLowerCase().endsWith('.apk'))
|
h != null && h.isNotEmpty && h.toLowerCase().endsWith('.apk'))
|
||||||
.map((e) => mirrorDwBase + e!)
|
.map((e) => targetUrl + e!)
|
||||||
.toList();
|
.toList();
|
||||||
} else {
|
} else {
|
||||||
throw getObtainiumHttpError(res2);
|
throw getObtainiumHttpError(res2);
|
||||||
@@ -59,4 +57,20 @@ class VLC extends AppSource {
|
|||||||
throw getObtainiumHttpError(res);
|
throw getObtainiumHttpError(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> apkUrlPrefetchModifier(
|
||||||
|
String apkUrl, String standardUrl) async {
|
||||||
|
Response res = await sourceRequest(apkUrl);
|
||||||
|
if (res.statusCode == 200) {
|
||||||
|
String? apkUrl =
|
||||||
|
parse(res.body).querySelector('#alt_link')?.attributes['href'];
|
||||||
|
if (apkUrl == null) {
|
||||||
|
throw NoAPKError();
|
||||||
|
}
|
||||||
|
return apkUrl;
|
||||||
|
} else {
|
||||||
|
throw getObtainiumHttpError(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user