File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,16 +102,20 @@ public Response execute(@Nonnull Request request) throws IOException, ReCaptchaE
102102
103103 return new Response (responseCode , responseMessage , responseHeaders , response .toString ());
104104 } catch (Exception e ) {
105+ final int responseCode = connection .getResponseCode ();
106+
105107 /*
106108 * HTTP 429 == Too Many Request
107109 * Receive from Youtube.com = ReCaptcha challenge request
108110 * See : https://github.com/rg3/youtube-dl/issues/5138
109111 */
110- if (connection . getResponseCode () == 429 ) {
112+ if (responseCode == 429 ) {
111113 throw new ReCaptchaException ("reCaptcha Challenge requested" , url );
114+ } else if (responseCode != -1 ) {
115+ return new Response (responseCode , connection .getResponseMessage (), connection .getHeaderFields (), null );
112116 }
113117
114- throw new IOException (connection . getResponseCode () + " " + connection . getResponseMessage () , e );
118+ throw new IOException ("Error occurred while fetching the content" , e );
115119 } finally {
116120 if (outputStream != null ) outputStream .close ();
117121 if (input != null ) input .close ();
You can’t perform that action at this time.
0 commit comments