aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDocile-Alligator <chineseperson5@gmail.com>2021-02-02 10:58:55 +0000
committerGitHub <noreply@github.com>2021-02-02 10:58:55 +0000
commit0d513b76f8304bb9487b468caf878dee358c7849 (patch)
treef37fdff6a5536b6e0d7b51405ac592857962b518 /app
parentc0cb024eb99be74c36ea422df5731b09a0d5d570 (diff)
parent2bc7e40f78e7f23cdb662f03c38f39438dcc468c (diff)
downloadinfinity-for-reddit-0d513b76f8304bb9487b468caf878dee358c7849.tar
infinity-for-reddit-0d513b76f8304bb9487b468caf878dee358c7849.tar.gz
infinity-for-reddit-0d513b76f8304bb9487b468caf878dee358c7849.tar.bz2
infinity-for-reddit-0d513b76f8304bb9487b468caf878dee358c7849.tar.lz
infinity-for-reddit-0d513b76f8304bb9487b468caf878dee358c7849.tar.xz
infinity-for-reddit-0d513b76f8304bb9487b468caf878dee358c7849.tar.zst
infinity-for-reddit-0d513b76f8304bb9487b468caf878dee358c7849.zip
Merge pull request #261 from vlakreeh/fix-gfycat-case-sensitive
Fix issue with gifs not playing with invalid gfycat id
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
index 809f0806..2ba685eb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
@@ -403,7 +403,7 @@ public class ParsePost {
if (gfycatId.contains("-")) {
gfycatId = gfycatId.substring(0, gfycatId.indexOf('-'));
}
- post.setGfycatId(gfycatId);
+ post.setGfycatId(gfycatId.toLowerCase());
} else if (authority != null && authority.contains("redgifs.com")) {
String gfycatId = url.substring(url.lastIndexOf("/") + 1);
if (gfycatId.contains("-")) {
@@ -411,7 +411,7 @@ public class ParsePost {
}
post.setIsRedgifs(true);
post.setVideoUrl(url);
- post.setGfycatId(gfycatId);
+ post.setGfycatId(gfycatId.toLowerCase());
}
} catch (IllegalArgumentException ignore) { }
} else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
@@ -449,16 +449,21 @@ public class ParsePost {
} else if (post.getPostType() == Post.LINK_TYPE) {
Uri uri = Uri.parse(url);
String authority = uri.getAuthority();
+
+ // Gyfcat ids must be lowercase to resolve to a video through the api, we are not
+ // guaranteed to get an id that is all lowercase.
+ String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase();
+
if (authority != null && (authority.contains("gfycat.com"))) {
post.setPostType(Post.VIDEO_TYPE);
post.setIsGfycat(true);
post.setVideoUrl(url);
- post.setGfycatId(url.substring(url.lastIndexOf("/") + 1));
+ post.setGfycatId(gfycatId);
} else if (authority != null && authority.contains("redgifs.com")) {
post.setPostType(Post.VIDEO_TYPE);
post.setIsRedgifs(true);
post.setVideoUrl(url);
- post.setGfycatId(url.substring(url.lastIndexOf("/") + 1));
+ post.setGfycatId(gfycatId);
}
}
}