mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-27 11:43:47 +01:00 
			
		
		
		
	Add "Intermediate Link" option to HTML Source (#820)
This commit is contained in:
		| @@ -240,7 +240,7 @@ | ||||
|    "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", | ||||
|    "sortByFileNamesNotLinks": "Sort by file names instead of full links", | ||||
|    "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", | ||||
|    "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", | ||||
|    "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", | ||||
|    "appsPossiblyUpdated": "App Updates Attempted", | ||||
|    "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", | ||||
|    "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", | ||||
|   | ||||
| @@ -240,7 +240,7 @@ | ||||
|     "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", | ||||
|     "sortByFileNamesNotLinks": "Sort by file names instead of full links", | ||||
|     "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", | ||||
|     "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "appsPossiblyUpdated": "App Updates Attempted", | ||||
|     "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", | ||||
|     "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", | ||||
| @@ -248,6 +248,8 @@ | ||||
|     "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", | ||||
|     "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", | ||||
|     "verifyLatestTag": "Verify the 'latest' tag", | ||||
|     "intermediateLinkRegex": "Filter for an 'Intermediate' Link to Visit First", | ||||
|     "intermediateLinkNotFound": "Intermediate link not found", | ||||
|     "removeAppQuestion": { | ||||
|         "one": "Remove App?", | ||||
|         "other": "Remove Apps?" | ||||
|   | ||||
| @@ -240,7 +240,7 @@ | ||||
|     "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", | ||||
|     "sortByFileNamesNotLinks": "Sort by file names instead of full links", | ||||
|     "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", | ||||
|     "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "appsPossiblyUpdated": "App Updates Attempted", | ||||
|     "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", | ||||
|     "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", | ||||
|   | ||||
| @@ -240,7 +240,7 @@ | ||||
|     "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", | ||||
|     "sortByFileNamesNotLinks": "Sort by file names instead of full links", | ||||
|     "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", | ||||
|     "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "appsPossiblyUpdated": "App Updates Attempted", | ||||
|     "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", | ||||
|     "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", | ||||
|   | ||||
| @@ -239,7 +239,7 @@ | ||||
|     "gitlabSourceNote": "Előfordulhat, hogy a GitLab APK kibontása nem működik API-kulcs nélkül.", | ||||
|     "sortByFileNamesNotLinks": "Fájlnevek szerinti elrendezés teljes linkek helyett", | ||||
|     "filterReleaseNotesByRegEx": "Kiadási megjegyzések szűrése reguláris kifejezéssel", | ||||
|     "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "appsPossiblyUpdated": "App Updates Attempted", | ||||
|     "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", | ||||
|     "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", | ||||
|   | ||||
| @@ -240,7 +240,7 @@ | ||||
|     "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", | ||||
|     "sortByFileNamesNotLinks": "Sort by file names instead of full links", | ||||
|     "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", | ||||
|     "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "appsPossiblyUpdated": "App Updates Attempted", | ||||
|     "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", | ||||
|     "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", | ||||
|   | ||||
| @@ -240,7 +240,7 @@ | ||||
|     "gitlabSourceNote": "Извлечение APK из GitLab может не работать без ключа API.", | ||||
|     "sortByFileNamesNotLinks": "Sort by file names instead of full links", | ||||
|     "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", | ||||
|     "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", | ||||
|     "appsPossiblyUpdated": "App Updates Attempted", | ||||
|     "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", | ||||
|     "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", | ||||
|   | ||||
| @@ -103,7 +103,16 @@ class HTML extends AppSource { | ||||
|               } | ||||
|             ]) | ||||
|       ], | ||||
|       [ | ||||
|         GeneratedFormTextField('intermediateLinkRegex', | ||||
|             label: tr('intermediateLinkRegex'), | ||||
|             hint: '([0-9]+\.)*[0-9]+/\$', | ||||
|             required: false, | ||||
|             additionalValidators: [(value) => regExValidator(value)]) | ||||
|       ] | ||||
|     ]; | ||||
|     overrideVersionDetectionFormDefault('noVersionDetection', | ||||
|         disableStandard: true, disableRelDate: true); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
| @@ -132,6 +141,21 @@ class HTML extends AppSource { | ||||
|           .map((element) => element.attributes['href'] ?? '') | ||||
|           .toList(); | ||||
|       List<String> links = []; | ||||
|       if ((additionalSettings['intermediateLinkRegex'] as String?) | ||||
|               ?.isNotEmpty == | ||||
|           true) { | ||||
|         var reg = RegExp(additionalSettings['intermediateLinkRegex']); | ||||
|         links = allLinks.where((element) => reg.hasMatch(element)).toList(); | ||||
|         links.sort((a, b) => compareAlphaNumeric(a, b)); | ||||
|         if (links.isEmpty) { | ||||
|           throw ObtainiumError(tr('intermediateLinkNotFound')); | ||||
|         } | ||||
|         Map<String, dynamic> additionalSettingsTemp = | ||||
|             Map.from(additionalSettings); | ||||
|         additionalSettingsTemp['intermediateLinkRegex'] = null; | ||||
|         return getLatestAPKDetails( | ||||
|             ensureAbsoluteUrl(links.last, uri), additionalSettingsTemp); | ||||
|       } | ||||
|       if ((additionalSettings['customLinkFilterRegex'] as String?) | ||||
|               ?.isNotEmpty == | ||||
|           true) { | ||||
|   | ||||
| @@ -7,7 +7,8 @@ class HuaweiAppGallery extends AppSource { | ||||
|   HuaweiAppGallery() { | ||||
|     name = 'Huawei AppGallery'; | ||||
|     host = 'appgallery.huawei.com'; | ||||
|     overrideVersionDetectionFormDefault('releaseDateAsVersion', true); | ||||
|     overrideVersionDetectionFormDefault('releaseDateAsVersion', | ||||
|         disableStandard: true); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   | ||||
| @@ -6,7 +6,8 @@ import 'package:obtainium/providers/source_provider.dart'; | ||||
|  | ||||
| class Jenkins extends AppSource { | ||||
|   Jenkins() { | ||||
|     overrideVersionDetectionFormDefault('releaseDateAsVersion', true); | ||||
|     overrideVersionDetectionFormDefault('releaseDateAsVersion', | ||||
|         disableStandard: true); | ||||
|   } | ||||
|  | ||||
|   String trimJobUrl(String url) { | ||||
|   | ||||
| @@ -329,16 +329,23 @@ abstract class AppSource { | ||||
|     name = runtimeType.toString(); | ||||
|   } | ||||
|  | ||||
|   overrideVersionDetectionFormDefault(String vd, bool disableStandard) { | ||||
|   overrideVersionDetectionFormDefault(String vd, | ||||
|       {bool disableStandard = false, bool disableRelDate = false}) { | ||||
|     additionalAppSpecificSourceAgnosticSettingFormItems = | ||||
|         additionalAppSpecificSourceAgnosticSettingFormItems.map((e) { | ||||
|       return e.map((e2) { | ||||
|         if (e2.key == 'versionDetection') { | ||||
|           var item = e2 as GeneratedFormDropdown; | ||||
|           item.defaultValue = vd; | ||||
|           item.disabledOptKeys = []; | ||||
|           if (disableStandard) { | ||||
|             item.disabledOptKeys = ['standardVersionDetection']; | ||||
|             item.disabledOptKeys?.add('standardVersionDetection'); | ||||
|           } | ||||
|           if (disableRelDate) { | ||||
|             item.disabledOptKeys?.add('releaseDateAsVersion'); | ||||
|           } | ||||
|           item.disabledOptKeys = | ||||
|               item.disabledOptKeys?.where((element) => element != vd).toList(); | ||||
|         } | ||||
|         return e2; | ||||
|       }).toList(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user