add preference for jsdelivr

This commit is contained in:
Cloudburst 2023-02-11 13:31:32 +00:00
parent ea306b9bb3
commit f5297ddf11
3 changed files with 29 additions and 12 deletions

View file

@ -73,7 +73,9 @@ object RepositoryManager {
}
val GH_REGEX = Regex("^https://raw.githubusercontent.com/([A-Za-z0-9-]+)/([A-Za-z0-9_.-]+)/(.*)$")
/* Convert raw.githubusercontent.com urls to cdn.jsdelivr.net if enabled in settings */
fun convertRawGitUrl(url: String): String {
if (!(getKey<Boolean>("jsdelivr_proxy_key") ?: false)) return url
val match = GH_REGEX.find(url) ?: return url
val (user, repo, rest) = match.destructured
return "https://cdn.jsdelivr.net/gh/$user/$repo@$rest"

View file

@ -373,6 +373,8 @@
<string name="video_disk_description">Causes problems if set too high on devices with low storage space, such as Android TV.</string>
<string name="dns_pref">DNS over HTTPS</string>
<string name="dns_pref_summary">Useful for bypassing ISP blocks</string>
<string name="jsdelivr_proxy">raw.githubusercontent.com Proxy</string>
<string name="jsdelivr_proxy_summary">Bypasses blocking of GitHub using jsdelivr, may cause updates to be delayed by few days.</string>
<string name="add_site_pref">Clone site</string>
<string name="remove_site_pref">Remove site</string>
<string name="add_site_summary">Add a clone of an existing site, with a different URL</string>
@ -400,6 +402,7 @@
responsibility of user to avoid any actions that might violate the laws governing his/her locality. Use
CloudStream 3 at your own risk.
</string>
<string name="pref_category_bypass">ISP Bypasses</string>
<string name="pref_category_links">Links</string>
<string name="pref_category_app_updates">App updates</string>
<string name="pref_category_backup">Backup</string>

View file

@ -6,18 +6,6 @@
android:title="@string/app_language"
android:icon="@drawable/ic_baseline_language_24" />
<Preference
android:key="@string/override_site_key"
android:title="@string/add_site_pref"
android:summary="@string/add_site_summary"
android:icon="@drawable/ic_baseline_add_24" />
<Preference
android:key="@string/dns_key"
android:title="@string/dns_pref"
android:summary="@string/dns_pref_summary"
android:icon="@drawable/ic_baseline_dns_24" />
<Preference
android:key="@string/download_path_key"
android:title="@string/download_path_pref"
@ -34,6 +22,30 @@
android:icon="@drawable/benene"
app:summary="@string/benene_des" />
<PreferenceCategory
android:title="@string/pref_category_bypass">
<Preference
android:key="@string/override_site_key"
android:title="@string/add_site_pref"
android:summary="@string/add_site_summary"
android:icon="@drawable/ic_baseline_add_24" />
<Preference
android:key="@string/dns_key"
android:title="@string/dns_pref"
android:summary="@string/dns_pref_summary"
android:icon="@drawable/ic_baseline_dns_24" />
<SwitchPreference
android:defaultValue="false"
android:icon="@drawable/ic_github_logo"
android:key="jsdelivr_proxy_key"
android:title="@string/jsdelivr_proxy"
android:summary="@string/jsdelivr_proxy_summary" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_category_links">