|
|
@ -1160,23 +1160,6 @@ public final class Utils { |
|
|
|
return "[]"; |
|
|
|
} |
|
|
|
|
|
|
|
@NonNull |
|
|
|
public static String iHighlightIdsMerger(final String... strings) { |
|
|
|
if (strings != null) { |
|
|
|
int iMax = strings.length - 1; |
|
|
|
if (iMax != -1) { |
|
|
|
final StringBuilder builder = new StringBuilder(); |
|
|
|
for (int i = 0; ; i++) { |
|
|
|
builder.append(strings[i]); |
|
|
|
if (i == iMax) return builder.toString(); |
|
|
|
builder.append("&reel_ids="); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
public static void putHighlightModels(final HttpURLConnection conn, final Object[] model) throws Exception { |
|
|
|
final boolean isHighlightModel = model instanceof HighlightModel[]; |
|
|
|
final boolean isFeedStoryModel = model instanceof FeedStoryModel[]; |
|
|
@ -1246,75 +1229,6 @@ public final class Utils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void iPutFeedStoryModels(final HttpURLConnection conn, final FeedStoryModel[] model, final String[] ids) throws Exception { |
|
|
|
final JSONObject highlightsMediaReel = new JSONObject(Utils.readFromConnection(conn)).getJSONObject("reels"); |
|
|
|
final int mediaLength = highlightsMediaReel.length(); |
|
|
|
|
|
|
|
for (int i = 0; i < mediaLength; ++i) { |
|
|
|
final JSONArray items = highlightsMediaReel.getJSONObject(ids[i]).getJSONArray("items"); |
|
|
|
final int itemsLen = items.length(); |
|
|
|
|
|
|
|
final StoryModel[] storyModels = new StoryModel[itemsLen]; |
|
|
|
for (int j = 0; j < itemsLen; ++j) { |
|
|
|
final JSONObject data = items.getJSONObject(j); |
|
|
|
final boolean isVideo = data.has("video_duration"); |
|
|
|
|
|
|
|
storyModels[j] = new StoryModel(data.getString("pk"), |
|
|
|
data.getJSONObject("image_versions2").getJSONArray("candidates").getJSONObject(0).getString("url"), |
|
|
|
isVideo ? MediaItemType.MEDIA_TYPE_VIDEO : MediaItemType.MEDIA_TYPE_IMAGE, |
|
|
|
data.optLong("taken_at", 0), |
|
|
|
model[i].getProfileModel().getUsername()); |
|
|
|
|
|
|
|
final JSONArray videoResources = data.optJSONArray("video_versions"); |
|
|
|
if (isVideo && videoResources != null) |
|
|
|
storyModels[j].setVideoUrl(Utils.getHighQualityPost(videoResources, true, true)); |
|
|
|
|
|
|
|
if (data.has("story_feed_media")) { |
|
|
|
storyModels[j].setTappableShortCode(data.getJSONArray("story_feed_media").getJSONObject(0).optString("media_id")); |
|
|
|
} |
|
|
|
|
|
|
|
if (!data.isNull("story_app_attribution")) |
|
|
|
storyModels[j].setSpotify(data.getJSONObject("story_app_attribution").optString("content_url").split("\\?")[0]); |
|
|
|
|
|
|
|
if (data.has("story_polls")) { |
|
|
|
JSONObject tappableObject = data.optJSONArray("story_polls").getJSONObject(0).optJSONObject("poll_sticker"); |
|
|
|
if (tappableObject != null) storyModels[j].setPoll(new PollModel( |
|
|
|
String.valueOf(tappableObject.getLong("poll_id")), |
|
|
|
tappableObject.getString("question"), |
|
|
|
tappableObject.getJSONArray("tallies").getJSONObject(0).getString("text"), |
|
|
|
tappableObject.getJSONArray("tallies").getJSONObject(0).getInt("count"), |
|
|
|
tappableObject.getJSONArray("tallies").getJSONObject(1).getString("text"), |
|
|
|
tappableObject.getJSONArray("tallies").getJSONObject(1).getInt("count"), |
|
|
|
tappableObject.optInt("viewer_vote", -1) |
|
|
|
)); |
|
|
|
} |
|
|
|
if (data.has("story_questions")) { |
|
|
|
JSONObject tappableObject = data.getJSONArray("story_questions").getJSONObject(0).optJSONObject("question_sticker"); |
|
|
|
if (tappableObject != null) storyModels[j].setQuestion(new QuestionModel( |
|
|
|
String.valueOf(tappableObject.getLong("question_id")), |
|
|
|
tappableObject.getString("question") |
|
|
|
)); |
|
|
|
} |
|
|
|
JSONArray hashtags = data.optJSONArray("story_hashtags"); |
|
|
|
JSONArray atmarks = data.optJSONArray("reel_mentions"); |
|
|
|
String[] mentions = new String[(hashtags == null ? 0 : hashtags.length()) + (atmarks == null ? 0 : atmarks.length())]; |
|
|
|
if (hashtags != null) { |
|
|
|
for (int h = 0; h < hashtags.length(); ++h) { |
|
|
|
mentions[h] = "#"+hashtags.getJSONObject(h).getJSONObject("hashtag").getString("name"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (atmarks != null) { |
|
|
|
for (int h = 0; h < atmarks.length(); ++h) { |
|
|
|
mentions[h + (hashtags == null ? 0 : hashtags.length())] = |
|
|
|
"@"+atmarks.getJSONObject(h).getJSONObject("user").getString("username"); |
|
|
|
} |
|
|
|
} |
|
|
|
storyModels[j].setMentions(mentions); |
|
|
|
} |
|
|
|
model[i].setStoryModels(storyModels); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static String sign(final String message) { |
|
|
|
try { |
|
|
|
Mac hasher = Mac.getInstance("HmacSHA256"); |
|
|
|