mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-16 22:56:44 +02:00
Added VLC as a Source
This commit is contained in:
@ -20,6 +20,7 @@ Currently supported App sources:
|
|||||||
- Any URLs ending with `/fdroid/<word>`, where `<word>` can be anything - most often `repo`
|
- Any URLs ending with `/fdroid/<word>`, where `<word>` can be anything - most often `repo`
|
||||||
- [Steam](https://store.steampowered.com/mobile)
|
- [Steam](https://store.steampowered.com/mobile)
|
||||||
- [Telegram App](https://telegram.org)
|
- [Telegram App](https://telegram.org)
|
||||||
|
- [VLC](https://www.videolan.org/vlc/download-android.html)
|
||||||
- [Neutron Code](https://neutroncode.com)
|
- [Neutron Code](https://neutroncode.com)
|
||||||
- "HTML" (Fallback)
|
- "HTML" (Fallback)
|
||||||
- Any other URL that returns an HTML page with links to APK files (if multiple, the last file alphabetically is picked)
|
- Any other URL that returns an HTML page with links to APK files (if multiple, the last file alphabetically is picked)
|
||||||
|
62
lib/app_sources/vlc.dart
Normal file
62
lib/app_sources/vlc.dart
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import 'package:html/parser.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:obtainium/app_sources/html.dart';
|
||||||
|
import 'package:obtainium/custom_errors.dart';
|
||||||
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
|
|
||||||
|
class VLC extends AppSource {
|
||||||
|
VLC() {
|
||||||
|
host = 'videolan.org';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String standardizeURL(String url) {
|
||||||
|
return 'https://$host';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<APKDetails> getLatestAPKDetails(
|
||||||
|
String standardUrl,
|
||||||
|
Map<String, dynamic> additionalSettings,
|
||||||
|
) async {
|
||||||
|
Response res = await get(
|
||||||
|
Uri.parse('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) {
|
||||||
|
throw NoVersionError();
|
||||||
|
}
|
||||||
|
String? targetUrl = 'https://$dwUrlBase/$version/';
|
||||||
|
Response res2 = await get(Uri.parse(targetUrl));
|
||||||
|
String mirrorDwBase =
|
||||||
|
'https://plug-mirror.rcac.purdue.edu/vlc/vlc-android/$version/';
|
||||||
|
List<String> apkUrls = [];
|
||||||
|
if (res2.statusCode == 200) {
|
||||||
|
apkUrls = parse(res2.body)
|
||||||
|
.querySelectorAll('a')
|
||||||
|
.map((e) => e.attributes['href'])
|
||||||
|
.where((h) =>
|
||||||
|
h != null && h.isNotEmpty && h.toLowerCase().endsWith('.apk'))
|
||||||
|
.map((e) => mirrorDwBase + e!)
|
||||||
|
.toList();
|
||||||
|
} else {
|
||||||
|
throw getObtainiumHttpError(res2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return APKDetails(version, apkUrls, AppNames('VideoLAN', 'VLC'));
|
||||||
|
} else {
|
||||||
|
throw getObtainiumHttpError(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@ import 'package:obtainium/app_sources/signal.dart';
|
|||||||
import 'package:obtainium/app_sources/sourceforge.dart';
|
import 'package:obtainium/app_sources/sourceforge.dart';
|
||||||
import 'package:obtainium/app_sources/steammobile.dart';
|
import 'package:obtainium/app_sources/steammobile.dart';
|
||||||
import 'package:obtainium/app_sources/telegramapp.dart';
|
import 'package:obtainium/app_sources/telegramapp.dart';
|
||||||
|
import 'package:obtainium/app_sources/vlc.dart';
|
||||||
import 'package:obtainium/components/generated_form.dart';
|
import 'package:obtainium/components/generated_form.dart';
|
||||||
import 'package:obtainium/custom_errors.dart';
|
import 'package:obtainium/custom_errors.dart';
|
||||||
import 'package:obtainium/mass_app_sources/githubstars.dart';
|
import 'package:obtainium/mass_app_sources/githubstars.dart';
|
||||||
@ -348,6 +349,7 @@ class SourceProvider {
|
|||||||
FDroidRepo(),
|
FDroidRepo(),
|
||||||
SteamMobile(),
|
SteamMobile(),
|
||||||
TelegramApp(),
|
TelegramApp(),
|
||||||
|
VLC(),
|
||||||
NeutronCode(),
|
NeutronCode(),
|
||||||
HTML() // This should ALWAYS be the last option as they are tried in order
|
HTML() // This should ALWAYS be the last option as they are tried in order
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user