From 44b431b533a7b9e94cf1bcdd2f246726ae178aa3 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Fri, 13 Nov 2020 18:37:19 -0500 Subject: [PATCH] fix feed oops --- .../awais/instagrabber/utils/ResponseBodyUtils.java | 1 + .../awais/instagrabber/webservices/FeedService.java | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java b/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java index 9d552796..387e8aaf 100644 --- a/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java @@ -671,6 +671,7 @@ public final class ResponseBodyUtils { } final JSONObject feedItem = itemJson.getJSONObject("node"); final String mediaType = feedItem.optString("__typename"); + if ("GraphSuggestedUserFeedUnit".equals(mediaType)) return null; final boolean isVideo = feedItem.optBoolean("is_video"); final long videoViews = feedItem.optLong("video_view_count", 0); diff --git a/app/src/main/java/awais/instagrabber/webservices/FeedService.java b/app/src/main/java/awais/instagrabber/webservices/FeedService.java index cfdb1ab4..d4e84e35 100644 --- a/app/src/main/java/awais/instagrabber/webservices/FeedService.java +++ b/app/src/main/java/awais/instagrabber/webservices/FeedService.java @@ -84,10 +84,10 @@ public class FeedService extends BaseService { return; } final Map queryMap = new HashMap<>(); - queryMap.put("query_hash", "6b838488258d7a4820e48d209ef79eb1"); + queryMap.put("query_hash", "c699b185975935ae2a457f24075de8c7"); queryMap.put("variables", "{" + "\"fetch_media_item_count\":" + maxItemsToLoad + "," + - "\"has_threaded_comments\":true," + + "\"fetch_like\":3,\"has_stories\":false,\"has_stories\":false,\"has_threaded_comments\":true," + "\"fetch_media_item_cursor\":\"" + (cursor == null ? "" : cursor) + "\"" + "}"); final Call request = repository.fetch(queryMap); @@ -154,8 +154,10 @@ public class FeedService extends BaseService { if (itemJson == null) { continue; } - final FeedModel feedModel = ResponseBodyUtils.parseItem(itemJson); - feedModels.add(feedModel); + final FeedModel feedModel = ResponseBodyUtils.parseGraphQLItem(itemJson); + if (feedModel != null) { + feedModels.add(feedModel); + } } return new PostsFetchResponse(feedModels, hasNextPage, endCursor); }