Fix some crashes

This commit is contained in:
Thomas 2020-09-12 10:37:11 +02:00
parent 2f909d5ffa
commit c4c745dbc0
1 changed files with 13 additions and 4 deletions

View File

@ -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<Integer, String> category = new LinkedHashMap<>();
LinkedHashMap<Integer, String> license = new LinkedHashMap<>();
LinkedHashMap<Integer, String> 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();