diff options
Diffstat (limited to 'app/src')
-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"; } |