diff --git a/assets/translations/bs.json b/assets/translations/bs.json index 54fa76b..2c3c5d3 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -246,6 +246,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$')", "removeAppQuestion": { "one": "Želite li ukloniti aplikaciju?", "other": "Želite li ukloniti aplikacije?" diff --git a/assets/translations/de.json b/assets/translations/de.json index fe26fab..0884158 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLab APK-Extraktion funktioniert möglicherweise nicht ohne API-Schlüssel", "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$')", "removeAppQuestion": { "one": "App entfernen?", "other": "Apps entfernen?" diff --git a/assets/translations/en.json b/assets/translations/en.json index 2daf50e..397c7a2 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -246,6 +246,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$')", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index 76bddc6..b5d3d25 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -246,6 +246,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$')", "removeAppQuestion": { "one": "¿Eliminar Aplicación?", "other": "¿Eliminar Aplicaciones?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index 342d98d..beaf442 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -246,6 +246,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$')", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 32d1e35..ec680f8 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -246,6 +246,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$')", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index ab5be1f..8b10f31 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -245,6 +245,7 @@ "gitlabSourceNote": "Előfordulhat, hogy a GitLab APK kibontása nem működik API-kulcs nélkül.", "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$')", "removeAppQuestion": { "one": "Eltávolítja az alkalmazást?", "other": "Eltávolítja az alkalmazást?" diff --git a/assets/translations/it.json b/assets/translations/it.json index be3e441..4dd0383 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -246,6 +246,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$')", "removeAppQuestion": { "one": "Rimuovere l'app?", "other": "Rimuovere le app?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index a89fc20..6c1f7eb 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "GitLabのAPK抽出は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$')", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/pl.json b/assets/translations/pl.json index be2f699..d227ee2 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -250,6 +250,7 @@ "gitlabSourceNote": "Pozyskiwanie pliku APK z GitLab może nie działać bez klucza 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$')", "removeAppQuestion": { "one": "Usunąć aplikację?", "other": "Usunąć aplikacje?" diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 94a6ebf..1f27453 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -246,6 +246,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$')", "removeAppQuestion": { "one": "Удалить приложение?", "other": "Удалить приложения?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index e59296d..d5bc0eb 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -246,6 +246,7 @@ "gitlabSourceNote": "未使用访问令牌时可能无法从 GitLab 获取 APK 文件。", "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$')", "removeAppQuestion": { "one": "是否删除应用?", "other": "是否删除应用?" diff --git a/lib/app_sources/html.dart b/lib/app_sources/html.dart index a60386e..2331d54 100644 --- a/lib/app_sources/html.dart +++ b/lib/app_sources/html.dart @@ -91,7 +91,18 @@ class HTML extends AppSource { [ GeneratedFormSwitch('sortByFileNamesNotLinks', label: tr('sortByFileNamesNotLinks')) - ] + ], + [ + GeneratedFormTextField('customLinkFilterRegex', + label: tr('customLinkFilterRegex'), + hint: 'download/(.*/)?(android|apk|mobile)', + required: false, + additionalValidators: [ + (value) { + return regExValidator(value); + } + ]) + ], ]; } @@ -115,16 +126,29 @@ class HTML extends AppSource { var uri = Uri.parse(standardUrl); Response res = await sourceRequest(standardUrl); if (res.statusCode == 200) { - List links = parse(res.body) + var html = parse(res.body); + List allLinks = html .querySelectorAll('a') .map((element) => element.attributes['href'] ?? '') - .where((element) => - Uri.parse(element).path.toLowerCase().endsWith('.apk')) .toList(); + List links = []; + if ((additionalSettings['customLinkFilterRegex'] as String?) + ?.isNotEmpty == + true) { + var reg = RegExp(additionalSettings['customLinkFilterRegex']); + links = allLinks.where((element) => reg.hasMatch(element)).toList(); + } else { + links = allLinks + .where((element) => + Uri.parse(element).path.toLowerCase().endsWith('.apk')) + .toList(); + } links.sort((a, b) => additionalSettings['sortByFileNamesNotLinks'] == true - ? compareAlphaNumeric(a.split('/').last, b.split('/').last) + ? compareAlphaNumeric(a.split('/').where((e) => e.isNotEmpty).last, + b.split('/').where((e) => e.isNotEmpty).last) : compareAlphaNumeric(a, b)); - if (additionalSettings['apkFilterRegEx'] != null) { + if ((additionalSettings['apkFilterRegEx'] as String?)?.isNotEmpty == + true) { var reg = RegExp(additionalSettings['apkFilterRegEx']); links = links.where((element) => reg.hasMatch(element)).toList(); }