From 50c5314eaff78bddd956a2f6d8d1d78dc885a64b Mon Sep 17 00:00:00 2001 From: Schabi Date: Fri, 29 Dec 2017 15:02:23 +0100 Subject: [PATCH] fix yt trending content language --- app/build.gradle | 2 +- .../fragments/list/kiosk/KioskFragment.java | 7 ++++++- .../schabi/newpipe/util/ExtractorHelper.java | 19 ++++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 46e63a082..50fa6ab12 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,7 +55,7 @@ dependencies { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:2d191c4ca' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:044b8fe32f47e28' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:1.10.19' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java index c50a8a66a..ad0d0432f 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java @@ -5,6 +5,7 @@ import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -153,7 +154,11 @@ public class KioskFragment extends BaseListInfoFragment { @Override public Single loadMoreItemsLogic() { - return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextItemsUrl); + String contentCountry = PreferenceManager + .getDefaultSharedPreferences(activity) + .getString(getString(R.string.search_language_key), + getString(R.string.default_language_value)); + return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextItemsUrl, contentCountry); } /*////////////////////////////////////////////////////////////////////////// diff --git a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java index 4763b6a02..5293ff3d6 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -143,16 +143,16 @@ public final class ExtractorHelper { return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable() { @Override public KioskInfo call() throws Exception { - return KioskInfo.getInfo(NewPipe.getService(serviceId), url, contentCountry); + return KioskInfo.getInfo(NewPipe.getService(serviceId), url, toUpperCase(contentCountry)); } })); } - public static Single getMoreKioskItems(final int serviceId, final String url, final String nextStreamsUrl) { + public static Single getMoreKioskItems(final int serviceId, final String url, final String nextStreamsUrl, final String contentCountry) { return Single.fromCallable(new Callable() { @Override public NextItemsResult call() throws Exception { - return KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextStreamsUrl); + return KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextStreamsUrl, toUpperCase(contentCountry)); } }); } @@ -267,4 +267,17 @@ public final class ExtractorHelper { public static boolean isInterruptedCaused(Throwable throwable) { return ExtractorHelper.hasExactCauseThrowable(throwable, InterruptedIOException.class, InterruptedException.class); } + + public static String toUpperCase(String value) { + StringBuilder sb = new StringBuilder(value); + for (int index = 0; index < sb.length(); index++) { + char c = sb.charAt(index); + if (Character.isLowerCase(c)) { + sb.setCharAt(index, Character.toUpperCase(c)); + } else { + sb.setCharAt(index, Character.toLowerCase(c)); + } + } + return sb.toString(); + } }