Update extractor version and add head request to downloader
This commit is contained in:
parent
4f688862a2
commit
c4eaee1e31
|
@ -57,7 +57,7 @@ dependencies {
|
|||
exclude module: 'support-annotations'
|
||||
})
|
||||
|
||||
implementation 'com.github.teamnewpipe:NewPipeExtractor:06f2144e4daa10'
|
||||
implementation 'com.github.teamnewpipe:NewPipeExtractor:v0.17.4'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:2.23.0'
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
|||
return null;
|
||||
}
|
||||
|
||||
return new DownloadResponse(body.string(), response.headers().toMultimap());
|
||||
return new DownloadResponse(response.code(), body.string(), response.headers().toMultimap());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -275,6 +275,22 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
|||
return null;
|
||||
}
|
||||
|
||||
return new DownloadResponse(body.string(), response.headers().toMultimap());
|
||||
return new DownloadResponse(response.code(), body.string(), response.headers().toMultimap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadResponse head(String siteUrl) throws IOException, ReCaptchaException {
|
||||
final Request request = new Request.Builder()
|
||||
.head().url(siteUrl)
|
||||
.addHeader("User-Agent", USER_AGENT)
|
||||
.build();
|
||||
final Response response = client.newCall(request).execute();
|
||||
|
||||
if (response.code() == 429) {
|
||||
throw new ReCaptchaException("reCaptcha Challenge requested", siteUrl);
|
||||
}
|
||||
|
||||
return new DownloadResponse(response.code(), null, response.headers().toMultimap());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue