diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java index d0adf85..173316a 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java @@ -235,7 +235,9 @@ public class PeertubeAPI { e.printStackTrace(); } } else { - return null; + if (!resobj.has("name")) { + return null; + } } try { peertube.setId(resobj.getString("id")); @@ -243,6 +245,7 @@ public class PeertubeAPI { if (resobj.has("uuid")) { peertube.setUuid(resobj.getString("uuid")); } + peertube.setName(resobj.getString("name")); peertube.setDescription(resobj.getString("description")); peertube.setEmbedPath(resobj.getString("embedPath")); @@ -272,11 +275,16 @@ public class PeertubeAPI { LinkedHashMap category = new LinkedHashMap<>(); LinkedHashMap license = new LinkedHashMap<>(); LinkedHashMap privacy = new LinkedHashMap<>(); - category.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").getString("label")); + + if (!resobj.getJSONObject("category").isNull("id")) { + license.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").getString("label")); + } else { + license.put(1, resobj.getJSONObject("category").getString("label")); + } if (!resobj.getJSONObject("licence").isNull("id")) { license.put(resobj.getJSONObject("licence").getInt("id"), resobj.getJSONObject("licence").getString("label")); } else { - license.put(1, "Unknown"); + license.put(1, resobj.getJSONObject("licence").getString("label")); } privacy.put(resobj.getJSONObject("privacy").getInt("id"), resobj.getJSONObject("privacy").getString("label")); langue.put(resobj.getJSONObject("language").getString("id"), resobj.getJSONObject("language").getString("label")); @@ -284,7 +292,8 @@ public class PeertubeAPI { peertube.setLicense(license); peertube.setLanguage(langue); peertube.setPrivacy(privacy); - } catch (Exception ignored) { + } catch (Exception e) { + e.printStackTrace(); } } catch (JSONException e) { e.printStackTrace();