Added LiteAPKs as a source (#1799)

This commit is contained in:
Imran Remtulla
2025-08-30 23:59:21 -04:00
parent 9ac963557e
commit 5b147b82e0
2 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
import 'dart:convert';
import 'package:http/http.dart';
import 'package:obtainium/custom_errors.dart';
import 'package:obtainium/providers/source_provider.dart';
class LiteAPKs extends AppSource {
LiteAPKs() {
hosts = ['liteapks.com'];
name = 'LiteAPKs';
}
@override
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
RegExp standardUrlRegEx = RegExp(
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+',
caseSensitive: false,
);
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
if (match == null) {
throw InvalidURLError(name);
}
return match.group(0)!;
}
@override
Future<APKDetails> getLatestAPKDetails(
String standardUrl,
Map<String, dynamic> additionalSettings,
) async {
var standardUri = Uri.parse(standardUrl);
var slug = standardUri.path
.split('.')
.reversed
.toList()
.sublist(1)
.reversed
.join('.');
Response res1 = await sourceRequest(
'${standardUri.origin}/wp-json/wp/v2/posts?slug=$slug',
additionalSettings,
);
if (res1.statusCode != 200) {
throw getObtainiumHttpError(res1);
}
var liteAppId = jsonDecode(res1.body)[0]['id'];
if (liteAppId == null) {
throw NoReleasesError();
}
Response res2 = await sourceRequest(
'${standardUri.origin}/wp-json/v2/posts/$liteAppId',
additionalSettings,
);
if (res2.statusCode != 200) {
throw getObtainiumHttpError(res2);
}
var json = jsonDecode(res2.body);
var appName = json['data']?['title'] as String?;
var author = json['data']?['publisher'] as String?;
var version = json['data']?['versions']?[0]?['version'] as String?;
if (version == null) {
throw NoVersionError();
}
var apkUrls =
((json['data']?['versions']?[0]?['version_downloads'] as List<dynamic>?)
?.map((l) => l['version_download_link']) ??
[])
.map(
(l) => MapEntry<String, String>(
Uri.decodeComponent(Uri.parse(l).pathSegments.last),
l,
),
)
.toList();
return APKDetails(
version,
apkUrls,
AppNames(
author ?? Uri.parse(standardUrl).host,
appName ?? standardUrl.split('/').last,
),
);
}
}

View File

@@ -25,6 +25,7 @@ import 'package:obtainium/app_sources/huaweiappgallery.dart';
import 'package:obtainium/app_sources/izzyondroid.dart';
import 'package:obtainium/app_sources/html.dart';
import 'package:obtainium/app_sources/jenkins.dart';
import 'package:obtainium/app_sources/liteapks.dart';
import 'package:obtainium/app_sources/neutroncode.dart';
import 'package:obtainium/app_sources/rustore.dart';
import 'package:obtainium/app_sources/sourceforge.dart';
@@ -1076,6 +1077,7 @@ class SourceProvider {
HuaweiAppGallery(),
Tencent(),
CoolApk(),
LiteAPKs(),
VivoAppStore(),
Jenkins(),
APKMirror(),