diff options
author | stom79 <tschneider.ac@gmail.com> | 2019-01-09 17:30:18 +0100 |
---|---|---|
committer | stom79 <tschneider.ac@gmail.com> | 2019-01-09 17:30:18 +0100 |
commit | 15f0d4f3ecd154c110db43d651d4888521f782d4 (patch) | |
tree | ee80b4bd70ab8621579c3115967833133e8073bb /app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java | |
parent | 13759865b1e838bd9807f3c285ca74076145f22e (diff) |
Some fixes
Diffstat (limited to 'app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java')
-rw-r--r-- | app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java index 7ad38ab5a..52d4fbf22 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java @@ -489,6 +489,62 @@ public class PeertubeAPI { } + /** + * Retrieves videos for the account *synchronously* + * + * @param max_id String id max + * @return APIResponse + */ + public APIResponse getMyVideos(String max_id) { + return getMyVideos(max_id, null, tootPerPage); + } + + + + /** + * Retrieves status for the account *synchronously* + * + * @param max_id String id max + * @param since_id String since the id + * @param limit int limit - max value 40 + * @return APIResponse + */ + @SuppressWarnings("SameParameterValue") + private APIResponse getMyVideos(String max_id, String since_id, int limit) { + + HashMap<String, String> params = new HashMap<>(); + if (max_id != null) + params.put("start", max_id); + if (since_id != null) + params.put("since_id", since_id); + if (0 < limit || limit > 40) + limit = 40; + params.put("count", String.valueOf(limit)); + List<Peertube> peertubes = new ArrayList<>(); + try { + + HttpsConnection httpsConnection = new HttpsConnection(context); + String response = httpsConnection.get(getAbsoluteUrl("/users/me/videos"), 60, params, prefKeyOauthTokenT); + + JSONArray jsonArray = new JSONObject(response).getJSONArray("data"); + peertubes = parsePeertube(jsonArray); + + } catch (HttpsConnection.HttpsConnectionException e) { + setError(e.getStatusCode(), e); + e.printStackTrace(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (KeyManagementException e) { + e.printStackTrace(); + } catch (JSONException e) { + e.printStackTrace(); + } + apiResponse.setPeertubes(peertubes); + return apiResponse; + } + /** * Retrieves status for the account *synchronously* |