mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 07:13:00 +00:00 
			
		
		
		
	Start reCaptcha activity when starting video directly
This commit is contained in:
		| @@ -5,8 +5,8 @@ import android.os.Handler; | ||||
| import android.util.Log; | ||||
| import android.view.View; | ||||
|  | ||||
| import org.schabi.newpipe.Downloader; | ||||
| 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.StreamInfo; | ||||
| import org.schabi.newpipe.report.ErrorActivity; | ||||
| @@ -44,6 +44,7 @@ public class StreamInfoWorker { | ||||
|     public interface OnStreamInfoReceivedListener { | ||||
|         void onReceive(StreamInfo info); | ||||
|         void onError(int messageId); | ||||
|         void onReCaptchaException(); | ||||
|         void onBlockedByGemaError(); | ||||
|         void onContentErrorWithMessage(int messageId); | ||||
|         void onContentError(); | ||||
| @@ -107,6 +108,13 @@ public class StreamInfoWorker { | ||||
|                 } | ||||
|  | ||||
|                 // These errors render the stream information unusable. | ||||
|             } catch (ReCaptchaException e) { | ||||
|                 h.post(new Runnable() { | ||||
|                     @Override | ||||
|                     public void run() { | ||||
|                         onStreamInfoReceivedListener.onReCaptchaException(); | ||||
|                     } | ||||
|                 }); | ||||
|             } catch (IOException e) { | ||||
|                 h.post(new Runnable() { | ||||
|                     @Override | ||||
|   | ||||
| @@ -43,6 +43,7 @@ import java.util.Vector; | ||||
|  | ||||
| import org.schabi.newpipe.ActivityCommunicator; | ||||
| 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.StreamPreviewInfo; | ||||
| 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.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> | ||||
| @@ -604,6 +608,17 @@ public class VideoItemDetailFragment extends Fragment { | ||||
|                 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 | ||||
|             public void onBlockedByGemaError() { | ||||
|                 onErrorBlockedByGema(); | ||||
| @@ -793,4 +808,23 @@ public class VideoItemDetailFragment extends Fragment { | ||||
|                 VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId); | ||||
|         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="reCaptchaActivity">reCaptcha</string> | ||||
|     <string name="reCaptcha_title">reCaptcha Challenge</string> | ||||
|     <string name="recaptcha_request_toast">ReCaptcha Challenge requested</string> | ||||
|  | ||||
|     <!-- End of GigaGet's Strings --> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Benoît Mauduit
					Benoît Mauduit