Start reCaptcha activity when starting video directly
This commit is contained in:
parent
c87da9903f
commit
143df9a529
|
@ -5,8 +5,8 @@ import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.schabi.newpipe.Downloader;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream_info.StreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
|
@ -44,6 +44,7 @@ public class StreamInfoWorker {
|
||||||
public interface OnStreamInfoReceivedListener {
|
public interface OnStreamInfoReceivedListener {
|
||||||
void onReceive(StreamInfo info);
|
void onReceive(StreamInfo info);
|
||||||
void onError(int messageId);
|
void onError(int messageId);
|
||||||
|
void onReCaptchaException();
|
||||||
void onBlockedByGemaError();
|
void onBlockedByGemaError();
|
||||||
void onContentErrorWithMessage(int messageId);
|
void onContentErrorWithMessage(int messageId);
|
||||||
void onContentError();
|
void onContentError();
|
||||||
|
@ -107,6 +108,13 @@ public class StreamInfoWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
// These errors render the stream information unusable.
|
// These errors render the stream information unusable.
|
||||||
|
} catch (ReCaptchaException e) {
|
||||||
|
h.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
onStreamInfoReceivedListener.onReCaptchaException();
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
h.post(new Runnable() {
|
h.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,6 +43,7 @@ import java.util.Vector;
|
||||||
|
|
||||||
import org.schabi.newpipe.ActivityCommunicator;
|
import org.schabi.newpipe.ActivityCommunicator;
|
||||||
import org.schabi.newpipe.ChannelActivity;
|
import org.schabi.newpipe.ChannelActivity;
|
||||||
|
import org.schabi.newpipe.ReCaptchaActivity;
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo;
|
import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo;
|
||||||
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
||||||
|
@ -59,6 +60,9 @@ import org.schabi.newpipe.player.BackgroundPlayer;
|
||||||
import org.schabi.newpipe.player.PlayVideoActivity;
|
import org.schabi.newpipe.player.PlayVideoActivity;
|
||||||
import org.schabi.newpipe.player.ExoPlayerActivity;
|
import org.schabi.newpipe.player.ExoPlayerActivity;
|
||||||
|
|
||||||
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
import static org.schabi.newpipe.ReCaptchaActivity.RECAPTCHA_REQUEST;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||||
|
@ -604,6 +608,17 @@ public class VideoItemDetailFragment extends Fragment {
|
||||||
postNewErrorToast(messageId);
|
postNewErrorToast(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReCaptchaException() {
|
||||||
|
Toast.makeText(getActivity(), R.string.recaptcha_request_toast,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
// Starting ReCaptcha Challenge Activity
|
||||||
|
startActivityForResult(
|
||||||
|
new Intent(getActivity(), ReCaptchaActivity.class),
|
||||||
|
RECAPTCHA_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockedByGemaError() {
|
public void onBlockedByGemaError() {
|
||||||
onErrorBlockedByGema();
|
onErrorBlockedByGema();
|
||||||
|
@ -793,4 +808,23 @@ public class VideoItemDetailFragment extends Fragment {
|
||||||
VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId);
|
VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId);
|
||||||
activity.startActivity(detailIntent);
|
activity.startActivity(detailIntent);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case RECAPTCHA_REQUEST:
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
String videoUrl = getArguments().getString(VIDEO_URL);
|
||||||
|
StreamInfoWorker siw = StreamInfoWorker.getInstance();
|
||||||
|
siw.search(streamingServiceId, videoUrl, getActivity());
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "ReCaptcha failed");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Log.e(TAG, "Request code from activity not supported [" + requestCode + "]");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -271,6 +271,7 @@
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="reCaptchaActivity">reCaptcha</string>
|
<string name="reCaptchaActivity">reCaptcha</string>
|
||||||
<string name="reCaptcha_title">reCaptcha Challenge</string>
|
<string name="reCaptcha_title">reCaptcha Challenge</string>
|
||||||
|
<string name="recaptcha_request_toast">ReCaptcha Challenge requested</string>
|
||||||
|
|
||||||
<!-- End of GigaGet's Strings -->
|
<!-- End of GigaGet's Strings -->
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue