From 2bc7e40f78e7f23cdb662f03c38f39438dcc468c Mon Sep 17 00:00:00 2001 From: Zeb Piasecki Date: Mon, 25 Jan 2021 11:10:44 -0500 Subject: Fix issue with gfycat/redgifs occasionally 404ing due to non-lowercase id --- .../docilealligator/infinityforreddit/post/ParsePost.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'app/src') 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); } } } -- cgit v1.2.3 From 057f15ee708213f0bef77cc88b58f2df6fc54e63 Mon Sep 17 00:00:00 2001 From: iamveryfunny <77995063+iamveryfunny@users.noreply.github.com> Date: Mon, 25 Jan 2021 23:00:16 +0100 Subject: Update strings.xml --- app/src/main/res/values-de/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/src') diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 49aa330a..3368e0bc 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -47,7 +47,7 @@ "Faulheitsmodus stoppen" "Senden" "Sortieren" - "Beitrag verstecksn" + "Beitrag verstecken" "Beitrag wieder anzeigen" "Beitrag bearbeiten" "Beitrag löschen" @@ -904,4 +904,4 @@ Reiter könnten den Inhalt verlieren, wenn zu anderen gewechselt wird. Selbes Ve "Angewandt auf: Icon, welches den Tyo des Posts angibt, wenn keine Vorschau verfügbar ist" "Keine Post-Typ Hintergrundfarbe" "Angewandt auf: Platzhalter, der die Art des Beitrags angibt, wenn keine Vorschau verfügbar ist" - \ No newline at end of file + -- cgit v1.2.3