mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-27 19:38:22 +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_TYPE, ViewImgurMediaActivity.IMGUR_TYPE_IMAGE);
|
||||||
intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_ID, path.substring(1));
|
intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_ID, path.substring(1));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (path.endsWith("gifv")) {
|
} else if (path.endsWith("gifv") || path.endsWith("mp4")) {
|
||||||
String url = uri.toString();
|
String url = uri.toString();
|
||||||
// Insecure imgur links won't load
|
// Insecure imgur links won't load
|
||||||
url = url.replaceFirst("http://" , "https://");
|
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 intent = new Intent(this, ViewVideoActivity.class);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false));
|
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false));
|
||||||
|
@ -378,9 +378,13 @@ public class ParsePost {
|
|||||||
Uri uri = Uri.parse(url);
|
Uri uri = Uri.parse(url);
|
||||||
String authority = uri.getAuthority();
|
String authority = uri.getAuthority();
|
||||||
// The hls stream inside REDDIT_VIDEO_PREVIEW_KEY can sometimes lack an audio track
|
// 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.endsWith(".mp4"))) {
|
||||||
if (authority.contains("imgur.com") && url.endsWith(".gifv")) {
|
// Insecure imgur links won't load
|
||||||
url = url.substring(0, url.length() - 5) + ".mp4";
|
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,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair,
|
||||||
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
|
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
|
||||||
@ -430,6 +434,24 @@ public class ParsePost {
|
|||||||
|
|
||||||
post.setPreviews(previews);
|
post.setPreviews(previews);
|
||||||
post.setVideoUrl(url);
|
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")) {
|
} else if (url.endsWith("mp4")) {
|
||||||
//Video post
|
//Video post
|
||||||
int postType = Post.VIDEO_TYPE;
|
int postType = Post.VIDEO_TYPE;
|
||||||
@ -441,22 +463,6 @@ public class ParsePost {
|
|||||||
post.setPreviews(previews);
|
post.setPreviews(previews);
|
||||||
post.setVideoUrl(url);
|
post.setVideoUrl(url);
|
||||||
post.setVideoDownloadUrl(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 {
|
} else {
|
||||||
if (url.contains(permalink)) {
|
if (url.contains(permalink)) {
|
||||||
//Text post but with a preview
|
//Text post but with a preview
|
||||||
|
Loading…
Reference in New Issue
Block a user