summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/de/danoeh/antennapod/discovery/ItunesTopListLoader.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/discovery/ItunesTopListLoader.java b/app/src/main/java/de/danoeh/antennapod/discovery/ItunesTopListLoader.java
index 79ccd9532..ee318c706 100644
--- a/app/src/main/java/de/danoeh/antennapod/discovery/ItunesTopListLoader.java
+++ b/app/src/main/java/de/danoeh/antennapod/discovery/ItunesTopListLoader.java
@@ -1,6 +1,8 @@
package de.danoeh.antennapod.discovery;
import android.content.Context;
+import android.util.Log;
+
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
@@ -21,6 +23,7 @@ import java.util.List;
import java.util.Locale;
public class ItunesTopListLoader {
+ private static final String TAG = "ITunesTopListLoader";
private final Context context;
public ItunesTopListLoader(Context context) {
@@ -29,11 +32,11 @@ public class ItunesTopListLoader {
public Single<List<PodcastSearchResult>> loadToplist(int limit) {
return Single.create((SingleOnSubscribe<List<PodcastSearchResult>>) emitter -> {
- String lang = Locale.getDefault().getLanguage();
+ String country = Locale.getDefault().getCountry();
OkHttpClient client = AntennapodHttpClient.getHttpClient();
String feedString;
try {
- feedString = getTopListFeed(client, lang, limit);
+ feedString = getTopListFeed(client, country, limit);
} catch (IOException e) {
feedString = getTopListFeed(client, "us", limit);
}
@@ -74,11 +77,12 @@ public class ItunesTopListLoader {
.observeOn(AndroidSchedulers.mainThread());
}
- private String getTopListFeed(OkHttpClient client, String language, int limit) throws IOException {
- String url = "https://itunes.apple.com/%s/rss/toppodcasts/limit="+limit+"/explicit=true/json";
+ private String getTopListFeed(OkHttpClient client, String country, int limit) throws IOException {
+ String url = "https://itunes.apple.com/%s/rss/toppodcasts/limit=" + limit + "/explicit=true/json";
+ Log.d(TAG, "Feed URL " + String.format(url, country));
Request.Builder httpReq = new Request.Builder()
.header("User-Agent", ClientConfig.USER_AGENT)
- .url(String.format(url, language));
+ .url(String.format(url, country));
try (Response response = client.newCall(httpReq.build()).execute()) {
if (response.isSuccessful()) {
@@ -95,7 +99,7 @@ public class ItunesTopListLoader {
JSONArray entries = feed.getJSONArray("entry");
List<PodcastSearchResult> results = new ArrayList<>();
- for (int i=0; i < entries.length(); i++) {
+ for (int i = 0; i < entries.length(); i++) {
JSONObject json = entries.getJSONObject(i);
results.add(PodcastSearchResult.fromItunesToplist(json));
}