From 3b02cfb3678f1682f80d647372e79b767a9d5b79 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 30 Jun 2020 13:45:32 +0200 Subject: [PATCH] Fix playlist --- .../main/java/app/fedilab/fedilabtube/PeertubeActivity.java | 5 +++-- .../fedilabtube/asynctasks/ManagePlaylistsAsyncTask.java | 3 +++ .../java/app/fedilab/fedilabtube/client/PeertubeAPI.java | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 98c122b..fb11cb8 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -228,8 +228,9 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee initFullscreenDialog(); initFullscreenButton(); } - - new ManagePlaylistsAsyncTask(PeertubeActivity.this, GET_PLAYLIST, null, null, null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + if( Helper.isLoggedIn(PeertubeActivity.this)) { + new ManagePlaylistsAsyncTask(PeertubeActivity.this, GET_PLAYLIST, null, null, null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } new RetrievePeertubeSingleAsyncTask(PeertubeActivity.this, peertubeInstance, videoId, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } diff --git a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/ManagePlaylistsAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/ManagePlaylistsAsyncTask.java index 3db6c32..b319d08 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/ManagePlaylistsAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/ManagePlaylistsAsyncTask.java @@ -45,6 +45,9 @@ public class ManagePlaylistsAsyncTask extends AsyncTask { String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(contextReference.get())); SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); Account account = new AccountDAO(contextReference.get(), db).getUniqAccount(userId, instance); + if( account == null) { + account = new AccountDAO(contextReference.get(), db).getUniqAccount(userId, Helper.getPeertubeUrl(instance)); + } if (account == null) { statusCode = 403; apiResponse = new APIResponse(); 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 2a0bee1..b2bbeb0 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java @@ -1472,7 +1472,6 @@ public class PeertubeAPI { List ids = new ArrayList<>(); try { String response = new HttpsConnection(context).get(getAbsoluteUrl("/users/me/video-playlists/videos-exist"), 60, params, prefKeyOauthTokenT); - JSONArray jsonArray = new JSONObject(response).getJSONArray(videoId); try { int i = 0; @@ -1509,6 +1508,7 @@ public class PeertubeAPI { playlists = parsePlaylists(context, new JSONObject(response).getJSONArray("data")); } catch (HttpsConnection.HttpsConnectionException e) { setError(e.getStatusCode(), e); + e.printStackTrace(); } catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) { e.printStackTrace(); }