SponsorBlock: Now requires the API url to be set
Added/rearranged/renamed some SponsorBlock settings. Now the API Url setting must be set for SponsorBlock to work.
This commit is contained in:
parent
41479dc37c
commit
f0b029df06
5 changed files with 59 additions and 38 deletions
|
@ -1048,15 +1048,19 @@ public abstract class BasePlayer implements
|
|||
initThumbnail(info.getThumbnailUrl());
|
||||
registerView();
|
||||
|
||||
if (info.getUrl().startsWith("https://www.youtube.com")
|
||||
&& mPrefs.getBoolean(context.getString(R.string.sponsorblock_enable), false)) {
|
||||
try {
|
||||
sponsorTimeInfo = new SponsorBlockApiTask(
|
||||
mPrefs.getString(context.getString(R.string.sponsorblock_custom_api_url),
|
||||
"https://sponsor.ajay.app/api/"))
|
||||
.getYouTubeVideoSponsorTimes(info.getId());
|
||||
} catch (Exception e) {
|
||||
Log.e("SPONSOR_BLOCK", "Error getting YouTube video sponsor times.", e);
|
||||
if (info.getUrl().startsWith("https://www.youtube.com")) {
|
||||
String apiUrl = mPrefs
|
||||
.getString(context.getString(R.string.sponsorblock_api_url), null);
|
||||
boolean isSponsorBlockEnabled = mPrefs
|
||||
.getBoolean(context.getString(R.string.sponsorblock_enable), false);
|
||||
|
||||
if (apiUrl != null && !apiUrl.isEmpty() && isSponsorBlockEnabled) {
|
||||
try {
|
||||
sponsorTimeInfo = new SponsorBlockApiTask(apiUrl)
|
||||
.getYouTubeVideoSponsorTimes(info.getId());
|
||||
} catch (Exception e) {
|
||||
Log.e("SPONSOR_BLOCK", "Error getting YouTube video sponsor times.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,9 +140,17 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
return true;
|
||||
});
|
||||
|
||||
Preference sponsorblockPrivacyPreference =
|
||||
Preference sponsorBlockWebsitePreference =
|
||||
findPreference(getString(R.string.sponsorblock_home_page));
|
||||
sponsorBlockWebsitePreference.setOnPreferenceClickListener((Preference p) -> {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://sponsor.ajay.app/"));
|
||||
startActivity(i);
|
||||
return true;
|
||||
});
|
||||
|
||||
Preference sponsorBlockPrivacyPreference =
|
||||
findPreference(getString(R.string.sponsorblock_privacy));
|
||||
sponsorblockPrivacyPreference.setOnPreferenceClickListener((Preference p) -> {
|
||||
sponsorBlockPrivacyPreference.setOnPreferenceClickListener((Preference p) -> {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse(
|
||||
"https://gist.github.com/ajayyy/aa9f8ded2b573d4f73a3ffa0ef74f796"
|
||||
|
|
|
@ -223,8 +223,9 @@
|
|||
<string name="downloads_storage_ask" translatable="false">downloads_storage_ask</string>
|
||||
<string name="storage_use_saf" translatable="false">storage_use_saf</string>
|
||||
|
||||
<string name="sponsorblock_enable" translatable="false">skip_sponsors</string>
|
||||
<string name="sponsorblock_custom_api_url" translatable="false">sponsorblock_custom_api_url</string>
|
||||
<string name="sponsorblock_home_page" translatable="false">sponsorblock_home_page</string>
|
||||
<string name="sponsorblock_enable" translatable="false">sponsorblock_enable</string>
|
||||
<string name="sponsorblock_api_url" translatable="false">sponsorblock_custom_api_url</string>
|
||||
<string name="sponsorblock_notifications" translatable="false">sponsorblock_notifications</string>
|
||||
<string name="sponsorblock_privacy" translatable="false">sponsorblock_privacy</string>
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
<string name="settings_category_other_title">Other</string>
|
||||
<string name="settings_category_debug_title">Debug</string>
|
||||
<string name="settings_category_updates_title">Updates</string>
|
||||
<string name="settings_category_sponsorblock">SponsorBlock Beta (Third party service)</string>
|
||||
<string name="settings_category_sponsorblock">SponsorBlock (beta, third party service)</string>
|
||||
<string name="background_player_playing_toast">Playing in background</string>
|
||||
<string name="popup_playing_toast">Playing in popup mode</string>
|
||||
<string name="background_player_append">Queued on background player</string>
|
||||
|
@ -661,12 +661,14 @@
|
|||
<string name="video_detail_by">By %s</string>
|
||||
<string name="playlist_page_summary">Playlist page</string>
|
||||
<!-- SponsorBlock -->
|
||||
<string name="sponsorblock_home_page_title">View Website</string>
|
||||
<string name="sponsorblock_home_page_summary">View the official SponsorBlock website.</string>
|
||||
<string name="sponsorblock_enable_title">Skip Sponsors</string>
|
||||
<string name="sponsorblock_enable_summary">Use the SponsorBlock API to automatically skip sponsors in videos.</string>
|
||||
<string name="sponsorblock_custom_api_url_title">Custom API Url</string>
|
||||
<string name="sponsorblock_custom_api_url_summary">The url to use when querying the SponsorBlock API. Leave empty to use the default.</string>
|
||||
<string name="sponsorblock_enable_summary">Use the SponsorBlock API to automatically skip sponsors in videos. This currently only works for YouTube videos.</string>
|
||||
<string name="sponsorblock_api_url_title">API Url</string>
|
||||
<string name="sponsorblock_api_url_summary">The url to use when querying the SponsorBlock API. This must be set for SponsorBlock to work.</string>
|
||||
<string name="sponsorblock_notifications_title">Notify when sponsors are skipped</string>
|
||||
<string name="sponsorblock_notifications_summary">Show a toast notification when a sponsor is automatically skipped.</string>
|
||||
<string name="sponsorblock_privacy_title">View Privacy Policy</string>
|
||||
<string name="sponsorblock_privacy_summary">View the privacy policy of the SponsorBlock service.</string>
|
||||
<string name="sponsorblock_privacy_summary">View SponsorBlock\'s privacy policy.</string>
|
||||
</resources>
|
|
@ -122,26 +122,10 @@
|
|||
android:layout="@layout/settings_category_header_layout"
|
||||
android:title="@string/settings_category_sponsorblock">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/sponsorblock_enable"
|
||||
android:summary="@string/sponsorblock_enable_summary"
|
||||
android:title="@string/sponsorblock_enable_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:dependency="@string/sponsorblock_enable"
|
||||
android:key="@string/sponsorblock_notifications"
|
||||
android:summary="@string/sponsorblock_notifications_summary"
|
||||
android:title="@string/sponsorblock_notifications_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<EditTextPreference
|
||||
android:dependency="@string/sponsorblock_enable"
|
||||
android:key="@string/sponsorblock_custom_api_url"
|
||||
android:summary="@string/sponsorblock_custom_api_url_summary"
|
||||
android:title="@string/sponsorblock_custom_api_url_title"
|
||||
<Preference
|
||||
android:key="@string/sponsorblock_home_page"
|
||||
android:summary="@string/sponsorblock_home_page_summary"
|
||||
android:title="@string/sponsorblock_home_page_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<Preference
|
||||
|
@ -150,5 +134,27 @@
|
|||
android:title="@string/sponsorblock_privacy_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/sponsorblock_api_url"
|
||||
android:summary="@string/sponsorblock_api_url_summary"
|
||||
android:title="@string/sponsorblock_api_url_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:dependency="@string/sponsorblock_api_url"
|
||||
android:defaultValue="false"
|
||||
android:key="@string/sponsorblock_enable"
|
||||
android:summary="@string/sponsorblock_enable_summary"
|
||||
android:title="@string/sponsorblock_enable_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:dependency="@string/sponsorblock_api_url"
|
||||
android:key="@string/sponsorblock_notifications"
|
||||
android:summary="@string/sponsorblock_notifications_summary"
|
||||
android:title="@string/sponsorblock_notifications_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Reference in a new issue