From a7b58cf0a410a1670aa9230cab4d05938caf6648 Mon Sep 17 00:00:00 2001 From: scria1000 <91804886+scria1000@users.noreply.github.com> Date: Mon, 20 Dec 2021 13:18:40 +0000 Subject: Support imgur gifv with audio (#602) Support imgur gifv videos with audio. --- .../activities/LinkResolverActivity.java | 2 + .../activities/ViewVideoActivity.java | 9 +++- .../adapters/PostDetailRecyclerViewAdapter.java | 10 +++- .../adapters/PostRecyclerViewAdapter.java | 15 ++++-- .../infinityforreddit/post/ParsePost.java | 61 +++++++++++++++++----- .../infinityforreddit/post/Post.java | 11 ++++ 6 files changed, 88 insertions(+), 20 deletions(-) (limited to 'app/src/main/java/ml/docilealligator') 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 fe7c89c3..a8c609f2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -261,6 +261,8 @@ public class LinkResolverActivity extends AppCompatActivity { startActivity(intent); } else if (path.endsWith("gifv")) { String url = uri.toString(); + // Insecure imgur links won't load + url = url.replaceFirst("http://" , "https://"); url = url.substring(0, url.length() - 5) + ".mp4"; Intent intent = new Intent(this, ViewVideoActivity.class); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index 2727e40a..b53ddf7e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -126,6 +126,7 @@ public class ViewVideoActivity extends AppCompatActivity { public static final String EXTRA_V_REDD_IT_URL = "EVRIU"; public static final String EXTRA_STREAMABLE_SHORT_CODE = "ESSC"; public static final String EXTRA_IS_NSFW = "EIN"; + public static final int VIDEO_TYPE_IMGUR = 7; public static final int VIDEO_TYPE_STREAMABLE = 5; public static final int VIDEO_TYPE_V_REDD_IT = 4; public static final int VIDEO_TYPE_DIRECT = 3; @@ -523,9 +524,13 @@ public class ViewVideoActivity extends AppCompatActivity { player.prepare(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri)); preparePlayer(savedInstanceState); } - } else if (videoType == VIDEO_TYPE_DIRECT) { + } else if (videoType == VIDEO_TYPE_DIRECT || videoType == VIDEO_TYPE_IMGUR) { videoDownloadUrl = mVideoUri.toString(); - videoFileName = FilenameUtils.getName(videoDownloadUrl); + if (videoType == VIDEO_TYPE_DIRECT) { + videoFileName = FilenameUtils.getName(videoDownloadUrl); + } else { + videoFileName = "imgur-" + FilenameUtils.getName(videoDownloadUrl); + } // Produces DataSource instances through which media data is loaded. dataSourceFactory = new CacheDataSourceFactory(mSimpleCache, new DefaultHttpDataSourceFactory(Util.getUserAgent(this, "Infinity"))); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 0f268f08..6b63a0c0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -1657,7 +1657,10 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter