Prevent a potential parsing error using the gfycat API.

This commit is contained in:
Alex Ning 2021-01-23 09:56:13 +08:00
parent f17350cc1d
commit 54ef23c357

View File

@ -104,7 +104,12 @@ public class FetchGfycatOrRedgifsVideoLinks {
.getJSONObject(JSONUtils.CONTENT_URLS_KEY)
.getJSONObject(JSONUtils.WEBM_KEY)
.getString(JSONUtils.URL_KEY);
mp4 = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getString(JSONUtils.MP4_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);
} catch (JSONException e) {
e.printStackTrace();
parseFailed = true;