summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré <1729839+andre-m-dev@users.noreply.github.com>2024-05-31 10:51:58 +0200
committerGitHub <noreply@github.com>2024-05-31 10:51:58 +0200
commit43d487f7e96f76df6f2b7f04d3a24456b387300a (patch)
treef5cc19e1bd7cfc609ccc267f71823cc7fa623fce
parentf8c864f5536e97c6f55c2bf9455d3ba5451cb76c (diff)
downloadAntennaPod-43d487f7e96f76df6f2b7f04d3a24456b387300a.zip
Name of the sync server in error messages (#7213)
-rw-r--r--net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java62
1 files changed, 4 insertions, 58 deletions
diff --git a/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java b/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java
index b04e9bdc9..4b08c4b9f 100644
--- a/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java
+++ b/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java
@@ -31,7 +31,6 @@ import java.util.Locale;
import de.danoeh.antennapod.net.sync.gpoddernet.mapper.ResponseMapper;
import de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetDevice;
import de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetEpisodeActionPostResponse;
-import de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast;
import de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetUploadChangesResponse;
import okhttp3.Credentials;
import okhttp3.MediaType;
@@ -60,13 +59,13 @@ public class GpodnetService implements ISyncService {
private final OkHttpClient httpClient;
- public GpodnetService(OkHttpClient httpClient, String baseHosturl,
+ public GpodnetService(OkHttpClient httpClient, String baseHostUrl,
String deviceId, String username, String password) {
this.httpClient = httpClient;
this.deviceId = deviceId;
this.username = username;
this.password = password;
- HostnameParser hostname = new HostnameParser(baseHosturl == null ? DEFAULT_BASE_HOST : baseHosturl);
+ HostnameParser hostname = new HostnameParser(baseHostUrl == null ? DEFAULT_BASE_HOST : baseHostUrl);
this.baseHost = hostname.host;
this.basePort = hostname.port;
this.baseScheme = hostname.scheme;
@@ -373,69 +372,16 @@ public class GpodnetService implements ISyncService {
}
}
if (responseCode >= 500) {
- throw new GpodnetServiceBadStatusCodeException("Gpodder.net is currently unavailable (code "
+ throw new GpodnetServiceBadStatusCodeException(this.baseHost + " is currently unavailable (code "
+ responseCode + ")", responseCode);
} else {
- throw new GpodnetServiceBadStatusCodeException("Unable to connect to Gpodder.net (code "
+ throw new GpodnetServiceBadStatusCodeException("Unable to connect to " + this.baseHost + " (code "
+ responseCode + ": " + response.message() + ")", responseCode);
}
}
}
}
- private List<GpodnetPodcast> readPodcastListFromJsonArray(@NonNull JSONArray array) throws JSONException {
- List<GpodnetPodcast> result = new ArrayList<>(array.length());
- for (int i = 0; i < array.length(); i++) {
- result.add(readPodcastFromJsonObject(array.getJSONObject(i)));
- }
- return result;
- }
-
- private GpodnetPodcast readPodcastFromJsonObject(JSONObject object) throws JSONException {
- String url = object.getString("url");
-
- String title;
- Object titleObj = object.opt("title");
- if (titleObj instanceof String) {
- title = (String) titleObj;
- } else {
- title = url;
- }
-
- String description;
- Object descriptionObj = object.opt("description");
- if (descriptionObj instanceof String) {
- description = (String) descriptionObj;
- } else {
- description = "";
- }
-
- int subscribers = object.getInt("subscribers");
-
- Object logoUrlObj = object.opt("logo_url");
- String logoUrl = (logoUrlObj instanceof String) ? (String) logoUrlObj : null;
- if (logoUrl == null) {
- Object scaledLogoUrl = object.opt("scaled_logo_url");
- if (scaledLogoUrl instanceof String) {
- logoUrl = (String) scaledLogoUrl;
- }
- }
-
- String website = null;
- Object websiteObj = object.opt("website");
- if (websiteObj instanceof String) {
- website = (String) websiteObj;
- }
- String mygpoLink = object.getString("mygpo_link");
-
- String author = null;
- Object authorObj = object.opt("author");
- if (authorObj instanceof String) {
- author = (String) authorObj;
- }
- return new GpodnetPodcast(url, title, description, subscribers, logoUrl, website, mygpoLink, author);
- }
-
private List<GpodnetDevice> readDeviceListFromJsonArray(@NonNull JSONArray array) throws JSONException {
List<GpodnetDevice> result = new ArrayList<>(array.length());
for (int i = 0; i < array.length(); i++) {