Skip to content

Commit

Permalink
Not loading images from i.redgifs.com because they are webpages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Docile-Alligator committed Nov 4, 2023
1 parent 975046f commit 66ce420
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,14 @@ private static Post parseData(JSONObject data, String permalink, String id, Stri
spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort);

if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", ""));
if ("i.redgifs.com".equals(uri.getAuthority())) {
//No preview link (Not able to load redgifs image)
post.setPostType(Post.NO_PREVIEW_LINK_TYPE);
} else {
previews.add(new Post.Preview(url, 0, 0, "", ""));
}
} else if ("i.redgifs.com".equals(uri.getAuthority())) {
post.setUrl(previews.get(previews.size() - 1).getPreviewUrl());
}
post.setPreviews(previews);
} else {
Expand Down Expand Up @@ -423,7 +430,14 @@ private static Post parseData(JSONObject data, String permalink, String id, Stri
distinguished, suggestedSort);

if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", ""));
if ("i.redgifs.com".equals(uri.getAuthority())) {
//No preview link (Not able to load redgifs image)
post.setPostType(Post.NO_PREVIEW_LINK_TYPE);
} else {
previews.add(new Post.Preview(url, 0, 0, "", ""));
}
} else if ("i.redgifs.com".equals(uri.getAuthority())) {
post.setUrl(previews.get(previews.size() - 1).getPreviewUrl());
}
post.setPreviews(previews);
} else if (path.endsWith(".gif")) {
Expand Down Expand Up @@ -533,7 +547,14 @@ private static Post parseData(JSONObject data, String permalink, String id, Stri
spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort);

if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", ""));
if ("i.redgifs.com".equals(uri.getAuthority())) {
//No preview link (Not able to load redgifs image)
post.setPostType(Post.NO_PREVIEW_LINK_TYPE);
} else {
previews.add(new Post.Preview(url, 0, 0, "", ""));
}
} else if ("i.redgifs.com".equals(uri.getAuthority())) {
post.setUrl(previews.get(previews.size() - 1).getPreviewUrl());
}
post.setPreviews(previews);
} else if (path.endsWith(".mp4")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public Post[] newArray(int size) {
private ArrayList<Preview> previews = new ArrayList<>();
private ArrayList<Gallery> gallery = new ArrayList<>();

//Text and video posts
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
String author, String authorFlair, String authorFlairHTML, long postTimeMillis,
String title, String permalink, int score, int postType, int voteType, int nComments,
Expand Down

0 comments on commit 66ce420

Please sign in to comment.