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 9fba9cdf..f8ce9884 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -296,8 +296,6 @@ public class LinkResolverActivity extends AppCompatActivity { startActivity(intent); } else if (path.endsWith("gifv") || path.endsWith("mp4")) { String url = uri.toString(); - // Insecure imgur links won't load - url = url.replaceFirst("http://" , "https://"); if (path.endsWith("gifv")) { url = url.substring(0, url.length() - 5) + ".mp4"; } 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 865d8fc5..b9fa2655 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -504,7 +504,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe loadStreamableVideo(shortCode, savedInstanceState); } else { dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); player.prepare(); player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); preparePlayer(savedInstanceState); @@ -536,7 +536,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe } } else { dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); player.prepare(); player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); preparePlayer(savedInstanceState); @@ -550,7 +550,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe } // Produces DataSource instances through which media data is loaded. dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); // Prepare the player with the source. player.prepare(); player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); @@ -562,7 +562,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe videoFileName = subredditName + "-" + id + ".mp4"; // Produces DataSource instances through which media data is loaded. dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); // Prepare the player with the source. player.prepare(); player.setMediaSource(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); @@ -693,7 +693,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe mVideoUri = Uri.parse(webm); videoDownloadUrl = mp4; dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); preparePlayer(savedInstanceState); player.prepare(); player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); @@ -723,7 +723,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe mVideoUri = Uri.parse(webm); videoDownloadUrl = mp4; dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); preparePlayer(savedInstanceState); player.prepare(); player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); @@ -789,7 +789,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe videoFileName = "imgur-" + FilenameUtils.getName(videoDownloadUrl); // Produces DataSource instances through which media data is loaded. dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); // Prepare the player with the source. player.prepare(); player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); @@ -805,7 +805,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe videoFileName = subredditName + "-" + id + ".mp4"; // Produces DataSource instances through which media data is loaded. dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); // Prepare the player with the source. preparePlayer(savedInstanceState); player.prepare(); @@ -848,7 +848,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe videoDownloadUrl = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile.url : streamableVideo.mp4.url; mVideoUri = Uri.parse(videoDownloadUrl); dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); preparePlayer(savedInstanceState); player.prepare(); player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java index 24dbab0c..67b6b74a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java @@ -148,7 +148,7 @@ public class ViewImgurVideoFragment extends Fragment { player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build(); videoPlayerView.setPlayer(player); dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); player.prepare(); player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(imgurMedia.getLink()))); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java index f71e9cc9..d58b139b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java @@ -158,7 +158,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment { player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build(); videoPlayerView.setPlayer(player); dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT)); + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); player.prepare(); player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(galleryVideo.url))); 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 d1bdd74c..f937cfcc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -379,9 +379,6 @@ public class ParsePost { String authority = uri.getAuthority(); // The hls stream inside REDDIT_VIDEO_PREVIEW_KEY can sometimes lack an audio track 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"; } @@ -438,8 +435,6 @@ public class ParsePost { // 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"; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/DefaultExoCreator.java b/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/DefaultExoCreator.java index dc1375b9..ddf321fd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/DefaultExoCreator.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/DefaultExoCreator.java @@ -79,7 +79,7 @@ public class DefaultExoCreator implements ExoCreator, MediaSourceEventListener { DataSource.Factory baseFactory = config.dataSourceFactory; if (baseFactory == null) { - baseFactory = new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT); + baseFactory = new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT); } DataSource.Factory factory = new DefaultDataSource.Factory(this.toro.context, baseFactory); if (config.cache != null)