mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Fix redgifs download issues.
This commit is contained in:
parent
61da952b7b
commit
f70721d7fd
@ -125,7 +125,7 @@ class AppModule {
|
|||||||
.addInterceptor(chain -> chain.proceed(
|
.addInterceptor(chain -> chain.proceed(
|
||||||
chain.request()
|
chain.request()
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.header("User-Agent", APIUtils.getRedgifsUserAgent(mApplication))
|
.header("User-Agent", APIUtils.USER_AGENT)
|
||||||
.build()
|
.build()
|
||||||
))
|
))
|
||||||
.addInterceptor(new RedgifsAccessTokenAuthenticator(currentAccountSharedPreferences))
|
.addInterceptor(new RedgifsAccessTokenAuthenticator(currentAccountSharedPreferences))
|
||||||
|
@ -51,7 +51,7 @@ public class FetchGfycatOrRedgifsVideoLinks {
|
|||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(currentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")),
|
Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(currentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")),
|
||||||
gfycatId, APIUtils.getRedgifsUserAgent(context)).execute();
|
gfycatId, APIUtils.USER_AGENT).execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
|
parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,7 +6,6 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
|
|||||||
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
|
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@ -25,7 +24,6 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.OrientationEventListener;
|
import android.view.OrientationEventListener;
|
||||||
@ -40,6 +38,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
@ -505,7 +504,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
loadStreamableVideo(shortCode, savedInstanceState);
|
loadStreamableVideo(shortCode, savedInstanceState);
|
||||||
} else {
|
} else {
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(ViewVideoActivity.this)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
@ -537,7 +536,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(ViewVideoActivity.this)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
@ -551,7 +550,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
}
|
}
|
||||||
// Produces DataSource instances through which media data is loaded.
|
// Produces DataSource instances through which media data is loaded.
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(ViewVideoActivity.this)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -563,7 +562,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
videoFileName = subredditName + "-" + id + ".mp4";
|
videoFileName = subredditName + "-" + id + ".mp4";
|
||||||
// Produces DataSource instances through which media data is loaded.
|
// Produces DataSource instances through which media data is loaded.
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(ViewVideoActivity.this)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -625,13 +624,12 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
if (videoType == VIDEO_TYPE_NORMAL) {
|
if (videoType == VIDEO_TYPE_NORMAL) {
|
||||||
hdButton.setVisibility(View.VISIBLE);
|
hdButton.setVisibility(View.VISIBLE);
|
||||||
hdButton.setOnClickListener(view -> {
|
hdButton.setOnClickListener(view -> {
|
||||||
TrackSelectionDialogBuilder builder = new TrackSelectionDialogBuilder(ViewVideoActivity.this, getString(R.string.select_video_quality), player, 0);
|
TrackSelectionDialogBuilder builder = new TrackSelectionDialogBuilder(ViewVideoActivity.this, getString(R.string.select_video_quality), player, C.TRACK_TYPE_VIDEO);
|
||||||
builder.setShowDisableOption(true);
|
builder.setShowDisableOption(true);
|
||||||
builder.setAllowAdaptiveSelections(false);
|
builder.setAllowAdaptiveSelections(false);
|
||||||
Dialog dialog = builder.build();
|
Dialog dialog = builder.setTheme(R.style.MaterialAlertDialogTheme).build();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
if (dialog instanceof AlertDialog) {
|
if (dialog instanceof AlertDialog) {
|
||||||
Log.i("asfadsf", "asdfasdf");
|
|
||||||
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
}
|
}
|
||||||
@ -695,7 +693,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
mVideoUri = Uri.parse(webm);
|
mVideoUri = Uri.parse(webm);
|
||||||
videoDownloadUrl = mp4;
|
videoDownloadUrl = mp4;
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(ViewVideoActivity.this)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -725,7 +723,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
mVideoUri = Uri.parse(webm);
|
mVideoUri = Uri.parse(webm);
|
||||||
videoDownloadUrl = mp4;
|
videoDownloadUrl = mp4;
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(ViewVideoActivity.this)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -791,7 +789,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
videoFileName = "imgur-" + FilenameUtils.getName(videoDownloadUrl);
|
videoFileName = "imgur-" + FilenameUtils.getName(videoDownloadUrl);
|
||||||
// Produces DataSource instances through which media data is loaded.
|
// Produces DataSource instances through which media data is loaded.
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(ViewVideoActivity.this)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
@ -807,7 +805,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
videoFileName = subredditName + "-" + id + ".mp4";
|
videoFileName = subredditName + "-" + id + ".mp4";
|
||||||
// Produces DataSource instances through which media data is loaded.
|
// Produces DataSource instances through which media data is loaded.
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(ViewVideoActivity.this)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
@ -850,7 +848,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
videoDownloadUrl = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile.url : streamableVideo.mp4.url;
|
videoDownloadUrl = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile.url : streamableVideo.mp4.url;
|
||||||
mVideoUri = Uri.parse(videoDownloadUrl);
|
mVideoUri = Uri.parse(videoDownloadUrl);
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(ViewVideoActivity.this)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
|
||||||
|
@ -43,8 +43,6 @@ import com.bumptech.glide.request.RequestListener;
|
|||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.google.android.exoplayer2.Tracks;
|
import com.google.android.exoplayer2.Tracks;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
import com.google.android.exoplayer2.ui.PlayerView;
|
import com.google.android.exoplayer2.ui.PlayerView;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -681,7 +679,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
|
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
|
||||||
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.getRedgifsUserAgent(mActivity));
|
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
|
||||||
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
||||||
post.isGfycat(), mAutomaticallyTryRedgifs,
|
post.isGfycat(), mAutomaticallyTryRedgifs,
|
||||||
@ -843,7 +841,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
|
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
|
||||||
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.getRedgifsUserAgent(mActivity));
|
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
|
||||||
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
||||||
post.isGfycat(), mAutomaticallyTryRedgifs,
|
post.isGfycat(), mAutomaticallyTryRedgifs,
|
||||||
|
@ -681,7 +681,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) {
|
if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
mPost.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(mPost.getGfycatId()) :
|
mPost.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(mPost.getGfycatId()) :
|
||||||
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), mPost.getGfycatId(), APIUtils.getRedgifsUserAgent(mActivity));
|
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), mPost.getGfycatId(), APIUtils.USER_AGENT);
|
||||||
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
||||||
mPost.isGfycat(), mAutomaticallyTryRedgifs,
|
mPost.isGfycat(), mAutomaticallyTryRedgifs,
|
||||||
|
@ -43,8 +43,6 @@ import com.bumptech.glide.request.RequestListener;
|
|||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.google.android.exoplayer2.Tracks;
|
import com.google.android.exoplayer2.Tracks;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
import com.google.android.exoplayer2.ui.PlayerView;
|
import com.google.android.exoplayer2.ui.PlayerView;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -712,7 +710,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
|
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
|
||||||
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.getRedgifsUserAgent(mActivity));
|
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
|
||||||
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
||||||
post.isGfycat(), mAutomaticallyTryRedgifs,
|
post.isGfycat(), mAutomaticallyTryRedgifs,
|
||||||
@ -878,7 +876,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
|
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
|
||||||
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.getRedgifsUserAgent(mActivity));
|
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
|
||||||
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
||||||
post.isGfycat(), mAutomaticallyTryRedgifs,
|
post.isGfycat(), mAutomaticallyTryRedgifs,
|
||||||
|
@ -148,7 +148,7 @@ public class ViewImgurVideoFragment extends Fragment {
|
|||||||
player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build();
|
player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build();
|
||||||
videoPlayerView.setPlayer(player);
|
videoPlayerView.setPlayer(player);
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(activity)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(imgurMedia.getLink())));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(imgurMedia.getLink())));
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ public class ViewRPANBroadcastFragment extends Fragment {
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
if (dataSourceFactory == null) {
|
if (dataSourceFactory == null) {
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(mActivity)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(rpanBroadcast.rpanStream.hlsUrl)));
|
player.setMediaSource(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(rpanBroadcast.rpanStream.hlsUrl)));
|
||||||
|
@ -158,7 +158,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment {
|
|||||||
player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build();
|
player = new ExoPlayer.Builder(activity).setTrackSelector(trackSelector).build();
|
||||||
videoPlayerView.setPlayer(player);
|
videoPlayerView.setPlayer(player);
|
||||||
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
|
||||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(activity)));
|
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT));
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(galleryVideo.url)));
|
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(galleryVideo.url)));
|
||||||
|
|
||||||
|
@ -46,10 +46,12 @@ import ml.docilealligator.infinityforreddit.apis.DownloadFile;
|
|||||||
import ml.docilealligator.infinityforreddit.broadcastreceivers.DownloadedMediaDeleteActionBroadcastReceiver;
|
import ml.docilealligator.infinityforreddit.broadcastreceivers.DownloadedMediaDeleteActionBroadcastReceiver;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.events.DownloadMediaEvent;
|
import ml.docilealligator.infinityforreddit.events.DownloadMediaEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.NotificationUtils;
|
import ml.docilealligator.infinityforreddit.utils.NotificationUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
import retrofit2.Call;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@ -130,6 +132,12 @@ public class DownloadMediaService extends Service {
|
|||||||
.body(new DownloadProgressResponseBody(originalResponse.body(), progressListener))
|
.body(new DownloadProgressResponseBody(originalResponse.body(), progressListener))
|
||||||
.build();
|
.build();
|
||||||
})
|
})
|
||||||
|
.addInterceptor(chain -> chain.proceed(
|
||||||
|
chain.request()
|
||||||
|
.newBuilder()
|
||||||
|
.header("User-Agent", APIUtils.USER_AGENT)
|
||||||
|
.build()
|
||||||
|
))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
retrofit = retrofit.newBuilder().client(client).build();
|
retrofit = retrofit.newBuilder().client(client).build();
|
||||||
@ -140,7 +148,8 @@ public class DownloadMediaService extends Service {
|
|||||||
String destinationFileUriString = null;
|
String destinationFileUriString = null;
|
||||||
boolean isDefaultDestination = true;
|
boolean isDefaultDestination = true;
|
||||||
try {
|
try {
|
||||||
response = retrofit.create(DownloadFile.class).downloadFile(fileUrl).execute();
|
Call<ResponseBody> call = retrofit.create(DownloadFile.class).downloadFile(fileUrl);
|
||||||
|
response = call.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
String destinationFileDirectory = getDownloadLocation(mediaType, isNsfw);
|
String destinationFileDirectory = getDownloadLocation(mediaType, isNsfw);
|
||||||
if (destinationFileDirectory.equals("")) {
|
if (destinationFileDirectory.equals("")) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package ml.docilealligator.infinityforreddit.utils;
|
package ml.docilealligator.infinityforreddit.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -153,23 +152,4 @@ public class APIUtils {
|
|||||||
params.put(APIUtils.USER_AGENT_KEY, APIUtils.USER_AGENT);
|
params.put(APIUtils.USER_AGENT_KEY, APIUtils.USER_AGENT);
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRedgifsUserAgent(Context context) {
|
|
||||||
return APIUtils.USER_AGENT;
|
|
||||||
/*String versionName;
|
|
||||||
try {
|
|
||||||
String packageName = context.getPackageName();
|
|
||||||
PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
|
|
||||||
versionName = info.versionName;
|
|
||||||
} catch (Exception e) {
|
|
||||||
versionName = "?";
|
|
||||||
}
|
|
||||||
return "Toro ExoPlayer Extension, v3.7.0.2010003"
|
|
||||||
+ "/"
|
|
||||||
+ versionName
|
|
||||||
+ " (Linux;Android "
|
|
||||||
+ Build.VERSION.RELEASE
|
|
||||||
+ ") "
|
|
||||||
+ ExoPlayerLibraryInfo.VERSION_SLASHY;*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class DefaultExoCreator implements ExoCreator, MediaSourceEventListener {
|
|||||||
|
|
||||||
DataSource.Factory baseFactory = config.dataSourceFactory;
|
DataSource.Factory baseFactory = config.dataSourceFactory;
|
||||||
if (baseFactory == null) {
|
if (baseFactory == null) {
|
||||||
baseFactory = new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.getRedgifsUserAgent(getContext()));
|
baseFactory = new DefaultHttpDataSource.Factory().setUserAgent(APIUtils.USER_AGENT);
|
||||||
}
|
}
|
||||||
DataSource.Factory factory = new DefaultDataSource.Factory(this.toro.context, baseFactory);
|
DataSource.Factory factory = new DefaultDataSource.Factory(this.toro.context, baseFactory);
|
||||||
if (config.cache != null)
|
if (config.cache != null)
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user