Update extractor version and add head request to downloader

This commit is contained in:
TobiGr 2019-10-28 01:12:45 +01:00
parent 4f688862a2
commit c4eaee1e31
2 changed files with 20 additions and 4 deletions

View File

@ -57,7 +57,7 @@ dependencies {
exclude module: 'support-annotations' exclude module: 'support-annotations'
}) })
implementation 'com.github.teamnewpipe:NewPipeExtractor:06f2144e4daa10' implementation 'com.github.teamnewpipe:NewPipeExtractor:v0.17.4'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0' testImplementation 'org.mockito:mockito-core:2.23.0'

View File

@ -221,7 +221,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
return null; return null;
} }
return new DownloadResponse(body.string(), response.headers().toMultimap()); return new DownloadResponse(response.code(), body.string(), response.headers().toMultimap());
} }
@Override @Override
@ -275,6 +275,22 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
return null; 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());
}
} }