mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-27 03:18:24 +01:00
Fix Imgur bug for insecure mp4 links (#1240)
This commit is contained in:
parent
69ba6461ff
commit
9a3b9115ff
@ -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));
|
||||
|
@ -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,6 +434,24 @@ public class ParsePost {
|
||||
|
||||
post.setPreviews(previews);
|
||||
post.setVideoUrl(url);
|
||||
} 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,
|
||||
hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
|
||||
post.setPreviews(previews);
|
||||
post.setVideoUrl(url);
|
||||
post.setVideoDownloadUrl(url);
|
||||
post.setIsImgur(true);
|
||||
} else if (url.endsWith("mp4")) {
|
||||
//Video post
|
||||
int postType = Post.VIDEO_TYPE;
|
||||
@ -441,22 +463,6 @@ 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
|
||||
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,
|
||||
hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
|
||||
post.setPreviews(previews);
|
||||
post.setVideoUrl(url);
|
||||
post.setVideoDownloadUrl(url);
|
||||
post.setIsImgur(true);
|
||||
} else {
|
||||
if (url.contains(permalink)) {
|
||||
//Text post but with a preview
|
||||
|
Loading…
Reference in New Issue
Block a user