mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-16 22:56:44 +02:00
Auto-select direct APK source for URLs ending in '.apk' (#1820)
This commit is contained in:
@ -10,7 +10,7 @@ class APKCombo extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+[^/]+',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -32,7 +32,7 @@ class APKMirror extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/apk/[^/]+/[^/]+',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}/apk/[^/]+/[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -29,7 +29,7 @@ class APKPure extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegExB = RegExp(
|
RegExp standardUrlRegExB = RegExp(
|
||||||
'^https?://m.${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
|
'^https?://m.${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -14,7 +14,7 @@ class Aptoide extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}',
|
'^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -16,7 +16,7 @@ class Codeberg extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:obtainium/app_sources/html.dart';
|
import 'package:obtainium/app_sources/html.dart';
|
||||||
|
import 'package:obtainium/custom_errors.dart';
|
||||||
import 'package:obtainium/providers/source_provider.dart';
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
|
|
||||||
class DirectAPKLink extends AppSource {
|
class DirectAPKLink extends AppSource {
|
||||||
HTML html = HTML();
|
HTML html = HTML();
|
||||||
|
|
||||||
DirectAPKLink() {
|
DirectAPKLink() {
|
||||||
neverAutoSelect = true;
|
|
||||||
name = tr('directAPKLink');
|
name = tr('directAPKLink');
|
||||||
additionalSourceAppSpecificSettingFormItems = html
|
additionalSourceAppSpecificSettingFormItems = html
|
||||||
.additionalSourceAppSpecificSettingFormItems
|
.additionalSourceAppSpecificSettingFormItems
|
||||||
@ -24,6 +24,20 @@ class DirectAPKLink extends AppSource {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
|
print('AAA');
|
||||||
|
if (!forSelection) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
RegExp standardUrlRegExA = RegExp('.+\\.apk\$', caseSensitive: false);
|
||||||
|
var match = standardUrlRegExA.firstMatch(url);
|
||||||
|
if (match == null) {
|
||||||
|
throw InvalidURLError(name);
|
||||||
|
}
|
||||||
|
return match.group(0)!;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Map<String, String>?> getRequestHeaders(
|
Future<Map<String, String>?> getRequestHeaders(
|
||||||
Map<String, dynamic> additionalSettings,
|
Map<String, dynamic> additionalSettings,
|
||||||
|
@ -38,7 +38,7 @@ class FDroid extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegExB = RegExp(
|
RegExp standardUrlRegExB = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+packages/+[^/]+',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+packages/+[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -43,7 +43,7 @@ class FDroidRepo extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
var standardUri = Uri.parse(url);
|
var standardUri = Uri.parse(url);
|
||||||
var pathSegments = standardUri.pathSegments;
|
var pathSegments = standardUri.pathSegments;
|
||||||
if (pathSegments.isNotEmpty && pathSegments.last == 'index.xml') {
|
if (pathSegments.isNotEmpty && pathSegments.last == 'index.xml') {
|
||||||
|
@ -154,7 +154,7 @@ class GitHub extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -52,7 +52,7 @@ class GitLab extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -288,7 +288,7 @@ class HTML extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class HuaweiAppGallery extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}(/#)?/(app|appdl)/[^/]+',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}(/#)?/(app|appdl)/[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -14,7 +14,7 @@ class IzzyOnDroid extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegExA = RegExp(
|
RegExp standardUrlRegExA = RegExp(
|
||||||
'^https?://android.${getSourceRegex(hosts)}/repo/apk/[^/]+',
|
'^https?://android.${getSourceRegex(hosts)}/repo/apk/[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -10,7 +10,7 @@ class Mullvad extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -10,7 +10,7 @@ class NeutronCode extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/downloads/file/[^/]+',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}/downloads/file/[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -9,7 +9,7 @@ class Signal extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
return 'https://${hosts[0]}';
|
return 'https://${hosts[0]}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class SourceForge extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
var sourceRegex = getSourceRegex(hosts);
|
var sourceRegex = getSourceRegex(hosts);
|
||||||
RegExp standardUrlRegExC =
|
RegExp standardUrlRegExC =
|
||||||
RegExp('^https?://(www\\.)?$sourceRegex/p/.+', caseSensitive: false);
|
RegExp('^https?://(www\\.)?$sourceRegex/p/.+', caseSensitive: false);
|
||||||
|
@ -20,7 +20,7 @@ class SourceHut extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -20,7 +20,7 @@ class SteamMobile extends AppSource {
|
|||||||
final apks = {'steam': tr('steamMobile'), 'steam-chat-app': tr('steamChat')};
|
final apks = {'steam': tr('steamMobile'), 'steam-chat-app': tr('steamChat')};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
return 'https://${hosts[0]}';
|
return 'https://${hosts[0]}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class TelegramApp extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
return 'https://${hosts[0]}';
|
return 'https://${hosts[0]}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class Uptodown extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
RegExp standardUrlRegEx = RegExp(
|
RegExp standardUrlRegEx = RegExp(
|
||||||
'^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}',
|
'^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}',
|
||||||
caseSensitive: false);
|
caseSensitive: false);
|
||||||
|
@ -21,7 +21,7 @@ class VLC extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
return 'https://${hosts[0]}';
|
return 'https://${hosts[0]}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class WhatsApp extends AppSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
return 'https://${hosts[0]}';
|
return 'https://${hosts[0]}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +472,7 @@ abstract class AppSource {
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
String sourceSpecificStandardizeURL(String url) {
|
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||||
throw NotImplementedError();
|
throw NotImplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,7 +809,7 @@ class SourceProvider {
|
|||||||
for (var s in sources.where(
|
for (var s in sources.where(
|
||||||
(element) => element.hosts.isEmpty && !element.neverAutoSelect)) {
|
(element) => element.hosts.isEmpty && !element.neverAutoSelect)) {
|
||||||
try {
|
try {
|
||||||
s.sourceSpecificStandardizeURL(url);
|
s.sourceSpecificStandardizeURL(url, forSelection: true);
|
||||||
source = s;
|
source = s;
|
||||||
break;
|
break;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Reference in New Issue
Block a user