CLean up
This commit is contained in:
parent
ef56d813c8
commit
edcab6e9ec
|
@ -120,10 +120,10 @@ public class PeertubeAPI {
|
||||||
private static PeertubeNotification parsePeertubeNotifications(JSONObject resobj) {
|
private static PeertubeNotification parsePeertubeNotifications(JSONObject resobj) {
|
||||||
PeertubeNotification peertubeNotification = new PeertubeNotification();
|
PeertubeNotification peertubeNotification = new PeertubeNotification();
|
||||||
try {
|
try {
|
||||||
peertubeNotification.setId(resobj.get("id").toString());
|
peertubeNotification.setId(resobj.getString("id"));
|
||||||
peertubeNotification.setType(resobj.getInt("type"));
|
peertubeNotification.setType(resobj.getInt("type"));
|
||||||
peertubeNotification.setUpdatedAt(Helper.mstStringToDate(resobj.get("updatedAt").toString()));
|
peertubeNotification.setUpdatedAt(Helper.mstStringToDate(resobj.getString("updatedAt")));
|
||||||
peertubeNotification.setCreatedAt(Helper.mstStringToDate(resobj.get("createdAt").toString()));
|
peertubeNotification.setCreatedAt(Helper.mstStringToDate(resobj.getString("createdAt")));
|
||||||
peertubeNotification.setRead(resobj.getBoolean("read"));
|
peertubeNotification.setRead(resobj.getBoolean("read"));
|
||||||
|
|
||||||
if (resobj.has("comment")) {
|
if (resobj.has("comment")) {
|
||||||
|
@ -132,42 +132,42 @@ public class PeertubeAPI {
|
||||||
if (comment.has("account")) {
|
if (comment.has("account")) {
|
||||||
JSONObject account = comment.getJSONObject("account");
|
JSONObject account = comment.getJSONObject("account");
|
||||||
PeertubeAccountNotification peertubeAccountNotification = new PeertubeAccountNotification();
|
PeertubeAccountNotification peertubeAccountNotification = new PeertubeAccountNotification();
|
||||||
peertubeAccountNotification.setDisplayName(account.get("displayName").toString());
|
peertubeAccountNotification.setDisplayName(account.getString("displayName"));
|
||||||
peertubeAccountNotification.setName(account.get("name").toString());
|
peertubeAccountNotification.setName(account.getString("name"));
|
||||||
peertubeAccountNotification.setId(account.get("id").toString());
|
peertubeAccountNotification.setId(account.getString("id"));
|
||||||
if (account.has("host")) {
|
if (account.has("host")) {
|
||||||
peertubeAccountNotification.setHost(account.get("host").toString());
|
peertubeAccountNotification.setHost(account.getString("host"));
|
||||||
}
|
}
|
||||||
peertubeAccountNotification.setAvatar(account.getJSONObject("avatar").get("path").toString());
|
peertubeAccountNotification.setAvatar(account.getJSONObject("avatar").getString("path"));
|
||||||
peertubeComment.setPeertubeAccountNotification(peertubeAccountNotification);
|
peertubeComment.setPeertubeAccountNotification(peertubeAccountNotification);
|
||||||
}
|
}
|
||||||
if (comment.has("video")) {
|
if (comment.has("video")) {
|
||||||
JSONObject video = comment.getJSONObject("video");
|
JSONObject video = comment.getJSONObject("video");
|
||||||
PeertubeVideoNotification peertubeVideoNotification = new PeertubeVideoNotification();
|
PeertubeVideoNotification peertubeVideoNotification = new PeertubeVideoNotification();
|
||||||
peertubeVideoNotification.setUuid(video.get("uuid").toString());
|
peertubeVideoNotification.setUuid(video.getString("uuid"));
|
||||||
peertubeVideoNotification.setName(video.get("name").toString());
|
peertubeVideoNotification.setName(video.getString("name"));
|
||||||
peertubeVideoNotification.setId(video.get("id").toString());
|
peertubeVideoNotification.setId(video.getString("id"));
|
||||||
peertubeComment.setPeertubeVideoNotification(peertubeVideoNotification);
|
peertubeComment.setPeertubeVideoNotification(peertubeVideoNotification);
|
||||||
}
|
}
|
||||||
peertubeComment.setId(comment.get("id").toString());
|
peertubeComment.setId(comment.getString("id"));
|
||||||
peertubeComment.setThreadId(comment.get("threadId").toString());
|
peertubeComment.setThreadId(comment.getString("threadId"));
|
||||||
peertubeNotification.setPeertubeComment(peertubeComment);
|
peertubeNotification.setPeertubeComment(peertubeComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resobj.has("video")) {
|
if (resobj.has("video")) {
|
||||||
PeertubeVideoNotification peertubeVideoNotification = new PeertubeVideoNotification();
|
PeertubeVideoNotification peertubeVideoNotification = new PeertubeVideoNotification();
|
||||||
JSONObject video = resobj.getJSONObject("video");
|
JSONObject video = resobj.getJSONObject("video");
|
||||||
peertubeVideoNotification.setUuid(video.get("uuid").toString());
|
peertubeVideoNotification.setUuid(video.getString("uuid"));
|
||||||
peertubeVideoNotification.setName(video.get("name").toString());
|
peertubeVideoNotification.setName(video.getString("name"));
|
||||||
peertubeVideoNotification.setId(video.get("id").toString());
|
peertubeVideoNotification.setId(video.getString("id"));
|
||||||
if (video.has("channel")) {
|
if (video.has("channel")) {
|
||||||
PeertubeAccountNotification peertubeAccountNotification = new PeertubeAccountNotification();
|
PeertubeAccountNotification peertubeAccountNotification = new PeertubeAccountNotification();
|
||||||
JSONObject channel = video.getJSONObject("channel");
|
JSONObject channel = video.getJSONObject("channel");
|
||||||
peertubeAccountNotification.setDisplayName(channel.get("displayName").toString());
|
peertubeAccountNotification.setDisplayName(channel.getString("displayName"));
|
||||||
peertubeAccountNotification.setName(channel.get("name").toString());
|
peertubeAccountNotification.setName(channel.getString("name"));
|
||||||
peertubeAccountNotification.setId(channel.get("id").toString());
|
peertubeAccountNotification.setId(channel.getString("id"));
|
||||||
if (channel.has("avatar")) {
|
if (channel.has("avatar")) {
|
||||||
peertubeAccountNotification.setAvatar(channel.getJSONObject("avatar").get("path").toString());
|
peertubeAccountNotification.setAvatar(channel.getJSONObject("avatar").getString("path"));
|
||||||
}
|
}
|
||||||
peertubeVideoNotification.setPeertubeAccountNotification(peertubeAccountNotification);
|
peertubeVideoNotification.setPeertubeAccountNotification(peertubeAccountNotification);
|
||||||
}
|
}
|
||||||
|
@ -182,29 +182,29 @@ public class PeertubeAPI {
|
||||||
JSONObject following = actorFollow.getJSONObject("following");
|
JSONObject following = actorFollow.getJSONObject("following");
|
||||||
|
|
||||||
PeertubeAccountNotification peertubeAccountNotification = new PeertubeAccountNotification();
|
PeertubeAccountNotification peertubeAccountNotification = new PeertubeAccountNotification();
|
||||||
peertubeAccountNotification.setDisplayName(follower.get("displayName").toString());
|
peertubeAccountNotification.setDisplayName(follower.getString("displayName"));
|
||||||
peertubeAccountNotification.setName(follower.get("name").toString());
|
peertubeAccountNotification.setName(follower.getString("name"));
|
||||||
peertubeAccountNotification.setId(follower.get("id").toString());
|
peertubeAccountNotification.setId(follower.getString("id"));
|
||||||
if (follower.has("host")) {
|
if (follower.has("host")) {
|
||||||
peertubeAccountNotification.setHost(follower.get("host").toString());
|
peertubeAccountNotification.setHost(follower.getString("host"));
|
||||||
}
|
}
|
||||||
if (follower.has("avatar")) {
|
if (follower.has("avatar")) {
|
||||||
peertubeAccountNotification.setAvatar(follower.getJSONObject("avatar").get("path").toString());
|
peertubeAccountNotification.setAvatar(follower.getJSONObject("avatar").getString("path"));
|
||||||
}
|
}
|
||||||
peertubeActorFollow.setFollower(peertubeAccountNotification);
|
peertubeActorFollow.setFollower(peertubeAccountNotification);
|
||||||
|
|
||||||
PeertubeAccountNotification peertubeAccounFollowingNotification = new PeertubeAccountNotification();
|
PeertubeAccountNotification peertubeAccounFollowingNotification = new PeertubeAccountNotification();
|
||||||
peertubeAccounFollowingNotification.setDisplayName(following.get("displayName").toString());
|
peertubeAccounFollowingNotification.setDisplayName(following.getString("displayName"));
|
||||||
peertubeAccounFollowingNotification.setName(following.get("name").toString());
|
peertubeAccounFollowingNotification.setName(following.getString("name"));
|
||||||
try {
|
try {
|
||||||
peertubeAccounFollowingNotification.setId(following.get("id").toString());
|
peertubeAccounFollowingNotification.setId(following.getString("id"));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
if (following.has("avatar")) {
|
if (following.has("avatar")) {
|
||||||
peertubeAccounFollowingNotification.setAvatar(following.getJSONObject("avatar").get("path").toString());
|
peertubeAccounFollowingNotification.setAvatar(following.getJSONObject("avatar").getString("path"));
|
||||||
}
|
}
|
||||||
peertubeActorFollow.setFollowing(peertubeAccounFollowingNotification);
|
peertubeActorFollow.setFollowing(peertubeAccounFollowingNotification);
|
||||||
peertubeActorFollow.setId(actorFollow.get("id").toString());
|
peertubeActorFollow.setId(actorFollow.getString("id"));
|
||||||
peertubeNotification.setPeertubeActorFollow(peertubeActorFollow);
|
peertubeNotification.setPeertubeActorFollow(peertubeActorFollow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -232,31 +232,31 @@ public class PeertubeAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
peertube.setId(resobj.get("id").toString());
|
peertube.setId(resobj.getString("id"));
|
||||||
peertube.setCache(resobj);
|
peertube.setCache(resobj);
|
||||||
peertube.setUuid(resobj.get("uuid").toString());
|
peertube.setUuid(resobj.getString("uuid"));
|
||||||
peertube.setName(resobj.get("name").toString());
|
peertube.setName(resobj.getString("name"));
|
||||||
peertube.setDescription(resobj.get("description").toString());
|
peertube.setDescription(resobj.getString("description"));
|
||||||
peertube.setEmbedPath(resobj.get("embedPath").toString());
|
peertube.setEmbedPath(resobj.getString("embedPath"));
|
||||||
peertube.setPreviewPath(resobj.get("previewPath").toString());
|
peertube.setPreviewPath(resobj.getString("previewPath"));
|
||||||
peertube.setThumbnailPath(resobj.get("thumbnailPath").toString());
|
peertube.setThumbnailPath(resobj.getString("thumbnailPath"));
|
||||||
peertube.setAccount(parseAccountResponsePeertube(resobj.getJSONObject("account")));
|
peertube.setAccount(parseAccountResponsePeertube(resobj.getJSONObject("account")));
|
||||||
try {
|
try {
|
||||||
peertube.setChannel(parseAccountResponsePeertube(resobj.getJSONObject("channel")));
|
peertube.setChannel(parseAccountResponsePeertube(resobj.getJSONObject("channel")));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
peertube.setView(Integer.parseInt(resobj.get("views").toString()));
|
peertube.setView(resobj.getInt("views"));
|
||||||
peertube.setLike(Integer.parseInt(resobj.get("likes").toString()));
|
peertube.setLike(resobj.getInt("likes"));
|
||||||
peertube.setDislike(Integer.parseInt(resobj.get("dislikes").toString()));
|
peertube.setDislike(resobj.getInt("dislikes"));
|
||||||
peertube.setDuration(Integer.parseInt(resobj.get("duration").toString()));
|
peertube.setDuration(resobj.getInt("duration"));
|
||||||
peertube.setSensitive(Boolean.parseBoolean(resobj.get("nsfw").toString()));
|
peertube.setSensitive(resobj.getBoolean("nsfw"));
|
||||||
try {
|
try {
|
||||||
peertube.setCommentsEnabled(Boolean.parseBoolean(resobj.get("commentsEnabled").toString()));
|
peertube.setCommentsEnabled(resobj.getBoolean("commentsEnabled"));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
peertube.setCreated_at(Helper.mstStringToDate(resobj.get("createdAt").toString()));
|
peertube.setCreated_at(Helper.mstStringToDate(resobj.getString("createdAt")));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -266,10 +266,10 @@ public class PeertubeAPI {
|
||||||
LinkedHashMap<Integer, String> category = new LinkedHashMap<>();
|
LinkedHashMap<Integer, String> category = new LinkedHashMap<>();
|
||||||
LinkedHashMap<Integer, String> license = new LinkedHashMap<>();
|
LinkedHashMap<Integer, String> license = new LinkedHashMap<>();
|
||||||
LinkedHashMap<Integer, String> privacy = new LinkedHashMap<>();
|
LinkedHashMap<Integer, String> privacy = new LinkedHashMap<>();
|
||||||
category.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").get("label").toString());
|
category.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").getString("label"));
|
||||||
license.put(resobj.getJSONObject("licence").getInt("id"), resobj.getJSONObject("licence").get("label").toString());
|
license.put(resobj.getJSONObject("licence").getInt("id"), resobj.getJSONObject("licence").getString("label"));
|
||||||
privacy.put(resobj.getJSONObject("privacy").getInt("id"), resobj.getJSONObject("privacy").get("label").toString());
|
privacy.put(resobj.getJSONObject("privacy").getInt("id"), resobj.getJSONObject("privacy").getString("label"));
|
||||||
langue.put(resobj.getJSONObject("language").get("id").toString(), resobj.getJSONObject("language").get("label").toString());
|
langue.put(resobj.getJSONObject("language").getString("id"), resobj.getJSONObject("language").getString("label"));
|
||||||
|
|
||||||
peertube.setCategory(category);
|
peertube.setCategory(category);
|
||||||
peertube.setLicense(license);
|
peertube.setLicense(license);
|
||||||
|
@ -293,21 +293,21 @@ public class PeertubeAPI {
|
||||||
private static Peertube parseSinglePeertube(String instance, JSONObject resobj) {
|
private static Peertube parseSinglePeertube(String instance, JSONObject resobj) {
|
||||||
Peertube peertube = new Peertube();
|
Peertube peertube = new Peertube();
|
||||||
try {
|
try {
|
||||||
peertube.setId(resobj.get("id").toString());
|
peertube.setId(resobj.getString("id"));
|
||||||
peertube.setUuid(resobj.get("uuid").toString());
|
peertube.setUuid(resobj.getString("uuid"));
|
||||||
peertube.setName(resobj.get("name").toString());
|
peertube.setName(resobj.getString("name"));
|
||||||
peertube.setCache(resobj);
|
peertube.setCache(resobj);
|
||||||
peertube.setInstance(instance);
|
peertube.setInstance(instance);
|
||||||
peertube.setHost(resobj.getJSONObject("account").get("host").toString());
|
peertube.setHost(resobj.getJSONObject("account").getString("host"));
|
||||||
peertube.setDescription(resobj.get("description").toString());
|
peertube.setDescription(resobj.getString("description"));
|
||||||
peertube.setEmbedPath(resobj.get("embedPath").toString());
|
peertube.setEmbedPath(resobj.getString("embedPath"));
|
||||||
peertube.setPreviewPath(resobj.get("previewPath").toString());
|
peertube.setPreviewPath(resobj.getString("previewPath"));
|
||||||
peertube.setThumbnailPath(resobj.get("thumbnailPath").toString());
|
peertube.setThumbnailPath(resobj.getString("thumbnailPath"));
|
||||||
peertube.setView(Integer.parseInt(resobj.get("views").toString()));
|
peertube.setView(resobj.getInt("views"));
|
||||||
peertube.setLike(Integer.parseInt(resobj.get("likes").toString()));
|
peertube.setLike(resobj.getInt("likes"));
|
||||||
peertube.setCommentsEnabled(Boolean.parseBoolean(resobj.get("commentsEnabled").toString()));
|
peertube.setCommentsEnabled(resobj.getBoolean("commentsEnabled"));
|
||||||
peertube.setDislike(Integer.parseInt(resobj.get("dislikes").toString()));
|
peertube.setDislike(resobj.getInt("dislikes"));
|
||||||
peertube.setDuration(Integer.parseInt(resobj.get("duration").toString()));
|
peertube.setDuration(resobj.getInt("duration"));
|
||||||
peertube.setAccount(parseAccountResponsePeertube(resobj.getJSONObject("account")));
|
peertube.setAccount(parseAccountResponsePeertube(resobj.getJSONObject("account")));
|
||||||
List<String> tags = new ArrayList<>();
|
List<String> tags = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
@ -323,15 +323,15 @@ public class PeertubeAPI {
|
||||||
peertube.setChannel(parseAccountResponsePeertube(resobj.getJSONObject("channel")));
|
peertube.setChannel(parseAccountResponsePeertube(resobj.getJSONObject("channel")));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
peertube.setSensitive(Boolean.parseBoolean(resobj.get("nsfw").toString()));
|
peertube.setSensitive(resobj.getBoolean("nsfw"));
|
||||||
try {
|
try {
|
||||||
peertube.setCreated_at(Helper.mstStringToDate(resobj.get("createdAt").toString()));
|
peertube.setCreated_at(Helper.mstStringToDate(resobj.getString("createdAt")));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
peertube.setCreated_at(Helper.mstStringToDate(resobj.get("createdAt").toString()));
|
peertube.setCreated_at(Helper.mstStringToDate(resobj.getString("createdAt")));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ public class PeertubeAPI {
|
||||||
|
|
||||||
for (int j = 0; j < files.length(); j++) {
|
for (int j = 0; j < files.length(); j++) {
|
||||||
JSONObject attObj = files.getJSONObject(j);
|
JSONObject attObj = files.getJSONObject(j);
|
||||||
resolutions.add(attObj.getJSONObject("resolution").get("id").toString());
|
resolutions.add(attObj.getJSONObject("resolution").getString("id"));
|
||||||
}
|
}
|
||||||
peertube.setResolution(resolutions);
|
peertube.setResolution(resolutions);
|
||||||
peertube.setStreamService(true);
|
peertube.setStreamService(true);
|
||||||
|
@ -349,7 +349,7 @@ public class PeertubeAPI {
|
||||||
JSONArray files = resobj.getJSONArray("files");
|
JSONArray files = resobj.getJSONArray("files");
|
||||||
for (int j = 0; j < files.length(); j++) {
|
for (int j = 0; j < files.length(); j++) {
|
||||||
JSONObject attObj = files.getJSONObject(j);
|
JSONObject attObj = files.getJSONObject(j);
|
||||||
resolutions.add(attObj.getJSONObject("resolution").get("id").toString());
|
resolutions.add(attObj.getJSONObject("resolution").getString("id"));
|
||||||
}
|
}
|
||||||
peertube.setResolution(resolutions);
|
peertube.setResolution(resolutions);
|
||||||
peertube.setStreamService(false);
|
peertube.setStreamService(false);
|
||||||
|
@ -359,10 +359,10 @@ public class PeertubeAPI {
|
||||||
LinkedHashMap<Integer, String> category = new LinkedHashMap<>();
|
LinkedHashMap<Integer, String> category = new LinkedHashMap<>();
|
||||||
LinkedHashMap<Integer, String> license = new LinkedHashMap<>();
|
LinkedHashMap<Integer, String> license = new LinkedHashMap<>();
|
||||||
LinkedHashMap<Integer, String> privacy = new LinkedHashMap<>();
|
LinkedHashMap<Integer, String> privacy = new LinkedHashMap<>();
|
||||||
category.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").get("label").toString());
|
category.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").getString("label"));
|
||||||
license.put(resobj.getJSONObject("licence").getInt("id"), resobj.getJSONObject("licence").get("label").toString());
|
license.put(resobj.getJSONObject("licence").getInt("id"), resobj.getJSONObject("licence").getString("label"));
|
||||||
privacy.put(resobj.getJSONObject("privacy").getInt("id"), resobj.getJSONObject("privacy").get("label").toString());
|
privacy.put(resobj.getJSONObject("privacy").getInt("id"), resobj.getJSONObject("privacy").getString("label"));
|
||||||
langue.put(resobj.getJSONObject("language").get("id").toString(), resobj.getJSONObject("language").get("label").toString());
|
langue.put(resobj.getJSONObject("language").getString("id"), resobj.getJSONObject("language").get("label").toString());
|
||||||
|
|
||||||
peertube.setCategory(category);
|
peertube.setCategory(category);
|
||||||
peertube.setLicense(license);
|
peertube.setLicense(license);
|
||||||
|
@ -520,7 +520,7 @@ public class PeertubeAPI {
|
||||||
account.setDisplay_name(resobj.get("displayName").toString());
|
account.setDisplay_name(resobj.get("displayName").toString());
|
||||||
account.setHost(resobj.get("host").toString());
|
account.setHost(resobj.get("host").toString());
|
||||||
if (resobj.has("createdAt"))
|
if (resobj.has("createdAt"))
|
||||||
account.setCreated_at(Helper.mstStringToDate(resobj.get("createdAt").toString()));
|
account.setCreated_at(Helper.mstStringToDate(resobj.getString("createdAt")));
|
||||||
else
|
else
|
||||||
account.setCreated_at(new Date());
|
account.setCreated_at(new Date());
|
||||||
|
|
||||||
|
@ -534,17 +534,17 @@ public class PeertubeAPI {
|
||||||
account.setFollowing_count(0);
|
account.setFollowing_count(0);
|
||||||
account.setStatuses_count(0);
|
account.setStatuses_count(0);
|
||||||
if (resobj.has("description"))
|
if (resobj.has("description"))
|
||||||
account.setNote(resobj.get("description").toString());
|
account.setNote(resobj.getString("description"));
|
||||||
else
|
else
|
||||||
account.setNote("");
|
account.setNote("");
|
||||||
account.setUrl(resobj.get("url").toString());
|
account.setUrl(resobj.getString("url"));
|
||||||
account.setSocial("PEERTUBE");
|
account.setSocial("PEERTUBE");
|
||||||
if (resobj.has("avatar") && !resobj.get("avatar").toString().equals("null")) {
|
if (resobj.has("avatar") && !resobj.getString("avatar").equals("null")) {
|
||||||
account.setAvatar("https://" + instance + resobj.getJSONObject("avatar").get("path"));
|
account.setAvatar("https://" + instance + resobj.getJSONObject("avatar").get("path"));
|
||||||
account.setAvatar_static("https://" + instance + resobj.getJSONObject("avatar").get("path"));
|
account.setAvatar_static("https://" + instance + resobj.getJSONObject("avatar").get("path"));
|
||||||
} else
|
} else
|
||||||
account.setAvatar(null);
|
account.setAvatar(null);
|
||||||
account.setAvatar_static(resobj.get("avatar").toString());
|
account.setAvatar_static(resobj.getString("avatar"));
|
||||||
} catch (JSONException ignored) {
|
} catch (JSONException ignored) {
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -806,9 +806,9 @@ public class PeertubeAPI {
|
||||||
try {
|
try {
|
||||||
String response = new HttpsConnection(context).post(getAbsoluteUrl("/users/token"), 60, params, null);
|
String response = new HttpsConnection(context).post(getAbsoluteUrl("/users/token"), 60, params, null);
|
||||||
JSONObject resobj = new JSONObject(response);
|
JSONObject resobj = new JSONObject(response);
|
||||||
String token = resobj.get("access_token").toString();
|
String token = resobj.getString("access_token");
|
||||||
if (resobj.has("refresh_token"))
|
if (resobj.has("refresh_token"))
|
||||||
refresh_token = resobj.get("refresh_token").toString();
|
refresh_token = resobj.getString("refresh_token");
|
||||||
newValues.put("access_token", token);
|
newValues.put("access_token", token);
|
||||||
newValues.put("refresh_token", refresh_token);
|
newValues.put("refresh_token", refresh_token);
|
||||||
} catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException | HttpsConnection.HttpsConnectionException e) {
|
} catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException | HttpsConnection.HttpsConnectionException e) {
|
||||||
|
@ -1360,7 +1360,7 @@ public class PeertubeAPI {
|
||||||
try {
|
try {
|
||||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||||
String response = httpsConnection.get(getAbsoluteUrl(String.format("/users/me/videos/%s/rating", id)), 60, null, prefKeyOauthTokenT);
|
String response = httpsConnection.get(getAbsoluteUrl(String.format("/users/me/videos/%s/rating", id)), 60, null, prefKeyOauthTokenT);
|
||||||
return new JSONObject(response).get("rating").toString();
|
return new JSONObject(response).getString("rating");
|
||||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||||
setError(e.getStatusCode(), e);
|
setError(e.getStatusCode(), e);
|
||||||
} catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) {
|
} catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) {
|
||||||
|
@ -1741,11 +1741,11 @@ public class PeertubeAPI {
|
||||||
|
|
||||||
Instance instance = new Instance();
|
Instance instance = new Instance();
|
||||||
try {
|
try {
|
||||||
instance.setUri(resobj.get("uri").toString());
|
instance.setUri(resobj.getString("uri"));
|
||||||
instance.setTitle(resobj.get("title").toString());
|
instance.setTitle(resobj.getString("title"));
|
||||||
instance.setDescription(resobj.get("description").toString());
|
instance.setDescription(resobj.getString("description"));
|
||||||
instance.setEmail(resobj.get("email").toString());
|
instance.setEmail(resobj.getString("email"));
|
||||||
instance.setVersion(resobj.get("version").toString());
|
instance.setVersion(resobj.getString("version"));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
setDefaultError(e);
|
setDefaultError(e);
|
||||||
}
|
}
|
||||||
|
@ -1802,7 +1802,7 @@ public class PeertubeAPI {
|
||||||
String message = statusCode + " - " + error.getMessage();
|
String message = statusCode + " - " + error.getMessage();
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(error.getMessage()));
|
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(error.getMessage()));
|
||||||
String errorM = jsonObject.get("error").toString();
|
String errorM = jsonObject.getString("error");
|
||||||
message = "Error " + statusCode + " : " + errorM;
|
message = "Error " + statusCode + " : " + errorM;
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
if (error.getMessage().split(".").length > 0) {
|
if (error.getMessage().split(".").length > 0) {
|
||||||
|
|
|
@ -123,6 +123,7 @@ public class Helper {
|
||||||
public static String[] openid = {
|
public static String[] openid = {
|
||||||
"ac-normandie.fr",
|
"ac-normandie.fr",
|
||||||
"education.fr",
|
"education.fr",
|
||||||
|
"education.gouv.fr"
|
||||||
//TODO: remove this one used for tests
|
//TODO: remove this one used for tests
|
||||||
// "ac-orleans-tours.fr"
|
// "ac-orleans-tours.fr"
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue