aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java30
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