mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-06 00:00:10 +00:00
Block bypass attempts
This commit is contained in:
parent
e87a1c079c
commit
f7581f8a65
1 changed files with 28 additions and 3 deletions
|
@ -1171,6 +1171,8 @@ class VideoDetailView : ConstraintLayout {
|
||||||
//@OptIn(ExperimentalCoroutinesApi::class)
|
//@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
fun setVideoDetails(videoDetail: IPlatformVideoDetails, newVideo: Boolean = false) {
|
fun setVideoDetails(videoDetail: IPlatformVideoDetails, newVideo: Boolean = false) {
|
||||||
Logger.i(TAG, "setVideoDetails (${videoDetail.name})")
|
Logger.i(TAG, "setVideoDetails (${videoDetail.name})")
|
||||||
|
_didTriggerDatasourceErrroCount = 0;
|
||||||
|
_didTriggerDatasourceError = false;
|
||||||
|
|
||||||
if(newVideo && this.video?.url == videoDetail.url)
|
if(newVideo && this.video?.url == videoDetail.url)
|
||||||
return;
|
return;
|
||||||
|
@ -1648,6 +1650,7 @@ class VideoDetailView : ConstraintLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var _didTriggerDatasourceErrroCount = 0;
|
||||||
private var _didTriggerDatasourceError = false;
|
private var _didTriggerDatasourceError = false;
|
||||||
private fun onDataSourceError(exception: Throwable) {
|
private fun onDataSourceError(exception: Throwable) {
|
||||||
Logger.e(TAG, "onDataSourceError", exception);
|
Logger.e(TAG, "onDataSourceError", exception);
|
||||||
|
@ -1657,9 +1660,30 @@ class VideoDetailView : ConstraintLayout {
|
||||||
return;
|
return;
|
||||||
val config = currentVideo.sourceConfig;
|
val config = currentVideo.sourceConfig;
|
||||||
|
|
||||||
if(!_didTriggerDatasourceError) {
|
if(_didTriggerDatasourceErrroCount <= 3) {
|
||||||
_didTriggerDatasourceError = true;
|
_didTriggerDatasourceError = true;
|
||||||
|
_didTriggerDatasourceErrroCount++;
|
||||||
|
UIDialogs.toast("Block detected, attempting bypass");
|
||||||
|
|
||||||
|
fragment.lifecycleScope.launch(Dispatchers.IO) {
|
||||||
|
val newDetails = StatePlatform.instance.getContentDetails(currentVideo.url, true).await();
|
||||||
|
val previousVideoSource = _lastVideoSource;
|
||||||
|
val previousAudioSource = _lastAudioSource;
|
||||||
|
|
||||||
|
if(newDetails is IPlatformVideoDetails) {
|
||||||
|
val newVideoSource = if(previousVideoSource != null)
|
||||||
|
VideoHelper.selectBestVideoSource(newDetails.video, previousVideoSource.height * previousVideoSource.width, FutoVideoPlayerBase.PREFERED_VIDEO_CONTAINERS);
|
||||||
|
else null;
|
||||||
|
val newAudioSource = if(previousAudioSource != null)
|
||||||
|
VideoHelper.selectBestAudioSource(newDetails.video, FutoVideoPlayerBase.PREFERED_AUDIO_CONTAINERS, previousAudioSource.language, previousAudioSource.bitrate.toLong());
|
||||||
|
else null;
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
video = newDetails;
|
||||||
|
_player.setSource(newVideoSource, newAudioSource, true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
UIDialogs.showDialog(context, R.drawable.ic_error_pred,
|
UIDialogs.showDialog(context, R.drawable.ic_error_pred,
|
||||||
context.getString(R.string.media_error),
|
context.getString(R.string.media_error),
|
||||||
context.getString(R.string.the_media_source_encountered_an_unauthorized_error_this_might_be_solved_by_a_plugin_reload_would_you_like_to_reload_experimental),
|
context.getString(R.string.the_media_source_encountered_an_unauthorized_error_this_might_be_solved_by_a_plugin_reload_would_you_like_to_reload_experimental),
|
||||||
|
@ -1677,6 +1701,7 @@ class VideoDetailView : ConstraintLayout {
|
||||||
}
|
}
|
||||||
}, UIDialogs.ActionStyle.PRIMARY)
|
}, UIDialogs.ActionStyle.PRIMARY)
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2317,11 +2342,11 @@ class VideoDetailView : ConstraintLayout {
|
||||||
updateTracker(positionMilliseconds, isPlaying, false);
|
updateTracker(positionMilliseconds, isPlaying, false);
|
||||||
|
|
||||||
if(StateDeveloper.instance.isPlaybackTesting) {
|
if(StateDeveloper.instance.isPlaybackTesting) {
|
||||||
if((positionMilliseconds > 1000 * 70 || positionMilliseconds > (video!!.duration * 1000 - 1000))) {
|
if((positionMilliseconds > 1000 * 65 || positionMilliseconds > (video!!.duration * 1000 - 1000))) {
|
||||||
StateDeveloper.instance.testPlayback();
|
StateDeveloper.instance.testPlayback();
|
||||||
}
|
}
|
||||||
else if(video!!.duration > 70 && positionMilliseconds < 10000) {
|
else if(video!!.duration > 70 && positionMilliseconds < 10000) {
|
||||||
handleSeek(40000);
|
handleSeek(55000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue