mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-17 20:28:10 +02:00
Added "skip latest" option to APKPure (also fallback toggle)
This commit is contained in:
@@ -315,6 +315,7 @@
|
||||
"wiki": "Pomoć/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Konfiguracije aplikacije obezbeđene pomoću velikog broja ljudi (crowdsourcing) (koristite na svoju odgovornost)",
|
||||
"allowInsecure": "Allow insecure HTTP requests",
|
||||
"stayOneVersionBehind": "Stay one version behind latest",
|
||||
"removeAppQuestion": {
|
||||
"one": "Želite li ukloniti aplikaciju?",
|
||||
"other": "Želite li ukloniti aplikacije?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Nápověda/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Konfigurace aplikací s využitím crowdsourcingu (použití na vlastní nebezpečí)",
|
||||
"allowInsecure": "Povolení nezabezpečených požadavků HTTP",
|
||||
"stayOneVersionBehind": "Zůstaňte o jednu verzi pozadu za nejnovější",
|
||||
"removeAppQuestion": {
|
||||
"one": "Odstranit Apku?",
|
||||
"other": "Odstranit Apky?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Hjælp/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Crowdsourcede app-konfigurationer (brug på egen risiko)",
|
||||
"allowInsecure": "Tillad usikre HTTP-anmodninger",
|
||||
"stayOneVersionBehind": "Vær en version bagud i forhold til den nyeste",
|
||||
"removeAppQuestion": {
|
||||
"one": "Fjern app?",
|
||||
"other": "Fjern apps?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Hilfe/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Crowdsourced App-Konfigurationen (Verwendung auf eigene Gefahr)",
|
||||
"allowInsecure": "Unsichere HTTP-Anfragen zulassen",
|
||||
"stayOneVersionBehind": "Eine Version hinter der neuesten Version bleiben",
|
||||
"removeAppQuestion": {
|
||||
"one": "App entfernen?",
|
||||
"other": "Apps entfernen?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Helpo/Vikio",
|
||||
"crowdsourcedConfigsLabel": "Komunumaj apo-agordoj (uzu kun singardo)",
|
||||
"allowInsecure": "Allow insecure HTTP requests",
|
||||
"stayOneVersionBehind": "Stay one version behind latest",
|
||||
"removeAppQuestion": {
|
||||
"one": "Forigi la aplikaĵon?",
|
||||
"other": "Forigi la aplikaĵojn?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Help/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Crowdsourced App Configurations (use at your own risk)",
|
||||
"allowInsecure": "Allow insecure HTTP requests",
|
||||
"stayOneVersionBehind": "Stay one version behind latest",
|
||||
"removeAppQuestion": {
|
||||
"one": "Remove App?",
|
||||
"other": "Remove Apps?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Ayuda/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Crowdsourced App Configurations (uso bajo su propia responsabilidad)",
|
||||
"allowInsecure": "Permitir peticiones HTTP inseguras",
|
||||
"stayOneVersionBehind": "Mantenerse una versión por detrás de la última",
|
||||
"removeAppQuestion": {
|
||||
"one": "¿Eliminar aplicación?",
|
||||
"other": "¿Eliminar aplicaciones?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "راهنما/ویکی",
|
||||
"crowdsourcedConfigsLabel": "تنظیمات برنامه Crowdsourced (با مسئولیت خود استفاده کنید)",
|
||||
"allowInsecure": "درخواست های HTTP ناامن را مجاز کنید",
|
||||
"stayOneVersionBehind": "Stay one version behind latest",
|
||||
"removeAppQuestion": {
|
||||
"one": "برنامه حذف شود؟",
|
||||
"other": "برنامه ها حذف شوند؟"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Aide/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Configurations d'applications par la communauté (à utiliser à vos risques et périls)",
|
||||
"allowInsecure": "Autoriser les requêtes HTTP non sécurisées",
|
||||
"stayOneVersionBehind": "Rester à une version de la dernière",
|
||||
"removeAppQuestion": {
|
||||
"one": "Supprimer l'application ?",
|
||||
"other": "Supprimer les applications ?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Súgó/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Crowdsource-ből származó alkalmazások beállítása (saját felelősségére használja)",
|
||||
"allowInsecure": "Nem biztonságos HTTP-kérések engedélyezése",
|
||||
"stayOneVersionBehind": "Maradjon egy verzióval a legfrissebb mögött",
|
||||
"removeAppQuestion": {
|
||||
"one": "Eltávolítja az alkalmazást?",
|
||||
"other": "Eltávolítja az alkalmazásokat?"
|
||||
|
@@ -204,7 +204,7 @@
|
||||
"categoryDeleteWarning": "Semua aplikasi dalam kategori yang dihapus akan diatur sebagai tidak terkategori.",
|
||||
"addCategory": "Tambah kategori",
|
||||
"label": "Label",
|
||||
"language": "Language",
|
||||
"language": "Bahasa",
|
||||
"copiedToClipboard": "Disalin ke papan klip",
|
||||
"storagePermissionDenied": "Izin penyimpanan ditolak",
|
||||
"selectedCategorizeWarning": "Ini akan mengganti pengaturan kategori yang ada untuk aplikasi terpilih.",
|
||||
@@ -315,6 +315,7 @@
|
||||
"wiki": "Bantuan/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Konfigurasi aplikasi Crowdsourced (risiko penggunaan ditanggung sendiri)",
|
||||
"allowInsecure": "Izinkan permintaan HTTP yang tidak aman",
|
||||
"stayOneVersionBehind": "Tetap satu versi di belakang versi terbaru",
|
||||
"removeAppQuestion": {
|
||||
"one": "Hapus aplikasi?",
|
||||
"other": "Hapus aplikasi?"
|
||||
@@ -375,4 +376,4 @@
|
||||
"one": "{} APK",
|
||||
"other": "{} APK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Aiuto/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Configurazioni di app in crowdsourcing (uso a proprio rischio)",
|
||||
"allowInsecure": "Consentire le richieste HTTP non sicure",
|
||||
"stayOneVersionBehind": "Rimanere una versione indietro rispetto alla più recente",
|
||||
"removeAppQuestion": {
|
||||
"one": "Rimuovere l'app?",
|
||||
"other": "Rimuovere le app?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "ヘルプ/ウィキ",
|
||||
"crowdsourcedConfigsLabel": "クラウドソーシングによるアプリの設定(利用は自己責任で)",
|
||||
"allowInsecure": "安全でないHTTPリクエストを許可する",
|
||||
"stayOneVersionBehind": "最新バージョンから1つ遅れ",
|
||||
"removeAppQuestion": {
|
||||
"one": "アプリを削除しますか?",
|
||||
"other": "アプリを削除しますか?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Help/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Crowdsourced App-configuraties (gebruik op eigen risico)",
|
||||
"allowInsecure": "Onveilige HTTP-verzoeken toestaan",
|
||||
"stayOneVersionBehind": "Blijf een versie achter op de nieuwste",
|
||||
"removeAppQuestion": {
|
||||
"one": "App verwijderen?",
|
||||
"other": "Apps verwijderen?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Pomoc/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Konfiguracje aplikacji pochodzące z crowdsourcingu (korzystanie na własne ryzyko)",
|
||||
"allowInsecure": "Zezwalaj na niezabezpieczone żądania HTTP",
|
||||
"stayOneVersionBehind": "Pozostań jedną wersję za najnowszą",
|
||||
"removeAppQuestion": {
|
||||
"one": "Usunąć aplikację?",
|
||||
"few": "Usunąć aplikacje?",
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Ajuda/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Configurações de aplicações de crowdsourcing (utilização por sua conta e risco)",
|
||||
"allowInsecure": "Permitir pedidos HTTP inseguros",
|
||||
"stayOneVersionBehind": "Manter-se uma versão atrás da mais recente",
|
||||
"removeAppQuestion": {
|
||||
"one": "Remover aplicativo?",
|
||||
"other": "Remover aplicativos?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Помощь/Вики",
|
||||
"crowdsourcedConfigsLabel": "Конфигурации приложений на основе краудсорсинга (используйте на свой страх и риск)",
|
||||
"allowInsecure": "Разрешить небезопасные HTTP-запросы",
|
||||
"stayOneVersionBehind": "Не отставайте от последней версии",
|
||||
"removeAppQuestion": {
|
||||
"one": "Удалить приложение?",
|
||||
"other": "Удалить приложения?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Hjälp/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Crowdsourcade appkonfigurationer (använd på egen risk)",
|
||||
"allowInsecure": "Tillåt osäkra HTTP-förfrågningar",
|
||||
"stayOneVersionBehind": "Håll dig en version bakom den senaste",
|
||||
"removeAppQuestion": {
|
||||
"one": "Ta Bort App?",
|
||||
"other": "Ta Bort Appar?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Yardım/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Kitle Kaynaklı Uygulama Yapılandırmaları (riski size ait olmak üzere kullanın)",
|
||||
"allowInsecure": "Güvensiz HTTP isteklerine izin ver",
|
||||
"stayOneVersionBehind": "En son sürümün bir sürüm gerisinde kalın",
|
||||
"removeAppQuestion": {
|
||||
"one": "Uygulamayı Kaldır?",
|
||||
"other": "Uygulamaları Kaldır?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Довідка/Вікі",
|
||||
"crowdsourcedConfigsLabel": "Краудсорсингові конфігурації додатків (використовуйте на свій страх і ризик)",
|
||||
"allowInsecure": "Дозволити незахищені HTTP-запити",
|
||||
"stayOneVersionBehind": "Залишайтеся на одну версію актуальнішою",
|
||||
"removeAppQuestion": {
|
||||
"one": "Видалити застосунок?",
|
||||
"other": "Видалити застосунки?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "Trợ giúp/Wiki",
|
||||
"crowdsourcedConfigsLabel": "Crowdsourced App Configurations (use at your own risk)",
|
||||
"allowInsecure": "Allow insecure HTTP requests",
|
||||
"stayOneVersionBehind": "Stay one version behind latest",
|
||||
"removeAppQuestion": {
|
||||
"one": "Gỡ ứng dụng?",
|
||||
"other": "Gỡ ứng dụng?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "幫助/維基",
|
||||
"crowdsourcedConfigsLabel": "群眾外包的應用程式設定(使用風險自負)",
|
||||
"allowInsecure": "Allow insecure HTTP requests",
|
||||
"stayOneVersionBehind": "Stay one version behind latest",
|
||||
"removeAppQuestion": {
|
||||
"one": "移除應用程式?",
|
||||
"other": "移除應用程式?"
|
||||
|
@@ -315,6 +315,7 @@
|
||||
"wiki": "帮助/Wiki",
|
||||
"crowdsourcedConfigsLabel": "众包应用程序配置(使用风险自负)",
|
||||
"allowInsecure": "允许不安全的 HTTP 请求",
|
||||
"stayOneVersionBehind": "比最新版本晚一个版本",
|
||||
"removeAppQuestion": {
|
||||
"one": "是否删除应用?",
|
||||
"other": "是否删除应用?"
|
||||
|
@@ -2,6 +2,7 @@ import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:obtainium/app_sources/html.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
|
||||
@@ -26,6 +27,16 @@ class APKPure extends AppSource {
|
||||
allowSubDomains = true;
|
||||
naiveStandardVersionDetection = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
GeneratedFormSwitch('fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'), defaultValue: true)
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('stayOneVersionBehind',
|
||||
label: tr('stayOneVersionBehind'), defaultValue: false)
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -54,6 +65,97 @@ class APKPure extends AppSource {
|
||||
return Uri.parse(standardUrl).pathSegments.last;
|
||||
}
|
||||
|
||||
getDetailsForVersionLink(
|
||||
String standardUrl,
|
||||
String appId,
|
||||
String host,
|
||||
List<String> supportedArchs,
|
||||
String link,
|
||||
Map<String, dynamic> additionalSettings) async {
|
||||
var res = await sourceRequest(link, additionalSettings);
|
||||
if (res.statusCode == 200) {
|
||||
var html = parse(res.body);
|
||||
var apksDiv =
|
||||
html.querySelector('#version-list div div.show-more-content');
|
||||
DateTime? topReleaseDate;
|
||||
var apkUrls = apksDiv
|
||||
?.querySelectorAll('div.group-title')
|
||||
.map((e) {
|
||||
String architectureString = e.text.trim();
|
||||
if (architectureString.toLowerCase() == 'unlimited' ||
|
||||
architectureString.toLowerCase() == 'universal') {
|
||||
architectureString = '';
|
||||
}
|
||||
List<String> architectures = architectureString
|
||||
.split(',')
|
||||
.map((e) => e.trim())
|
||||
.where((e) => e.isNotEmpty)
|
||||
.toList();
|
||||
// Only take the first APK for each architecture, ignore others for now, for simplicity
|
||||
// Unclear why there can even be multiple APKs for the same version and arch
|
||||
var apkInfo = e.nextElementSibling?.querySelector('div.info');
|
||||
String? versionCode = RegExp('[0-9]+')
|
||||
.firstMatch(apkInfo
|
||||
?.querySelector('div.info-top span.code')
|
||||
?.text ??
|
||||
'')
|
||||
?.group(0)
|
||||
?.trim();
|
||||
var types = apkInfo
|
||||
?.querySelectorAll('div.info-top span.tag')
|
||||
.map((e) => e.text.trim())
|
||||
.map((t) => t == 'APKs' ? 'APK' : t) ??
|
||||
[];
|
||||
String type = types.isEmpty
|
||||
? 'APK'
|
||||
: types.length == 1
|
||||
? types.first
|
||||
: types.last;
|
||||
String? dateString = apkInfo
|
||||
?.querySelector('div.info-bottom span.time')
|
||||
?.text
|
||||
.trim();
|
||||
DateTime? releaseDate = parseDateTimeMMMddCommayyyy(dateString);
|
||||
if (additionalSettings['autoApkFilterByArch'] == true &&
|
||||
architectures.isNotEmpty &&
|
||||
architectures
|
||||
.where((a) => supportedArchs.contains(a))
|
||||
.isEmpty) {
|
||||
return const MapEntry('', '');
|
||||
}
|
||||
topReleaseDate ??=
|
||||
releaseDate; // Just use the release date of the first APK in the list as the release date for this version
|
||||
return MapEntry(
|
||||
'$appId-$versionCode-$architectureString.${type.toLowerCase()}',
|
||||
'https://d.${hosts.contains(host) ? 'cdnpure.com' : host}/b/$type/$appId?versionCode=$versionCode');
|
||||
})
|
||||
.where((e) => e.key.isNotEmpty)
|
||||
.toList() ??
|
||||
[];
|
||||
if (apkUrls.isEmpty) {
|
||||
throw NoAPKError();
|
||||
}
|
||||
String version = Uri.parse(link).pathSegments.last;
|
||||
String author = html
|
||||
.querySelector('span.info-sdk')
|
||||
?.text
|
||||
.trim()
|
||||
.substring(version.length + 4) ??
|
||||
Uri.parse(standardUrl).pathSegments.reversed.last;
|
||||
String appName =
|
||||
html.querySelector('h1.info-title')?.text.trim() ?? appId;
|
||||
String? changeLog = html
|
||||
.querySelector('div.module.change-log')
|
||||
?.innerHtml
|
||||
.trim()
|
||||
.replaceAll("<br>", " \n");
|
||||
return APKDetails(version, apkUrls, AppNames(author, appName),
|
||||
releaseDate: topReleaseDate, changeLog: changeLog);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<APKDetails> getLatestAPKDetails(
|
||||
String standardUrl,
|
||||
@@ -80,88 +182,17 @@ class APKPure extends AppSource {
|
||||
|
||||
for (var i = 0; i < versionLinks.length; i++) {
|
||||
var link = versionLinks[i];
|
||||
var res = await sourceRequest(link.key, additionalSettings);
|
||||
if (res.statusCode == 200) {
|
||||
var html = parse(res.body);
|
||||
var apksDiv =
|
||||
html.querySelector('#version-list div div.show-more-content');
|
||||
DateTime? topReleaseDate;
|
||||
var apkUrls = apksDiv
|
||||
?.querySelectorAll('div.group-title')
|
||||
.map((e) {
|
||||
String architectureString = e.text.trim();
|
||||
if (architectureString.toLowerCase() == 'unlimited' ||
|
||||
architectureString.toLowerCase() == 'universal') {
|
||||
architectureString = '';
|
||||
}
|
||||
List<String> architectures = architectureString
|
||||
.split(',')
|
||||
.map((e) => e.trim())
|
||||
.where((e) => e.isNotEmpty)
|
||||
.toList();
|
||||
// Only take the first APK for each architecture, ignore others for now, for simplicity
|
||||
// Unclear why there can even be multiple APKs for the same version and arch
|
||||
var apkInfo = e.nextElementSibling?.querySelector('div.info');
|
||||
String? versionCode = RegExp('[0-9]+')
|
||||
.firstMatch(apkInfo
|
||||
?.querySelector('div.info-top span.code')
|
||||
?.text ??
|
||||
'')
|
||||
?.group(0)
|
||||
?.trim();
|
||||
var types = apkInfo
|
||||
?.querySelectorAll('div.info-top span.tag')
|
||||
.map((e) => e.text.trim())
|
||||
.map((t) => t == 'APKs' ? 'APK' : t) ??
|
||||
[];
|
||||
String type = types.isEmpty
|
||||
? 'APK'
|
||||
: types.length == 1
|
||||
? types.first
|
||||
: types.last;
|
||||
String? dateString = apkInfo
|
||||
?.querySelector('div.info-bottom span.time')
|
||||
?.text
|
||||
.trim();
|
||||
DateTime? releaseDate =
|
||||
parseDateTimeMMMddCommayyyy(dateString);
|
||||
if (additionalSettings['autoApkFilterByArch'] == true &&
|
||||
architectures.isNotEmpty &&
|
||||
architectures
|
||||
.where((a) => supportedArchs.contains(a))
|
||||
.isEmpty) {
|
||||
return const MapEntry('', '');
|
||||
}
|
||||
topReleaseDate ??=
|
||||
releaseDate; // Just use the release date of the first APK in the list as the release date for this version
|
||||
return MapEntry(
|
||||
'$appId-$versionCode-$architectureString.${type.toLowerCase()}',
|
||||
'https://d.${hosts.contains(host) ? 'cdnpure.com' : host}/b/$type/$appId?versionCode=$versionCode');
|
||||
})
|
||||
.where((e) => e.key.isNotEmpty)
|
||||
.toList() ??
|
||||
[];
|
||||
if (apkUrls.isEmpty) {
|
||||
continue;
|
||||
try {
|
||||
if (i == 0 && additionalSettings['stayOneVersionBehind'] == true) {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
return await getDetailsForVersionLink(standardUrl, appId, host,
|
||||
supportedArchs, link.key, additionalSettings);
|
||||
} catch (e) {
|
||||
if (additionalSettings['fallbackToOlderReleases'] != true ||
|
||||
i == versionLinks.length - 1) {
|
||||
rethrow;
|
||||
}
|
||||
String version = Uri.parse(link.key).pathSegments.last;
|
||||
String author = html
|
||||
.querySelector('span.info-sdk')
|
||||
?.text
|
||||
.trim()
|
||||
.substring(version.length + 4) ??
|
||||
Uri.parse(standardUrl).pathSegments.reversed.last;
|
||||
String appName =
|
||||
html.querySelector('h1.info-title')?.text.trim() ?? appId;
|
||||
String? changeLog = html
|
||||
.querySelector('div.module.change-log')
|
||||
?.innerHtml
|
||||
.trim()
|
||||
.replaceAll("<br>", " \n");
|
||||
return APKDetails(version, apkUrls, AppNames(author, appName),
|
||||
releaseDate: topReleaseDate, changeLog: changeLog);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
}
|
||||
throw NoAPKError();
|
||||
|
Reference in New Issue
Block a user