diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-01-24 02:56:44 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-01-24 02:56:44 +0000 |
commit | 96a8230d39bb80f86a9c431f1e5ad34af767cf60 (patch) | |
tree | f971c8834447578270f5ab369458c49d0517aa98 /app | |
parent | 0402a4709058a222d4efb6844cf3065346fcbe4f (diff) | |
download | infinity-for-reddit-96a8230d39bb80f86a9c431f1e5ad34af767cf60.tar infinity-for-reddit-96a8230d39bb80f86a9c431f1e5ad34af767cf60.tar.gz infinity-for-reddit-96a8230d39bb80f86a9c431f1e5ad34af767cf60.tar.bz2 infinity-for-reddit-96a8230d39bb80f86a9c431f1e5ad34af767cf60.tar.lz infinity-for-reddit-96a8230d39bb80f86a9c431f1e5ad34af767cf60.tar.xz infinity-for-reddit-96a8230d39bb80f86a9c431f1e5ad34af767cf60.tar.zst infinity-for-reddit-96a8230d39bb80f86a9c431f1e5ad34af767cf60.zip |
Fix gfycat and redgifs API.
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java | 16 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java | 1 |
2 files changed, 13 insertions, 4 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java index 0aeb5eeb..c59f66a6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java @@ -1,6 +1,7 @@ package ml.docilealligator.infinityforreddit; import android.os.AsyncTask; +import android.util.Log; import androidx.annotation.NonNull; @@ -34,6 +35,7 @@ public class FetchGfycatOrRedgifsVideoLinks { gfycatRetrofit.create(GfycatAPI.class).getGfycatData(gfycatId).enqueue(new Callback<String>() { @Override public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { + Log.i("asdfasf", "s " + response.body()); if (response.isSuccessful()) { new ParseGfycatVideoLinksAsyncTask(response.body(), fetchGfycatOrRedgifsVideoLinksListener).execute(); } else { @@ -100,16 +102,22 @@ public class FetchGfycatOrRedgifsVideoLinks { protected Void doInBackground(Void... voids) { try { JSONObject jsonObject = new JSONObject(response); - webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY) - .getJSONObject(JSONUtils.CONTENT_URLS_KEY) - .getJSONObject(JSONUtils.WEBM_KEY) - .getString(JSONUtils.URL_KEY); mp4 = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).has(JSONUtils.MP4_URL_KEY) ? jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getString(JSONUtils.MP4_URL_KEY) : jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY) .getJSONObject(JSONUtils.CONTENT_URLS_KEY) .getJSONObject(JSONUtils.MP4_KEY) .getString(JSONUtils.URL_KEY); + if (jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).has(JSONUtils.WEBM_URL_KEY)) { + webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getString(JSONUtils.WEBM_URL_KEY); + } else if (jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getJSONObject(JSONUtils.CONTENT_URLS_KEY).has(JSONUtils.WEBM_KEY)) { + webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY) + .getJSONObject(JSONUtils.CONTENT_URLS_KEY) + .getJSONObject(JSONUtils.WEBM_KEY) + .getString(JSONUtils.URL_KEY); + } else { + webm = mp4; + } } catch (JSONException e) { e.printStackTrace(); parseFailed = true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java index 989df80f..085ee905 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java @@ -131,4 +131,5 @@ public class JSONUtils { public static final String AWARDEE_KARMA_KEY = "awardee_karma"; public static final String CONTENT_URLS_KEY = "content_urls";; public static final String WEBM_KEY = "webm"; + public static final String WEBM_URL_KEY = "webmUrl"; } |