diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-02-03 01:58:46 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-02-03 01:58:46 +0000 |
commit | 6f64303df8c776cf187d3e8820b67c1901804815 (patch) | |
tree | bf839d9af43d70dde1ee80a0e3c4d60caeecfba5 /app/src/main/java | |
parent | 36c7cfcc6bd9b3be1eb51303d2c3448e85401eac (diff) | |
download | infinity-for-reddit-6f64303df8c776cf187d3e8820b67c1901804815.tar infinity-for-reddit-6f64303df8c776cf187d3e8820b67c1901804815.tar.gz infinity-for-reddit-6f64303df8c776cf187d3e8820b67c1901804815.tar.bz2 infinity-for-reddit-6f64303df8c776cf187d3e8820b67c1901804815.tar.lz infinity-for-reddit-6f64303df8c776cf187d3e8820b67c1901804815.tar.xz infinity-for-reddit-6f64303df8c776cf187d3e8820b67c1901804815.tar.zst infinity-for-reddit-6f64303df8c776cf187d3e8820b67c1901804815.zip |
Make all gifcay id all lower case.
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java | 13 |
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); } } } |