Skip to content

Commit

Permalink
Merge pull request #835 from ImranR98/dev
Browse files Browse the repository at this point in the history
VLC: Postpone mirror-dependent request until download time (#821)
  • Loading branch information
ImranR98 authored Aug 30, 2023
2 parents 917c5f5 + 3d7df60 commit 4b63c12
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 105 deletions.
46 changes: 17 additions & 29 deletions lib/app_sources/vlc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,10 @@ class VLC extends AppSource {
if (version == null) {
throw NoVersionError();
}

String? targetUrl = 'https://$dwUrlBase/$version/';
Response res2 = await get(Uri.parse(targetUrl));
List<String> apkUrls = [];
if (res2.statusCode == 200) {
apkUrls = parse(res2.body)
.querySelectorAll('a')
.map((e) => e.attributes['href']?.split('/').last)
.where((h) =>
h != null && h.isNotEmpty && h.toLowerCase().endsWith('.apk'))
.map((e) => targetUrl + e!)
.toList();
} else if (res2.statusCode == 500 &&
res2.body.toLowerCase().indexOf('mirror') > 0) {
var html = parse(res2.body);
var err = '';
html.body?.nodes.forEach((element) {
if (element.text != null) {
err += '${element.text}\n';
}
});
err = err.trim();
if (err.isEmpty) {
err = tr('err');
}
throw ObtainiumError(err);
} else {
throw getObtainiumHttpError(res2);
}

var apkUrls = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
.map((e) => '${targetUrl}VLC-Android-$version-$e.apk')
.toList();
return APKDetails(
version, getApkUrlsFromUrls(apkUrls), AppNames('VideoLAN', 'VLC'));
} else {
Expand All @@ -108,6 +82,20 @@ class VLC extends AppSource {
throw NoAPKError();
}
return apkUrl;
} else if (res.statusCode == 500 &&
res.body.toLowerCase().indexOf('mirror') > 0) {
var html = parse(res.body);
var err = '';
html.body?.nodes.forEach((element) {
if (element.text != null) {
err += '${element.text}\n';
}
});
err = err.trim();
if (err.isEmpty) {
err = tr('err');
}
throw ObtainiumError(err);
} else {
throw getObtainiumHttpError(res);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
// ignore: implementation_imports
import 'package:easy_localization/src/localization.dart';

const String currentVersion = '0.14.4';
const String currentVersion = '0.14.5';
const String currentReleaseTag =
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES

Expand Down
Loading

0 comments on commit 4b63c12

Please sign in to comment.