diff options
author | scria1000 <91804886+scria1000@users.noreply.github.com> | 2022-11-27 12:17:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-27 12:17:39 +0000 |
commit | 9a3b9115ffd8492c7a64c285ae90df067ac764e7 (patch) | |
tree | 2234ce74b293ed30d91de4adbb733629a1397fb5 /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | 69ba6461ff5743d60911ea57a60983be78685b72 (diff) | |
download | infinity-for-reddit-9a3b9115ffd8492c7a64c285ae90df067ac764e7.tar infinity-for-reddit-9a3b9115ffd8492c7a64c285ae90df067ac764e7.tar.gz infinity-for-reddit-9a3b9115ffd8492c7a64c285ae90df067ac764e7.tar.bz2 infinity-for-reddit-9a3b9115ffd8492c7a64c285ae90df067ac764e7.tar.lz infinity-for-reddit-9a3b9115ffd8492c7a64c285ae90df067ac764e7.tar.xz infinity-for-reddit-9a3b9115ffd8492c7a64c285ae90df067ac764e7.tar.zst infinity-for-reddit-9a3b9115ffd8492c7a64c285ae90df067ac764e7.zip |
Fix Imgur bug for insecure mp4 links (#1240)
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java | 6 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java | 30 |
2 files changed, 22 insertions, 14 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java index 748d7b53..5bba98bc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -299,11 +299,13 @@ public class LinkResolverActivity extends AppCompatActivity { intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_TYPE, ViewImgurMediaActivity.IMGUR_TYPE_IMAGE); intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_ID, path.substring(1)); startActivity(intent); - } else if (path.endsWith("gifv")) { + } else if (path.endsWith("gifv") || path.endsWith("mp4")) { String url = uri.toString(); // Insecure imgur links won't load url = url.replaceFirst("http://" , "https://"); - url = url.substring(0, url.length() - 5) + ".mp4"; + if (path.endsWith("gifv")) { + url = url.substring(0, url.length() - 5) + ".mp4"; + } Intent intent = new Intent(this, ViewVideoActivity.class); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false)); 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 dddb4d69..d1bdd74c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -378,9 +378,13 @@ public class ParsePost { Uri uri = Uri.parse(url); String authority = uri.getAuthority(); // The hls stream inside REDDIT_VIDEO_PREVIEW_KEY can sometimes lack an audio track - // This happens with imgur gifv that are actually mp4, even the official Reddit app has this bug - if (authority.contains("imgur.com") && url.endsWith(".gifv")) { - url = url.substring(0, url.length() - 5) + ".mp4"; + if (authority.contains("imgur.com") && (url.endsWith(".gifv") || url.endsWith(".mp4"))) { + // Insecure imgur links won't load + url = url.replaceFirst("http://" , "https://"); + + if (url.endsWith("gifv")) { + url = url.substring(0, url.length() - 5) + ".mp4"; + } post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, @@ -430,10 +434,16 @@ public class ParsePost { post.setPreviews(previews); post.setVideoUrl(url); - } else if (url.endsWith("mp4")) { - //Video post + } else if (Uri.parse(url).getAuthority().contains("imgur.com") && (url.endsWith("gifv") || url.endsWith("mp4"))) { + // Imgur gifv/mp4 int postType = Post.VIDEO_TYPE; + // Insecure imgur links won't load + url = url.replaceFirst("http://" , "https://"); + if (url.endsWith("gifv")) { + url = url.substring(0, url.length() - 5) + ".mp4"; + } + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, @@ -441,14 +451,11 @@ public class ParsePost { post.setPreviews(previews); post.setVideoUrl(url); post.setVideoDownloadUrl(url); - } else if (url.endsWith("gifv") && Objects.equals(Uri.parse(url).getAuthority(), "i.imgur.com")) { - // Imgur gifv/mp4 + post.setIsImgur(true); + } else if (url.endsWith("mp4")) { + //Video post int postType = Post.VIDEO_TYPE; - // Insecure imgur links won't load - url = url.replaceFirst("http://" , "https://"); - url = url.substring(0, url.length() - 5) + ".mp4"; - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, @@ -456,7 +463,6 @@ public class ParsePost { post.setPreviews(previews); post.setVideoUrl(url); post.setVideoDownloadUrl(url); - post.setIsImgur(true); } else { if (url.contains(permalink)) { //Text post but with a preview |