From 06a6b07a53fbfc70ff04bfa4c89f3b143e4da4fa Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Thu, 11 Feb 2021 14:47:43 -0500 Subject: [PATCH] cover lunar new year reel exception --- .../webservices/StoriesService.java | 93 ++++++++++--------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/webservices/StoriesService.java b/app/src/main/java/awais/instagrabber/webservices/StoriesService.java index 108bf86c..6cd3e43e 100644 --- a/app/src/main/java/awais/instagrabber/webservices/StoriesService.java +++ b/app/src/main/java/awais/instagrabber/webservices/StoriesService.java @@ -113,52 +113,55 @@ public class StoriesService extends BaseService { for (int i = 0; i < feedStoriesReel.length(); ++i) { final JSONObject node = feedStoriesReel.getJSONObject(i); final JSONObject userJson = node.getJSONObject(node.has("user") ? "user" : "owner"); - final User user = new User(userJson.getLong("pk"), - userJson.getString("username"), - userJson.optString("full_name"), - userJson.optBoolean("is_private"), - userJson.getString("profile_pic_url"), - null, - new FriendshipStatus( - false, - false, - false, - false, - false, - false, - false, - false, - false, - false - ), - userJson.optBoolean("is_verified"), - false, - false, - false, - false, - null, - null, - 0, - 0, - 0, - 0, - null, - null, - 0, - null, - null - ); - final String id = node.getString("id"); - final long timestamp = node.getLong("latest_reel_media"); - final int mediaCount = node.getInt("media_count"); - final boolean fullyRead = !node.isNull("seen") && node.getLong("seen") == timestamp; - final JSONObject itemJson = node.has("items") ? node.getJSONArray("items").optJSONObject(0) : null; - final boolean isBestie = node.optBoolean("has_besties_media", false); - StoryModel firstStoryModel = null; - if (itemJson != null) { - firstStoryModel = ResponseBodyUtils.parseStoryItem(itemJson, false, false, null); + try { + final User user = new User(userJson.getLong("pk"), + userJson.getString("username"), + userJson.optString("full_name"), + userJson.optBoolean("is_private"), + userJson.getString("profile_pic_url"), + null, + new FriendshipStatus( + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ), + userJson.optBoolean("is_verified"), + false, + false, + false, + false, + null, + null, + 0, + 0, + 0, + 0, + null, + null, + 0, + null, + null + ); + final String id = node.getString("id"); + final long timestamp = node.getLong("latest_reel_media"); + final int mediaCount = node.getInt("media_count"); + final boolean fullyRead = !node.isNull("seen") && node.getLong("seen") == timestamp; + final JSONObject itemJson = node.has("items") ? node.getJSONArray("items").optJSONObject(0) : null; + final boolean isBestie = node.optBoolean("has_besties_media", false); + StoryModel firstStoryModel = null; + if (itemJson != null) { + firstStoryModel = ResponseBodyUtils.parseStoryItem(itemJson, false, false, null); + } + feedStoryModels.add(new FeedStoryModel(id, user, fullyRead, timestamp, firstStoryModel, mediaCount, false, isBestie)); } - feedStoryModels.add(new FeedStoryModel(id, user, fullyRead, timestamp, firstStoryModel, mediaCount, false, isBestie)); + catch (Exception e) {} // to cover promotional reels with non-long user pk's } final JSONArray broadcasts = new JSONObject(body).getJSONArray("broadcasts"); for (int i = 0; i < broadcasts.length(); ++i) {